Class: RSpec::Signal::Group
- Inherits:
-
Object
- Object
- RSpec::Signal::Group
- Defined in:
- lib/rspec/signal/group.rb
Overview
A set of failures that share a fingerprint.
Instance Attribute Summary collapse
-
#failures ⇒ Object
readonly
Returns the value of attribute failures.
-
#fingerprint ⇒ Object
readonly
Returns the value of attribute fingerprint.
-
#first_seen ⇒ Object
readonly
Returns the value of attribute first_seen.
Instance Method Summary collapse
- #<<(failure) ⇒ Object
-
#affected_locations ⇒ Object
Locations of every example in the group, in run order, deduplicated.
- #exception_class ⇒ Object
-
#initialize(fingerprint:, first_seen:) ⇒ Group
constructor
A new instance of Group.
- #message ⇒ Object
-
#omitted_frames ⇒ Object
Total backtrace frames this group's failures dropped.
- #others ⇒ Object
-
#representative ⇒ Object
The failure shown in full.
- #size ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(fingerprint:, first_seen:) ⇒ Group
Returns a new instance of Group.
9 10 11 12 13 |
# File 'lib/rspec/signal/group.rb', line 9 def initialize(fingerprint:, first_seen:) @fingerprint = fingerprint @first_seen = first_seen @failures = [] end |
Instance Attribute Details
#failures ⇒ Object (readonly)
Returns the value of attribute failures.
7 8 9 |
# File 'lib/rspec/signal/group.rb', line 7 def failures @failures end |
#fingerprint ⇒ Object (readonly)
Returns the value of attribute fingerprint.
7 8 9 |
# File 'lib/rspec/signal/group.rb', line 7 def fingerprint @fingerprint end |
#first_seen ⇒ Object (readonly)
Returns the value of attribute first_seen.
7 8 9 |
# File 'lib/rspec/signal/group.rb', line 7 def first_seen @first_seen end |
Instance Method Details
#<<(failure) ⇒ Object
15 16 17 18 |
# File 'lib/rspec/signal/group.rb', line 15 def <<(failure) @failures << failure self end |
#affected_locations ⇒ Object
Locations of every example in the group, in run order, deduplicated.
35 36 37 |
# File 'lib/rspec/signal/group.rb', line 35 def affected_locations @affected_locations ||= @failures.map(&:spec_location).uniq end |
#exception_class ⇒ Object
31 |
# File 'lib/rspec/signal/group.rb', line 31 def exception_class = representative.exception_class |
#message ⇒ Object
32 |
# File 'lib/rspec/signal/group.rb', line 32 def = representative. |
#omitted_frames ⇒ Object
Total backtrace frames this group's failures dropped.
44 45 46 |
# File 'lib/rspec/signal/group.rb', line 44 def omitted_frames @failures.sum { |failure| failure.reduced.omitted_count } end |
#others ⇒ Object
39 40 41 |
# File 'lib/rspec/signal/group.rb', line 39 def others @failures.reject { |failure| failure.equal?(representative) } end |
#representative ⇒ Object
The failure shown in full. We pick the one carrying the most first-party frames, because that is the one whose trace is most useful; ties break on run order so the choice is stable across runs.
25 26 27 28 29 |
# File 'lib/rspec/signal/group.rb', line 25 def representative @representative ||= @failures.each_with_index.max_by do |failure, index| [failure.reduced.project_frames.size, failure.reduced.kept_count, -index] end.first end |
#size ⇒ Object
20 |
# File 'lib/rspec/signal/group.rb', line 20 def size = @failures.size |
#to_h ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rspec/signal/group.rb', line 48 def to_h { signature: fingerprint.digest, count: size, exception: exception_class, culprit: fingerprint.culprit, app_context: fingerprint.app_context, representative: representative.to_h, affected: @failures.map { |failure| { location: failure.spec_location, description: failure.description } } }.compact end |