-
-
Save gotascii/920074 to your computer and use it in GitHub Desktop.
command-line rails test runner
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| def run_testunit(runner, path) | |
| path = path.gsub(/\/?test\/?/, '') | |
| path.gsub!(/_test.rb/, '') | |
| exec "#{runner} -I'test' test/#{path}_test.rb" | |
| end | |
| def run_unit(runner) | |
| run_testunit runner, "unit/#{ARGV[1]}" | |
| end | |
| def run_functional(runner) | |
| run_testunit runner, "functional/#{ARGV[1]}_controller" | |
| end | |
| def run_rspec(path) | |
| path = path.gsub(/^\/?spec\/?/, '') | |
| path.gsub!(/_spec.rb/, '') | |
| exec "rspec --drb -I'spec' spec/#{path}_spec.rb" | |
| end | |
| def run_model | |
| run_rspec "models/#{ARGV[1]}" | |
| end | |
| def run_controller | |
| run_rspec "controllers/#{ARGV[1]}_controller" | |
| end | |
| case ARGV[0] | |
| when "u" | |
| run_unit "ruby" | |
| when "ru" | |
| run_unit "testdrb" | |
| when "f" | |
| run_functional "ruby" | |
| when "rf" | |
| run_functional "testdrb" | |
| when "m" | |
| run_model | |
| when "c" | |
| run_controller | |
| when "sp" | |
| run_rspec ARGV[1] | |
| when "up" | |
| run_unit "ruby", ARGV[1] | |
| when "rup" | |
| run_unit "testdrb", ARGV[1] | |
| else | |
| puts <<-HELP | |
| rrt, run rails test | |
| unit rrt u dog | |
| unit spork rrt ru dog | |
| unit PATH rrt up PATH | |
| unit spork PATH rrt rup PATH | |
| functional rrt f dogs | |
| functional spork rrt rf dogs | |
| rspec model rrt m dog | |
| rspec controller rrt c dogs | |
| rspec PATH rrt sp PATH | |
| HELP | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment