augustl (owner)

Revisions

gist: 16519 Download_button fork
public
Public Clone URL: git://gist.github.com/16519.git
Embed All Files: show embed
rtest.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/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