Class: RSpec::Signal::Failure
- Inherits:
-
Object
- Object
- RSpec::Signal::Failure
- Defined in:
- lib/rspec/signal/failure.rb
Overview
One failed example, normalized and reduced. Pure data -- it knows nothing about RSpec, so every downstream stage is trivially testable.
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#diagnostics ⇒ Object
readonly
Returns the value of attribute diagnostics.
-
#example_id ⇒ Object
readonly
Returns the value of attribute example_id.
-
#exception_class ⇒ Object
readonly
Returns the value of attribute exception_class.
-
#frames ⇒ Object
readonly
Returns the value of attribute frames.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#reduced ⇒ Object
readonly
Returns the value of attribute reduced.
-
#rerun ⇒ Object
readonly
Returns the value of attribute rerun.
-
#shared_group_locations ⇒ Object
readonly
Returns the value of attribute shared_group_locations.
-
#spec_location ⇒ Object
readonly
Returns the value of attribute spec_location.
Instance Method Summary collapse
- #fingerprint ⇒ Object
-
#initialize(description:, spec_location:, exception_class:, message:, reduced:, frames:, rerun: nil, example_id: nil, diagnostics: {}, shared_group_locations: [], raw: nil, fingerprint: nil) ⇒ Failure
constructor
A new instance of Failure.
-
#symptom ⇒ Object
The one diagnostic characteristic this failure clusters on, if any.
- #to_h ⇒ Object
Constructor Details
#initialize(description:, spec_location:, exception_class:, message:, reduced:, frames:, rerun: nil, example_id: nil, diagnostics: {}, shared_group_locations: [], raw: nil, fingerprint: nil) ⇒ Failure
Returns a new instance of Failure.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rspec/signal/failure.rb', line 12 def initialize(description:, spec_location:, exception_class:, message:, reduced:, frames:, rerun: nil, example_id: nil, diagnostics: {}, shared_group_locations: [], raw: nil, fingerprint: nil) @description = description @spec_location = spec_location @exception_class = exception_class @message = @reduced = reduced @frames = frames @rerun = rerun || spec_location @example_id = example_id @diagnostics = diagnostics @shared_group_locations = shared_group_locations @raw = raw @fingerprint = fingerprint end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
8 9 10 |
# File 'lib/rspec/signal/failure.rb', line 8 def description @description end |
#diagnostics ⇒ Object (readonly)
Returns the value of attribute diagnostics.
8 9 10 |
# File 'lib/rspec/signal/failure.rb', line 8 def diagnostics @diagnostics end |
#example_id ⇒ Object (readonly)
Returns the value of attribute example_id.
8 9 10 |
# File 'lib/rspec/signal/failure.rb', line 8 def example_id @example_id end |
#exception_class ⇒ Object (readonly)
Returns the value of attribute exception_class.
8 9 10 |
# File 'lib/rspec/signal/failure.rb', line 8 def exception_class @exception_class end |
#frames ⇒ Object (readonly)
Returns the value of attribute frames.
8 9 10 |
# File 'lib/rspec/signal/failure.rb', line 8 def frames @frames end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
8 9 10 |
# File 'lib/rspec/signal/failure.rb', line 8 def @message end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
8 9 10 |
# File 'lib/rspec/signal/failure.rb', line 8 def raw @raw end |
#reduced ⇒ Object (readonly)
Returns the value of attribute reduced.
8 9 10 |
# File 'lib/rspec/signal/failure.rb', line 8 def reduced @reduced end |
#rerun ⇒ Object (readonly)
Returns the value of attribute rerun.
8 9 10 |
# File 'lib/rspec/signal/failure.rb', line 8 def rerun @rerun end |
#shared_group_locations ⇒ Object (readonly)
Returns the value of attribute shared_group_locations.
8 9 10 |
# File 'lib/rspec/signal/failure.rb', line 8 def shared_group_locations @shared_group_locations end |
#spec_location ⇒ Object (readonly)
Returns the value of attribute spec_location.
8 9 10 |
# File 'lib/rspec/signal/failure.rb', line 8 def spec_location @spec_location end |
Instance Method Details
#fingerprint ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/rspec/signal/failure.rb', line 29 def fingerprint @fingerprint ||= Fingerprint.for( exception_class: exception_class, message: .normalized, frames: frames, fallback_location: spec_location ) end |
#symptom ⇒ Object
The one diagnostic characteristic this failure clusters on, if any.
nil is the common and safe answer.
40 41 42 43 44 |
# File 'lib/rspec/signal/failure.rb', line 40 def symptom return @symptom if defined?(@symptom) @symptom = Symptoms.for(self) end |
#to_h ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rspec/signal/failure.rb', line 46 def to_h { description: description, location: spec_location, rerun: rerun, id: example_id, exception: exception_class, message: .body, trace: reduced.entries.map(&:to_h), omitted_frames: reduced.omitted_count, diagnostics: diagnostics, symptom: symptom&.to_h }.reject { |_, value| value.nil? || (value.respond_to?(:empty?) && value.empty?) } end |