Skip to content

Instantly share code, notes, and snippets.

@bryan-ash
Created January 6, 2010 04:09
Show Gist options
  • Save bryan-ash/270002 to your computer and use it in GitHub Desktop.
Save bryan-ash/270002 to your computer and use it in GitHub Desktop.
Simple watchr script for running specs
# Run me with:
#
# $ watchr specs.watchr.rb
# --------------------------------------------------
# Convenience Methods
# --------------------------------------------------
def all_specs
Dir['spec/**/*_spec.rb']
end
def run(cmd)
puts(cmd)
system(cmd)
end
# --------------------------------------------------
# Watchr Rules
# --------------------------------------------------
watch('.*') { |m| run 'spec -c spec/*_spec.rb' }
# --------------------------------------------------
# Signal Handling
# --------------------------------------------------
# Ctrl-\
Signal.trap('QUIT') do
puts " --- Running all specs ---\n\n"
run "spec -cfs #{all_specs.join(' ')}"
end
# Ctrl-C
Signal.trap('INT') { abort("\n") }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment