Skip to content

Commit

Permalink
do not passing extra info into ARGV
Browse files Browse the repository at this point in the history
  • Loading branch information
allenwei committed Jan 17, 2011
1 parent 64e2c74 commit 8f8d033
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 7 additions & 5 deletions bin/rt
Expand Up @@ -4,6 +4,9 @@ require File.join("rt.rb")

test_files = []

options = []
$: << File.join(".","test")

while f = ARGV.pop do
if f =~ /\*/
Dir.glob(f) do |test_file|
Expand All @@ -16,10 +19,10 @@ while f = ARGV.pop do
test_name = nil
%w[UnitTest ActiveSupportTestCase Shoulda].each do |matcher|
klass = eval("Rt::Matchers::#{matcher}")
break if test_name = klass.test_name(line)
break if test_name = klass.test_name(line)
end
if test_name
ARGV << "--name=/#{test_name}/"
if !test_name.nil?
options << "--name=/#{test_name.strip}/"
test_files << file_name
else
STDERR.puts "Can not find test in file #{file_name} line #{line_num}"
Expand All @@ -33,7 +36,6 @@ while f = ARGV.pop do
test_files << f
end
end
ARGV << "-Itest"
STDOUT.puts "run test #{ARGV.join(' ')} #{test_files.join(', ')}"
options.each {|o| ARGV << o }
test_files.each {|f| load f}

8 changes: 4 additions & 4 deletions features/cli.feature
Expand Up @@ -15,22 +15,22 @@ Feature: Runner
"""

Scenario: Run single file from command-line
When I run "bundle exec rt test/test_one.rb"
When I successfully run "bundle exec rt test/test_one.rb"
Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
And the exit status should be 0

Scenario: Run two file from command-line
When I run "bundle exec rt test/test_one.rb test/test_two.rb"
When I successfully run "bundle exec rt test/test_one.rb test/test_two.rb"
Then the stdout should contain "2 tests, 2 assertions, 0 failures, 0 errors"
And the exit status should be 0

Scenario: Run tests in folder
When I run "bundle exec rt test"
When I successfully run "bundle exec rt test"
Then the stdout should contain "2 tests, 2 assertions, 0 failures, 0 errors"
And the exit status should be 0

Scenario: Run tests with regular expression
When I run "bundle exec rt **/*_one.rb"
When I successfully run "bundle exec rt **/*_one.rb"
Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
And the exit status should be 0

8 changes: 3 additions & 5 deletions features/cli_load_path.feature
Expand Up @@ -3,7 +3,7 @@ Feature: Load path when running test
Scenario: default load path is "test" folder
Given a file named "test/test_helper.rb" with:
"""
puts 'load test_helper'
#no thing
"""
And a test file "test_one.rb" with:
"""
Expand All @@ -13,7 +13,5 @@ Feature: Load path when running test
assert true
end
"""
When I run "bundle exec rt test_one.rb"
Then the stdout should contain "load test_helper"
And the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"
And the exit status should be 0
When I successfully run "bundle exec rt test_one.rb"
Then the stdout should contain "1 tests, 1 assertions, 0 failures, 0 errors"

0 comments on commit 8f8d033

Please sign in to comment.