Exception: RSpec::Core::MultipleExceptionError
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
StandardError
|
|
Instance Chain:
self,
InterfaceTag ,
StandardError
|
|
Inherits: |
StandardError
|
Defined in: | rspec-core/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.
Class Method Summary
- .new(*exceptions) ⇒ MultipleExceptionError constructor
Instance Attribute Summary
- #aggregation_block_label ⇒ nil readonly
- #aggregation_metadata ⇒ Hash readonly
- #all_exceptions ⇒ Array<Exception> readonly
- #failures ⇒ Array<Exception> readonly
- #other_errors ⇒ Array<Exception> readonly
Instance Method Summary
-
#exception_count_description
return [String] A description of the failure/error counts.
- #message ⇒ String
- #summary ⇒ String
InterfaceTag
- Included
#add | Appends the provided exception to the list. |
Constructor Details
.new(*exceptions) ⇒ MultipleExceptionError
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 524
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
#aggregation_block_label ⇒ nil
(readonly)
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 521
attr_reader :aggregation_block_label
#aggregation_metadata ⇒ Hash
(readonly)
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 517
attr_reader :
#all_exceptions ⇒ Array
<Exception
> (readonly)
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 514
attr_reader :all_exceptions
#failures ⇒ Array
<Exception
> (readonly)
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 508
attr_reader :failures
#other_errors ⇒ Array
<Exception
> (readonly)
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 511
attr_reader :other_errors
Instance Method Details
#exception_count_description
return [String] A description of the failure/error counts.
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 549
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
#message ⇒ String
Note:
::RSpec
does not actually use this – instead it formats each exception individually.
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 539
def all_exceptions.map(&: ).join("\n\n") end
#summary ⇒ String
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 544
def summary "Got #{exception_count_description}" end