mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add tests for runner#test_files method
This commit is contained in:
parent
b58c0914f4
commit
3cc783b6bf
2 changed files with 21 additions and 7 deletions
|
@ -94,13 +94,6 @@ module Rails
|
|||
@options[:backtrace]
|
||||
end
|
||||
|
||||
private
|
||||
def run_tests
|
||||
test_files.to_a.each do |file|
|
||||
require File.expand_path file
|
||||
end
|
||||
end
|
||||
|
||||
def test_files
|
||||
return [@options[:filename]] if @options[:filename]
|
||||
if @options[:patterns]
|
||||
|
@ -111,6 +104,13 @@ module Rails
|
|||
Rake::FileList[pattern]
|
||||
end
|
||||
|
||||
private
|
||||
def run_tests
|
||||
test_files.to_a.each do |file|
|
||||
require File.expand_path file
|
||||
end
|
||||
end
|
||||
|
||||
def test_methods
|
||||
methods_map = []
|
||||
suites = Minitest::Runnable.runnables.shuffle
|
||||
|
|
|
@ -70,6 +70,9 @@ class TestUnitTestRunnerTest < ActiveSupport::TestCase
|
|||
assert_equal ["#{__dir__}/**/*_test.rb", "#{application_dir}/**/*_test.rb"], options[:patterns]
|
||||
assert_nil options[:filename]
|
||||
assert_nil options[:line]
|
||||
|
||||
runner = Rails::TestRunner.new(options)
|
||||
assert runner.test_files.size > 0
|
||||
end
|
||||
|
||||
test "run multiple files and run one file by line" do
|
||||
|
@ -79,5 +82,16 @@ class TestUnitTestRunnerTest < ActiveSupport::TestCase
|
|||
assert_equal ["#{__dir__}/**/*_test.rb"], options[:patterns]
|
||||
assert_equal __FILE__, options[:filename]
|
||||
assert_equal line, options[:line]
|
||||
|
||||
runner = Rails::TestRunner.new(options)
|
||||
assert_equal [__FILE__], runner.test_files, 'Only returns the file that running by line'
|
||||
end
|
||||
|
||||
test "running multiple files passing line number" do
|
||||
line = __LINE__
|
||||
options = @options.parse(["foobar.rb:8", "#{__FILE__}:#{line}"])
|
||||
|
||||
assert_equal __FILE__, options[:filename], 'Returns the last file'
|
||||
assert_equal line, options[:line]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue