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

aggregation_block_label[R]

@return [nil] Provided only for interface compatibility with

`RSpec::Expectations::MultipleExpectationsNotMetError`.
aggregation_metadata[R]

@return [Hash] Metadata used by RSpec for formatting purposes.

all_exceptions[R]

@return [Array<Exception>] The list of failures and other exceptions, combined.

failures[R]

@return [Array<Exception>] The list of failures.

other_errors[R]

@return [Array<Exception>] The list of other errors.

Public Class Methods

new(*exceptions) click to toggle source

@param exceptions [Array<Exception>] The initial list of exceptions.

Calls superclass method
# File lib/rspec/core/formatters/exception_presenter.rb, line 492
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

exception_count_description() click to toggle source

return [String] A description of the failure/error counts.

# File lib/rspec/core/formatters/exception_presenter.rb, line 517
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() click to toggle source

@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 lib/rspec/core/formatters/exception_presenter.rb, line 507
def message
  all_exceptions.map(&:message).join("\n\n")
end
summary() click to toggle source

@return [String] A summary of the failure, including the block label and a count of failures.

# File lib/rspec/core/formatters/exception_presenter.rb, line 512
def summary
  "Got #{exception_count_description}"
end