Created
November 16, 2010 14:00
-
-
Save zorab47/701843 to your computer and use it in GitHub Desktop.
Rails Watchr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run_all_tests | |
# see Rakefile for the definition of the test:all task | |
system( "rake -s test" ) | |
end | |
def run(cmd) | |
puts(cmd) | |
system(cmd) | |
end | |
watch( '^test/(functional|integration|unit)/.*\.rb' ) { |m| run("ruby -I.:lib:test %s" % m[0]) } | |
watch( '^test/fixtures/.*\.yml' ) { run_all_tests } | |
watch( '^app/controllers/(.*)\.rb' ) { |m| run("ruby -I.:lib:test test/functional/%s_test.rb" % m[1]) } | |
watch( '^app/views/(.*)/.*' ) { |m| run("ruby -I.:lib:test test/functional/%s_controller_test.rb" % m[1]) } | |
watch( '^app/models/(.*)\.rb' ) { |m| run("ruby -I.:lib:test test/unit/%s_test.rb" % m[1]) } | |
# helper unit tests | |
watch( '^test/unit/helpers/.*\.rb' ) { |m| run("ruby -I.:lib:test %s" % m[0]) } | |
watch( '^app/helpers/(.*)\.rb' ) { |m| run("ruby -I.:lib:test test/unit/helpers/%s_test.rb" % m[1]) } | |
watch( '^test/test_helper.rb|config/((boot|environment(s/test)?).rb|database.yml)' ) { run_all_tests } | |
# -------------------------------------------------- | |
# Signal Handling | |
# -------------------------------------------------- | |
# Ctrl-\ | |
Signal.trap('QUIT') do | |
puts " --- Running all tests ---\n\n" | |
run_all_tests | |
end | |
# Ctrl-C | |
Signal.trap('INT') { abort("\n") } | |
# vim: syntax=ruby sw=2 ts=2 expandtab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment