Skip to content

Instantly share code, notes, and snippets.

@Oshuma
Created October 4, 2009 02:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Oshuma/201067 to your computer and use it in GitHub Desktop.
Save Oshuma/201067 to your computer and use it in GitHub Desktop.
rails.watchr.rb
def run_tests(test_type)
case test_type
when :all
system('rake test')
when /(controllers|functional)\/?/
system('rake test:functionals')
when /(models|unit)\/?/
system('rake test:units')
else
# do nothing...
end
end
[
'app/(.*/)?.*\.rb',
'test/(.*/)?.*_test\.rb'
].each { |pattern| watch(pattern) { |md| run_tests(md[1]) } }
# Ctrl-\
Signal.trap('QUIT') do
puts "\n--- Running all tests ---\n"
run_tests(:all)
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