Class: Mutant::Strategy

Inherits:
Object
  • Object
show all
Includes:
AbstractType, Adamantium::Flat
Defined in:
lib/mutant/strategy.rb

Overview

Abstract base class for killing strategies

Direct Known Subclasses

Null

Defined Under Namespace

Classes: Null

Constant Summary collapse

REGISTRY =
{}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.lookup(name) ⇒ Strategy

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.

Lookup strategy for name

Parameters:

  • name (String)

Returns:



20
21
22
# File 'lib/mutant/strategy.rb', line 20

def self.lookup(name)
  REGISTRY.fetch(name)
end

Instance Method Details

#all_testsEnumerable<Test>

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.

Return all available tests by strategy

Returns:

  • (Enumerable<Test>)


63
# File 'lib/mutant/strategy.rb', line 63

abstract_method :all_tests

#setupself

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.

Perform strategy setup

Returns:

  • (self)


43
44
45
# File 'lib/mutant/strategy.rb', line 43

def setup
  self
end

#teardownself

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.

Perform strategy teardown

Returns:

  • (self)


53
54
55
# File 'lib/mutant/strategy.rb', line 53

def teardown
  self
end

#tests(subject) ⇒ Enumerable<Test>

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.

Return tests for mutation

TODO: This logic is now centralized but still fucked.

Parameters:

Returns:

  • (Enumerable<Test>)


75
76
77
78
79
80
81
82
83
84
# File 'lib/mutant/strategy.rb', line 75

def tests(subject)
  subject.match_prefixes.map do |match_expression|
    tests = all_tests.select do |test|
      test.subject_identification.start_with?(match_expression)
    end
    return tests if tests.any?
  end

  EMPTY_ARRAY
end