Class: RSpec::Signal::Fingerprint
- Inherits:
-
Struct
- Object
- Struct
- RSpec::Signal::Fingerprint
- Defined in:
- lib/rspec/signal/fingerprint.rb,
lib/rspec/signal/fingerprint.rb
Overview
Construction and rendering for the fingerprint value object above.
Constant Summary collapse
- DEFAULT_SPEC_PATTERNS =
Constants inside a
Struct.newblock would land on the enclosing module, so define this one explicitly. [%r{\Aspec/}, %r{\Atest/}, /_spec\.rb\z/, /_test\.rb\z/].freeze
Instance Attribute Summary collapse
-
#app_context ⇒ Object
Returns the value of attribute app_context.
-
#culprit ⇒ Object
Returns the value of attribute culprit.
-
#exception_class ⇒ Object
Returns the value of attribute exception_class.
-
#message ⇒ Object
Returns the value of attribute message.
Class Method Summary collapse
Instance Method Summary collapse
-
#digest ⇒ Object
Joined on NUL so that shifting text from one component into the next cannot produce the same digest.
- #to_h ⇒ Object
Instance Attribute Details
#app_context ⇒ Object
Returns the value of attribute app_context
22 23 24 |
# File 'lib/rspec/signal/fingerprint.rb', line 22 def app_context @app_context end |
#culprit ⇒ Object
Returns the value of attribute culprit
22 23 24 |
# File 'lib/rspec/signal/fingerprint.rb', line 22 def culprit @culprit end |
#exception_class ⇒ Object
Returns the value of attribute exception_class
22 23 24 |
# File 'lib/rspec/signal/fingerprint.rb', line 22 def exception_class @exception_class end |
#message ⇒ Object
Returns the value of attribute message
22 23 24 |
# File 'lib/rspec/signal/fingerprint.rb', line 22 def @message end |
Class Method Details
.for(exception_class:, message:, frames:, fallback_location:, spec_patterns: DEFAULT_SPEC_PATTERNS) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rspec/signal/fingerprint.rb', line 30 def self.for(exception_class:, message:, frames:, fallback_location:, spec_patterns: DEFAULT_SPEC_PATTERNS) significant = frames.reject(&:framework?) culprit = significant.first app_context = significant.find do |frame| frame.project? && spec_patterns.none? { |pattern| pattern.match?(frame.display_path) } end new( exception_class: exception_class.to_s, message: .to_s, culprit: culprit&.location || fallback_location, app_context: app_context&.location ) end |
Instance Method Details
#digest ⇒ Object
Joined on NUL so that shifting text from one component into the next cannot produce the same digest.
47 48 49 |
# File 'lib/rspec/signal/fingerprint.rb', line 47 def digest @digest ||= Digest::SHA256.hexdigest(to_a.join("\0"))[0, 12] end |
#to_h ⇒ Object
51 52 53 |
# File 'lib/rspec/signal/fingerprint.rb', line 51 def to_h { exception: exception_class, culprit: culprit, app_context: app_context, digest: digest }.compact end |