Sha256: 22ebaf5f61f80a2d6e772a083414bbcc37538a71acac6fbe79e2712400dd0cda

Contents?: true

Size: 760 Bytes

Versions: 6

Compression:

Stored size: 760 Bytes

Contents

require "active_support/core_ext/object/blank"
require "rake/file_list"

module Rails
  class TestRequirer # :nodoc:
    class << self
      def require_files(patterns, exclude_patterns = [])
        patterns = expand_patterns(patterns)

        file_list = Rake::FileList[patterns.compact.presence || "test/**/*_test.rb"]
        file_list.exclude(exclude_patterns)

        file_list.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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
railties-5.1.2 lib/rails/test_unit/test_requirer.rb
railties-5.1.2.rc1 lib/rails/test_unit/test_requirer.rb
railties-5.1.1 lib/rails/test_unit/test_requirer.rb
railties-5.1.0 lib/rails/test_unit/test_requirer.rb
railties-5.1.0.rc2 lib/rails/test_unit/test_requirer.rb
railties-5.1.0.rc1 lib/rails/test_unit/test_requirer.rb