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

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

Instance Method Summary collapse

Constructor Details

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

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



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