1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/lib/rails/test_unit/test_requirer.rb
yuuji.yaginuma 084a3908fc raise LoadError when a non-existent file or directory is specified to the test runner
Currently, if a file or directory that does not exist was specified in the test runner,
that argument is ignored.
This commit has been modified to cause an error if there is no file or directory.
2015-09-07 08:13:50 +09:00

28 lines
661 B
Ruby

require 'active_support/core_ext/object/blank'
require 'rake/file_list'
module Rails
class TestRequirer # :nodoc:
class << self
def require_files(patterns)
patterns = expand_patterns(patterns)
Rake::FileList[patterns.compact.presence || 'test/**/*_test.rb'].to_a.each do |file|
require File.expand_path(file)
end
end
private
def expand_patterns(patterns)
patterns.map do |arg|
arg = arg.gsub(/:(\d+)?$/, '')
if Dir.exist?(arg)
"#{arg}/**/*_test.rb"
else
arg
end
end
end
end
end
end