From d1a5460e3eb939d8de780df9a6530b02fe6d5614 Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Fri, 23 Jan 2015 20:35:13 -0500 Subject: Better file:line parsing and filter method by file too --- railties/test/test_unit/runner_test.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (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 cfc1d897b9..fa906d4080 100644 --- a/railties/test/test_unit/runner_test.rb +++ b/railties/test/test_unit/runner_test.rb @@ -18,4 +18,30 @@ class TestUnitTestRunnerTest < ActiveSupport::TestCase options = @options.parse(["--backtrace"]) assert options[:backtrace] end + + test "parse the filename and line" do + options = @options.parse(["foobar.rb:20"]) + assert_equal File.expand_path("foobar.rb"), options[:filename] + assert_equal 20, options[:line] + + options = @options.parse(["foobar.rb:"]) + assert_equal File.expand_path("foobar.rb"), options[:filename] + assert_nil options[:line] + + options = @options.parse(["foobar.rb"]) + assert_equal File.expand_path("foobar.rb"), options[:filename] + assert_nil options[:line] + end + + test "find_method on same file" do + options = @options.parse(["#{__FILE__}:#{__LINE__}"]) + runner = Rails::TestRunner.new(options) + assert_equal "test_find_method_on_same_file", runner.find_method + end + + test "find_method on a different file" do + options = @options.parse(["foobar.rb:#{__LINE__}"]) + runner = Rails::TestRunner.new(options) + assert_nil runner.find_method + end end -- cgit v1.2.3