aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--railties/lib/rails/test_unit/runner.rb9
-rw-r--r--railties/test/test_unit/runner_test.rb18
2 files changed, 21 insertions, 6 deletions
diff --git a/railties/lib/rails/test_unit/runner.rb b/railties/lib/rails/test_unit/runner.rb
index baf33b4468..982f77d0e3 100644
--- a/railties/lib/rails/test_unit/runner.rb
+++ b/railties/lib/rails/test_unit/runner.rb
@@ -51,9 +51,10 @@ module Rails
opt_parser.order!(args)
- if arg = args.shift
+ options[:patterns] = []
+ while arg = args.shift
if Dir.exists?(arg)
- options[:pattern] = "#{arg}/**/*_test.rb"
+ options[:patterns] << "#{arg}/**/*_test.rb"
else
options[:filename], options[:line] = arg.split(':')
options[:filename] = File.expand_path options[:filename]
@@ -102,8 +103,8 @@ module Rails
def test_files
return [@options[:filename]] if @options[:filename]
- if @options[:pattern]
- pattern = @options[:pattern]
+ if @options[:patterns]
+ pattern = @options[:patterns]
else
pattern = "test/**/*_test.rb"
end
diff --git a/railties/test/test_unit/runner_test.rb b/railties/test/test_unit/runner_test.rb
index cd0c66a5f7..9690893a0e 100644
--- a/railties/test/test_unit/runner_test.rb
+++ b/railties/test/test_unit/runner_test.rb
@@ -58,12 +58,26 @@ class TestUnitTestRunnerTest < ActiveSupport::TestCase
test "run all tests in a directory" do
options = @options.parse([__dir__])
- assert_equal "#{__dir__}/**/*_test.rb", options[:pattern]
+ assert_equal ["#{__dir__}/**/*_test.rb"], options[:patterns]
assert_nil options[:filename]
assert_nil options[:line]
end
test "run multiple files" do
- skip "needs implementation"
+ application_dir = File.expand_path("#{__dir__}/../application")
+ options = @options.parse([__dir__, application_dir])
+
+ assert_equal ["#{__dir__}/**/*_test.rb", "#{application_dir}/**/*_test.rb"], options[:patterns]
+ assert_nil options[:filename]
+ assert_nil options[:line]
+ end
+
+ test "run multiple files and run one file by line" do
+ line = __LINE__
+ options = @options.parse([__dir__, "#{__FILE__}:#{line}"])
+
+ assert_equal ["#{__dir__}/**/*_test.rb"], options[:patterns]
+ assert_equal __FILE__, options[:filename]
+ assert_equal line, options[:line]
end
end