Skip to content

Instantly share code, notes, and snippets.

@bjhess
Forked from Oshuma/rails.watchr.rb
Created February 23, 2010 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjhess/312782 to your computer and use it in GitHub Desktop.
Save bjhess/312782 to your computer and use it in GitHub Desktop.
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