diff --git a/bin/rt b/bin/rt index 5e24368..02527fe 100755 --- a/bin/rt +++ b/bin/rt @@ -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| @@ -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}" @@ -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} diff --git a/features/cli.feature b/features/cli.feature index eb54eb3..6639fd9 100644 --- a/features/cli.feature +++ b/features/cli.feature @@ -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 diff --git a/features/cli_load_path.feature b/features/cli_load_path.feature index 4c2bb72..b9b32b2 100644 --- a/features/cli_load_path.feature +++ b/features/cli_load_path.feature @@ -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: """ @@ -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"