Class: Evilution::Coverage::Recorder
- Inherits:
-
Object
- Object
- Evilution::Coverage::Recorder
- Defined in:
- lib/evilution/coverage/recorder.rb
Overview
Wraps each example with a before/after coverage diff and attributes the newly-executed lines (in target files only) to that example’s location. coverage_source is injected for testability; in production it is -> { ::Coverage.peek_result }.
Instance Method Summary collapse
- #around_example(example_location) ⇒ Object
-
#initialize(target_files:, coverage_source: -> { ::Coverage.peek_result }) ⇒ Recorder
constructor
A new instance of Recorder.
- #to_map(built_files:) ⇒ Object
Constructor Details
#initialize(target_files:, coverage_source: -> { ::Coverage.peek_result }) ⇒ Recorder
Returns a new instance of Recorder.
11 12 13 14 15 16 |
# File 'lib/evilution/coverage/recorder.rb', line 11 def initialize(target_files:, coverage_source: -> { ::Coverage.peek_result }) @target_files = target_files.to_a @coverage_source = coverage_source @index = Hash.new { |h, file| h[file] = Hash.new { |g, line| g[line] = [] } } @executed = Hash.new { |h, file| h[file] = [] } end |
Instance Method Details
#around_example(example_location) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/evilution/coverage/recorder.rb', line 18 def around_example(example_location) before = snapshot result = yield after = snapshot attribute(before, after, example_location) result end |