Created
October 13, 2008 11:09
-
-
Save augustl/16519 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
# Runs Rails tests via command line. | |
# | |
# * rtest unit - runs all unit tests | |
# * rtest unit post - runs the unit test for the 'post' model | |
# * rtest unit post comment foo - runs those tests, yep | |
# * rtest functional - you guessed it! | |
# * rtest integration - blows up your computer | |
case ARGV.size | |
when 0 | |
# run all of them | |
exec("rake test") | |
when 1 | |
case ARGV[0] | |
when 'unit', 'functional' | |
exec("rake test:#{ARGV[0]}s") | |
when 'integration' | |
# The integration task is not plural. | |
exec("rake test:integration") | |
end | |
else | |
# run a given set of tests | |
here = Dir.pwd | |
$: << File.join(here, 'lib') | |
$: << File.join(here, 'test') | |
test_type = ARGV.shift | |
test_files = case test_type | |
when 'unit', 'integration' | |
ARGV.map {|test_name| "test/#{test_type}/#{test_name}_test.rb" } | |
when 'functional' | |
ARGV.map {|test_name| "test/#{test_type}/#{test_name}_controller_test.rb" } | |
end | |
puts "Running tests: #{test_files.join(' ')}" | |
test_files.each {|f| load f } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment