Sha256: add55a327da3cc826934322921ad9bb2749a8b39743036ad83c71147bc20a77e

Contents?: true

Size: 516 Bytes

Versions: 1

Compression:

Stored size: 516 Bytes

Contents

module TestFileFinder
  class FileFinder
    def initialize(paths: [], mapping: nil)
      @paths = [paths].flatten
      @mapping = mapping
    end

    def test_files
      search
    end

    private

    attr_reader :paths

    def search
      file_path_guesses.select { |path| File.exist?(path) }
    end

    def file_path_guesses
      paths.flat_map do |path|
        guess_test_files_for(path)
      end.compact.uniq
    end

    def guess_test_files_for(path)
      @mapping.match(path)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
test_file_finder-0.1.0 lib/test_file_finder/file_finder.rb