module RSpec::Core::MultipleExceptionError::InterfaceTag

@private Used so there is a common module in the ancestor chain of this class and ‘RSpec::Expectations::MultipleExpectationsNotMetError`, which allows code to detect exceptions that are instances of either, without first checking to see if rspec-expectations is loaded.

Public Class Methods

for(ex) click to toggle source

Provides a way to force ‘ex` to be something that satisfies the multiple exception error interface. If it already satisfies it, it will be returned; otherwise it will wrap it in a `MultipleExceptionError`. @private

# File lib/rspec/core/formatters/exception_presenter.rb, line 467
def self.for(ex)
  return ex if self === ex
  MultipleExceptionError.new(ex)
end

Public Instance Methods

add(exception) click to toggle source

Appends the provided exception to the list. @param exception [Exception] Exception to append to the list. @private

# File lib/rspec/core/formatters/exception_presenter.rb, line 441
def add(exception)
  # `PendingExampleFixedError` can be assigned to an example that initially has no
  # failures, but when the `aggregate_failures` around hook completes, it notifies of
  # a failure. If we do not ignore `PendingExampleFixedError` it would be surfaced to
  # the user as part of a multiple exception error, which is undesirable. While it's
  # pretty weird we handle this here, it's the best solution I've been able to come
  # up with, and `PendingExampleFixedError` always represents the _lack_ of any exception
  # so clearly when we are transitioning to a `MultipleExceptionError`, it makes sense to
  # ignore it.
  return if Pending::PendingExampleFixedError === exception

  return if exception == self

  all_exceptions << exception

  if exception.class.name =~ /RSpec/
    failures << exception
  else
    other_errors << exception
  end
end