Class: Evilution::Integration::RSpec::StateGuard::ReporterArrays

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

Constant Summary collapse

IVARS =
%i[@examples @failed_examples @pending_examples].freeze

Instance Method Summary collapse

Instance Method Details

#release(lengths) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/evilution/integration/rspec/state_guard/reporter_arrays.rb', line 21

def release(lengths)
  return unless lengths

  reporter = Evilution::Integration::RSpec::StateGuard::Internals.config_ivar(:@reporter)
  return unless reporter

  lengths.each do |ivar, length|
    arr = reporter.instance_variable_get(ivar)
    arr.slice!(length..) if arr.is_a?(Array) && arr.length > length
  end
end

#snapshotObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/evilution/integration/rspec/state_guard/reporter_arrays.rb', line 9

def snapshot
  reporter = Evilution::Integration::RSpec::StateGuard::Internals.config_ivar(:@reporter)
  return nil unless reporter

  IVARS.each_with_object({}) do |ivar, acc|
    next unless reporter.instance_variable_defined?(ivar)

    arr = reporter.instance_variable_get(ivar)
    acc[ivar] = arr.length if arr.is_a?(Array)
  end
end