Class: Evilution::Integration::RSpec::TestFileResolver Private

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/integration/rspec/test_file_resolver.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(test_files:, spec_selector:, related_spec_heuristic:, related_specs_heuristic_enabled:, fallback_to_full_suite:, warner:) ⇒ TestFileResolver

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of TestFileResolver.



6
7
8
9
10
11
12
13
14
# File 'lib/evilution/integration/rspec/test_file_resolver.rb', line 6

def initialize(test_files:, spec_selector:, related_spec_heuristic:,
               related_specs_heuristic_enabled:, fallback_to_full_suite:, warner:)
  @test_files = test_files
  @spec_selector = spec_selector
  @related_spec_heuristic = related_spec_heuristic
  @related_specs_heuristic_enabled = related_specs_heuristic_enabled
  @fallback_to_full_suite = fallback_to_full_suite
  @warner = warner
end

Instance Method Details

#call(mutation) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/evilution/integration/rspec/test_file_resolver.rb', line 16

def call(mutation)
  return @test_files if @test_files

  resolved = Array(@spec_selector.call(mutation.file_path))
  if resolved.empty?
    @warner.call(mutation.file_path, fallback_to_full_suite: @fallback_to_full_suite)
    return @fallback_to_full_suite ? ["spec"] : nil
  end

  return resolved unless @related_specs_heuristic_enabled

  related = @related_spec_heuristic.call(mutation)
  (resolved + related).uniq
end