123456789_123456789_123456789_123456789_123456789_

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
  • Object
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

Instance Attribute Summary

Instance Method Summary

InterfaceTag - Included

#add

Appends the provided exception to the list.

Constructor Details

.new(*exceptions) ⇒ MultipleExceptionError

Parameters:

  • exceptions (Array<Exception>)

    The initial list of exceptions.

[ GitHub ]

  
# 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_labelnil (readonly)

Returns:

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 521

attr_reader :aggregation_block_label

#aggregation_metadataHash (readonly)

Returns:

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 517

attr_reader :

#all_exceptionsArray<Exception> (readonly)

Returns:

  • (Array<Exception>)

    The list of failures and other exceptions, combined.

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 514

attr_reader :all_exceptions

#failuresArray<Exception> (readonly)

Returns:

  • (Array<Exception>)

    The list of failures.

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 508

attr_reader :failures

#other_errorsArray<Exception> (readonly)

Returns:

  • (Array<Exception>)

    The list of other errors.

[ GitHub ]

  
# 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.

[ GitHub ]

  
# 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

#messageString

Note:

::RSpec does not actually use this – instead it formats each exception individually.

Returns:

  • (String)

    Combines all the exception messages into a single string.

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 539

def message
  all_exceptions.map(&:message).join("\n\n")
end

#summaryString

Returns:

  • (String)

    A summary of the failure, including the block label and a count of failures.

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/formatters/exception_presenter.rb', line 544

def summary
  "Got #{exception_count_description}"
end