Class: Crystalball::MapGenerator::CoverageStrategy

Inherits:
Object
  • Object
show all
Includes:
BaseStrategy
Defined in:
lib/crystalball/map_generator/coverage_strategy.rb,
lib/crystalball/map_generator/coverage_strategy/execution_detector.rb

Overview

Map generator strategy based on harvesting Coverage information during example execution

Defined Under Namespace

Classes: ExecutionDetector

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseStrategy

#after_start, #before_finalize

Constructor Details

#initialize(execution_detector = ExecutionDetector.new) ⇒ CoverageStrategy

Returns a new instance of CoverageStrategy.



15
16
17
# File 'lib/crystalball/map_generator/coverage_strategy.rb', line 15

def initialize(execution_detector = ExecutionDetector.new)
  @execution_detector = execution_detector
end

Instance Attribute Details

#execution_detectorObject (readonly)

Returns the value of attribute execution_detector.



13
14
15
# File 'lib/crystalball/map_generator/coverage_strategy.rb', line 13

def execution_detector
  @execution_detector
end

Instance Method Details

#after_registerObject



19
20
21
# File 'lib/crystalball/map_generator/coverage_strategy.rb', line 19

def after_register
  Coverage.start
end

#call(example_map, example) {|example_map, example| ... } ⇒ Object

Adds to the example_map’s used files the ones the ones in which the coverage has changed after the tests runs.

Parameters:

  • example_map (Crystalball::ExampleGroupMap)
    • object holding example metadata and used files

  • example (RSpec::Core::Example)
    • a RSpec example

Yields:

  • (example_map, example)


27
28
29
30
31
32
# File 'lib/crystalball/map_generator/coverage_strategy.rb', line 27

def call(example_map, example)
  before = Coverage.peek_result
  yield example_map, example
  after = Coverage.peek_result
  example_map.push(*execution_detector.detect(before, after))
end