diff options
author | Arthur Neves <arthurnn@gmail.com> | 2015-01-29 10:00:43 -0500 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-03-18 09:52:18 +0100 |
commit | b58c0914f4d85faa39f22eb3408970ac8a176913 (patch) | |
tree | 339361a7e1a084bd0ed3d563b4362e3c503ce2a1 | |
parent | 090c83672f333d6a4d87752ca1f980bfb6be6849 (diff) | |
download | rails-b58c0914f4d85faa39f22eb3408970ac8a176913.tar.gz rails-b58c0914f4d85faa39f22eb3408970ac8a176913.tar.bz2 rails-b58c0914f4d85faa39f22eb3408970ac8a176913.zip |
Run multiple files on runner
-rw-r--r-- | railties/lib/rails/test_unit/runner.rb | 9 | ||||
-rw-r--r-- | railties/test/test_unit/runner_test.rb | 18 |
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 |