Module: RSpec::Core::MultipleExceptionError::InterfaceTag

Included in:
RSpec::Core::MultipleExceptionError
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/exception_presenter.rb

Overview

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.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for(ex) ⇒ Object

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



467
468
469
470
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/exception_presenter.rb', line 467

def self.for(ex)
  return ex if self === ex
  MultipleExceptionError.new(ex)
end

Instance Method Details

#add(exception) ⇒ Object

Appends the provided exception to the list.

Parameters:

  • exception (Exception)

    Exception to append to the list.



441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/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