Skip to content

Instantly share code, notes, and snippets.

@levicole
Forked from vinbarnes/gist:271870
Created March 18, 2010 23:22
Show Gist options
  • Save levicole/337044 to your computer and use it in GitHub Desktop.
Save levicole/337044 to your computer and use it in GitHub Desktop.
puts "\n--- watchr initialized ---\n\n"
def cmd() 'script/spec '; end
def run_all_specs
system(cmd + 'spec/')
end
def run_spec(spec)
puts "Running #{spec}"
system(cmd + spec)
puts
end
watch('^spec\/.*\/.*_spec\.rb') {|md| run_spec(md[0]) }
watch('^app/(.*)\.rb') {|md| run_spec("spec/#{md[1]}_spec.rb") }
watch('spec/spec_helper.rb') {|md| run_all_specs }
# Ctrl-\
Signal.trap('QUIT') do
puts "\n--- Running all tests ---\n"
run_all_specs
puts
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