Class: Flatware::RSpec::Checkpoint

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/flatware/rspec/checkpoint.rb

Overview

Marshalable container for the run details from a worker. Can be added to other checkpoints to create a final run summary.

Constant Summary collapse

EVENTS =
%i[
  deprecation
  dump_failures
  dump_pending
  dump_profile
  dump_summary
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(events = {}) ⇒ Checkpoint

Returns a new instance of Checkpoint.



28
29
30
# File 'lib/flatware/rspec/checkpoint.rb', line 28

def initialize(events = {})
  @events = { deprecation: [] }.merge(events)
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



26
27
28
# File 'lib/flatware/rspec/checkpoint.rb', line 26

def events
  @events
end

Class Method Details

.listen_for(event, &block) ⇒ Object



32
33
34
35
36
# File 'lib/flatware/rspec/checkpoint.rb', line 32

def self.listen_for(event, &block)
  define_method(event) do |notification|
    instance_exec(Marshalable.for_event(event).from_rspec(notification), &block)
  end
end

Instance Method Details

#+(other) ⇒ Object



48
49
50
# File 'lib/flatware/rspec/checkpoint.rb', line 48

def +(other)
  self.class.new(events.merge(other.events) { |_, event, other_event| event + other_event })
end

#deprecationsObject



56
57
58
# File 'lib/flatware/rspec/checkpoint.rb', line 56

def deprecations
  events.fetch(:deprecation)
end

#profileObject



60
61
62
# File 'lib/flatware/rspec/checkpoint.rb', line 60

def profile
  events[:dump_profile]
end

#summaryObject



52
53
54
# File 'lib/flatware/rspec/checkpoint.rb', line 52

def summary
  events.fetch(:dump_summary)
end