Skip to content

Instantly share code, notes, and snippets.

@nathanclark
Created February 8, 2010 14:56
Show Gist options
  • Save nathanclark/298202 to your computer and use it in GitHub Desktop.
Save nathanclark/298202 to your computer and use it in GitHub Desktop.
# --------------------------------------------------
require 'rubygems'
def run(cmd)
puts(cmd)
system(cmd)
end
def run_all_tests
# see Rakefile for the definition of the test:all task
system( "rake -s test:all VERBOSE=true" )
end
watch( '^vendor/plugins/(.*)/app/controllers/admin/(.*)\.rb') { |m| run( "ruby -Ilib vendor/plugins/#{m[1]}/test/test_helper .rb -Itest vendor/plugins/#{m[1]}/test/functional/admin/%s_test.rb" % m[2] ) }
watch( '^vendor/plugins/(.*)/test/functional/admin/(.*)_test\.rb') { |m| run( "ruby -Itest %s" % m[0] ) }
watch( '^vendor/plugins/(.*)/app/models/admin/(.*)\.rb') { |m| run( "ruby -Ilib vendor/plugins/#{m[1]}/test/test_helper -Itest vendor/plugins/#{m[1]}/test/unit/admin/%s_test.rb" % m[2] ) }
watch( '^vendor/plugins/(.*)/test/unit/admin/(.*)_test\.rb') { |m| run( "ruby -Itest %s" % m[0] ) }
watch( '^vendor/plugins/(.*)/app/controllers/(.*)\.rb') { |m| run( "ruby -Ilib vendor/plugins/#{m[1]}/test/test_helper -Itest vendor/plugins/#{m[1]}/test/functional/%s_test.rb" % m[2] ) }
watch( '^vendor/plugins/(.*)/test/functional/(.*)_test\.rb') { |m| run( "ruby -Itest %s" % m[0] ) }
watch( '^vendor/plugins/(.*)/app/models/(.*)\.rb') { |m| run( "ruby -Ilib vendor/plugins/#{m[1]}/test/test_helper -Itest vendor/plugins/#{m[1]}/test/unit/%s_test.rb" % m[2] ) }
watch( '^vendor/plugins/(.*)/test/unit/(.*)_test\.rb') { |m| run( "ruby -Itest %s" % m[0] ) }
# --------------------------------------------------
# Signal Handling
# --------------------------------------------------
# Ctrl-\
Signal.trap('QUIT') do
puts " --- Running all tests ---\n\n"
run_all_tests
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