From de94929d70d94fd8bb20791bf544ee483db8ddc1 Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Thu, 29 Jan 2015 10:39:43 -0500 Subject: Fix relative dir call on test runner --- railties/test/test_unit/runner_test.rb | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'railties/test/test_unit') diff --git a/railties/test/test_unit/runner_test.rb b/railties/test/test_unit/runner_test.rb index 94f338344d..e8623bef67 100644 --- a/railties/test/test_unit/runner_test.rb +++ b/railties/test/test_unit/runner_test.rb @@ -30,16 +30,18 @@ class TestUnitTestRunnerTest < ActiveSupport::TestCase end test "parse the filename and line" do - options = @options.parse(["foobar.rb:20"]) - assert_equal File.expand_path("foobar.rb"), options[:filename] + file = "test/test_unit/runner_test.rb" + absolute_file = __FILE__ + options = @options.parse(["#{file}:20"]) + assert_equal absolute_file, options[:filename] assert_equal 20, options[:line] - options = @options.parse(["foobar.rb:"]) - assert_equal File.expand_path("foobar.rb"), options[:filename] + options = @options.parse(["#{file}:"]) + assert_equal [absolute_file], options[:patterns] assert_nil options[:line] - options = @options.parse(["foobar.rb"]) - assert_equal File.expand_path("foobar.rb"), options[:filename] + options = @options.parse([file]) + assert_equal [absolute_file], options[:patterns] assert_nil options[:line] end @@ -56,16 +58,18 @@ class TestUnitTestRunnerTest < ActiveSupport::TestCase end test "run all tests in a directory" do - options = @options.parse([__dir__]) + dir = Pathname.new(__dir__).basename.to_s + options = @options.parse([dir]) assert_equal ["#{__dir__}/**/*_test.rb"], options[:patterns] assert_nil options[:filename] assert_nil options[:line] end - test "run multiple files" do + test "run multiple folders" do application_dir = File.expand_path("#{__dir__}/../application") - options = @options.parse([__dir__, application_dir]) + + options = @options.parse([Pathname.new(__dir__).basename.to_s, Pathname.new(application_dir).basename.to_s]) assert_equal ["#{__dir__}/**/*_test.rb", "#{application_dir}/**/*_test.rb"], options[:patterns] assert_nil options[:filename] @@ -77,7 +81,7 @@ class TestUnitTestRunnerTest < ActiveSupport::TestCase test "run multiple files and run one file by line" do line = __LINE__ - options = @options.parse([__dir__, "#{__FILE__}:#{line}"]) + options = @options.parse([Pathname.new(__dir__).basename.to_s, "#{__FILE__}:#{line}"]) assert_equal ["#{__dir__}/**/*_test.rb"], options[:patterns] assert_equal __FILE__, options[:filename] -- cgit v1.2.3