class RSpec::Core::MultipleExceptionError
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.
Attributes
@return [nil] Provided only for interface compatibility with
`RSpec::Expectations::MultipleExpectationsNotMetError`.
@return [Array<Exception>] The list of failures and other exceptions, combined.
@return [Array<Exception>] The list of failures.
@return [Array<Exception>] The list of other errors.
Public Class Methods
@param exceptions [Array<Exception>] The initial list of exceptions.
# File rspec-core/lib/rspec/core/formatters/exception_presenter.rb, line 519 def initialize(*exceptions) super() @failures = [] @other_errors = [] @all_exceptions = [] @aggregation_metadata = { :hide_backtrace => true } @aggregation_block_label = nil exceptions.each { |e| add e } end
Public Instance Methods
return [String] A description of the failure/error counts.
# File rspec-core/lib/rspec/core/formatters/exception_presenter.rb, line 544 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
@return [String] Combines all the exception messages into a single 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 534 def message all_exceptions.map(&:message).join("\n\n") end
@return [String] A summary of the failure, including the block label and a count of failures.
# File rspec-core/lib/rspec/core/formatters/exception_presenter.rb, line 539 def summary "Got #{exception_count_description}" end