Class: RSpec::Signal::FailureBuilder
- Inherits:
-
Object
- Object
- RSpec::Signal::FailureBuilder
- Defined in:
- lib/rspec/signal/failure_builder.rb
Overview
Turns an RSpec FailedExampleNotification into a plain Failure.
This is the only place that touches RSpec's notification API, which keeps the reduction, grouping and rendering stages testable without booting a suite.
Constant Summary collapse
- SCREENSHOT =
/\[Screenshot(?:\s+Image)?\]:\s*(\S+)/i- MAX_CAUSE_DEPTH =
3- MAX_CAUSE_MESSAGE_LINES =
5- MAX_CAUSE_SCAN =
40
Instance Method Summary collapse
- #call(notification, position: nil) ⇒ Failure
-
#initialize(config) ⇒ FailureBuilder
constructor
A new instance of FailureBuilder.
Constructor Details
#initialize(config) ⇒ FailureBuilder
Returns a new instance of FailureBuilder.
16 17 18 |
# File 'lib/rspec/signal/failure_builder.rb', line 16 def initialize(config) @config = config end |
Instance Method Details
#call(notification, position: nil) ⇒ Failure
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rspec/signal/failure_builder.rb', line 23 def call(notification, position: nil) example = notification.example exception = notification.exception extra = Array(example.[:extra_failure_lines]) frames = Backtrace::Parser.parse(backtrace_for(exception), @config.classifier) Failure.new( **identity(example), exception_class: exception_class_name(exception), message: (notification, exception, extra), reduced: @config.reducer.call(frames), frames: frames, diagnostics: diagnostics(example, extra), shared_group_locations: shared_group_locations(example), raw: raw_output(notification, position) ) end |