Class: Retest::MatchingOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/retest/matching_options.rb,
lib/retest/matching_options/path.rb

Defined Under Namespace

Classes: Path

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, files: [], limit: 5, test_directories: nil) ⇒ MatchingOptions

Returns a new instance of MatchingOptions.



11
12
13
14
15
16
# File 'lib/retest/matching_options.rb', line 11

def initialize(path, files: [], limit: 5, test_directories: nil)
  @path = Path.new(path)
  @files = files
  @limit = limit || 5
  @test_directories = (test_directories || %w[spec test]) + %w[.] # add root file as a valid test directory
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



9
10
11
# File 'lib/retest/matching_options.rb', line 9

def files
  @files
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/retest/matching_options.rb', line 9

def path
  @path
end

#test_directoriesObject (readonly)

Returns the value of attribute test_directories.



9
10
11
# File 'lib/retest/matching_options.rb', line 9

def test_directories
  @test_directories
end

Class Method Details

.for(path, files: [], limit: nil) ⇒ Object



5
6
7
# File 'lib/retest/matching_options.rb', line 5

def self.for(path, files: [], limit: nil)
  new(path, files: files, limit: limit).filtered_results
end

Instance Method Details

#filtered_resultsObject



18
19
20
21
22
23
24
25
26
# File 'lib/retest/matching_options.rb', line 18

def filtered_results
  if path.test?(test_directories: test_directories)
    [path]
  elsif (screened_tests = screen_namespaces(possible_tests)).any?
    screened_tests
  else
    possible_tests
  end.map(&:to_s)
end