Exception: RSpec::Core::MultipleExceptionError
- Inherits:
-
StandardError
- Object
- StandardError
- RSpec::Core::MultipleExceptionError
- Defined in:
- lib/rspec/core/formatters/exception_presenter.rb
Overview
Provides a single exception instance that provides access to
multiple sub-exceptions. This is used in situations where a single
individual spec has multiple exceptions, such as one in the it
block
and one in an after
block.
Instance Attribute Summary (collapse)
-
- (nil) aggregation_block_label
readonly
Provided only for interface compatibility with
RSpec::Expectations::MultipleExpectationsNotMetError
. -
- (Hash) aggregation_metadata
readonly
Metadata used by RSpec for formatting purposes.
-
- (Array<Exception>) all_exceptions
readonly
The list of failures and other exceptions, combined.
-
- (Array<Exception>) failures
readonly
The list of failures.
-
- (Array<Exception>) other_errors
readonly
The list of other errors.
Instance Method Summary (collapse)
-
- (void) exception_count_description
return [String] A description of the failure/error counts.
-
- (MultipleExceptionError) initialize(*exceptions)
constructor
A new instance of MultipleExceptionError.
-
- (String) message
Combines all the exception messages into a single string.
-
- (String) summary
A summary of the failure, including the block label and a count of failures.
Constructor Details
- (MultipleExceptionError) initialize(*exceptions)
Returns a new instance of MultipleExceptionError
356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 356 def initialize(*exceptions) super() @failures = [] @other_errors = [] @all_exceptions = [] @aggregation_metadata = { :hide_backtrace => true } @aggregation_block_label = nil exceptions.each { |e| add e } end |
Instance Attribute Details
- (nil) aggregation_block_label (readonly)
Returns Provided only for interface compatibility with
RSpec::Expectations::MultipleExpectationsNotMetError
.
353 354 355 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 353 def aggregation_block_label @aggregation_block_label end |
- (Hash) aggregation_metadata (readonly)
Returns Metadata used by RSpec for formatting purposes.
349 350 351 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 349 def @aggregation_metadata end |
- (Array<Exception>) all_exceptions (readonly)
Returns The list of failures and other exceptions, combined.
346 347 348 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 346 def all_exceptions @all_exceptions end |
- (Array<Exception>) failures (readonly)
Returns The list of failures.
340 341 342 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 340 def failures @failures end |
- (Array<Exception>) other_errors (readonly)
Returns The list of other errors.
343 344 345 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 343 def other_errors @other_errors end |
Instance Method Details
- (void) exception_count_description
return [String] A description of the failure/error counts.
381 382 383 384 385 386 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 381 def exception_count_description failure_count = Formatters::Helpers.pluralize(failures.size, "failure") return failure_count if other_errors.empty? error_count = Formatters::Helpers.pluralize(other_errors.size, "other error") "#{failure_count} and #{error_count}" end |
- (String) message
RSpec does not actually use this -- instead it formats each exception individually.
Returns Combines all the exception messages into a single string.
371 372 373 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 371 def all_exceptions.map(&:message).join("\n\n") end |
- (String) summary
Returns A summary of the failure, including the block label and a count of failures.
376 377 378 |
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 376 def summary "Got #{exception_count_description}" end |