Class: Flatware::RSpec::Marshalable::SummaryNotification

Inherits:
RSpec::Core::Notifications::SummaryNotification
  • Object
show all
Defined in:
lib/flatware/rspec/marshalable/summary_notification.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_rspec(summary) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/flatware/rspec/marshalable/summary_notification.rb', line 24

def self.from_rspec(summary)
  serialized_examples = [
    summary.examples,
    summary.failed_examples,
    summary.pending_examples
  ].map do |examples|
    examples.map(&Example.method(:new))
  end

  new(summary.duration, *serialized_examples, *summary.to_a[4..])
end

Instance Method Details

#+(other) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/flatware/rspec/marshalable/summary_notification.rb', line 8

def +(other)
  values = to_h.map do |key, value|
    if %i[duration load_time].include?(key)
      [value, other.public_send(key)].max
    else
      value + other.public_send(key)
    end
  end

  self.class.new(*values)
end

#failures?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/flatware/rspec/marshalable/summary_notification.rb', line 20

def failures?
  [failure_count, errors_outside_of_examples_count].any?(&:positive?)
end