Exception: RSpec::Core::MultipleExceptionError

Inherits:
StandardError
  • Object
show all
Defined in:
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.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (MultipleExceptionError) initialize(*exceptions)

Returns a new instance of MultipleExceptionError

Parameters:

  • exceptions (Array<Exception>)

    The initial list of exceptions.

457
458
459
460
461
462
463
464
465
466
467
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 457
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

- (nil) aggregation_block_label (readonly)

Returns Provided only for interface compatibility with RSpec::Expectations::MultipleExpectationsNotMetError.

Returns:

  • (nil)

    Provided only for interface compatibility with RSpec::Expectations::MultipleExpectationsNotMetError.

454
455
456
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 454
def aggregation_block_label
  @aggregation_block_label
end

- (Hash) aggregation_metadata (readonly)

Returns Metadata used by RSpec for formatting purposes.

Returns:

  • (Hash)

    Metadata used by RSpec for formatting purposes.

450
451
452
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 450
def 
  @aggregation_metadata
end

- (Array<Exception>) all_exceptions (readonly)

Returns The list of failures and other exceptions, combined.

Returns:

  • (Array<Exception>)

    The list of failures and other exceptions, combined.

447
448
449
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 447
def all_exceptions
  @all_exceptions
end

- (Array<Exception>) failures (readonly)

Returns The list of failures.

Returns:

  • (Array<Exception>)

    The list of failures.

441
442
443
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 441
def failures
  @failures
end

- (Array<Exception>) other_errors (readonly)

Returns The list of other errors.

Returns:

  • (Array<Exception>)

    The list of other errors.

444
445
446
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 444
def other_errors
  @other_errors
end

Instance Method Details

- (void) exception_count_description

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

482
483
484
485
486
487
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 482
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

- (String) message

Note:

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

Returns Combines all the exception messages into a single string.

Returns:

  • (String)

    Combines all the exception messages into a single string.

472
473
474
# File 'lib/rspec/core/formatters/exception_presenter.rb', line 472
def message
  all_exceptions.map(&:message).join("\n\n")
end

- (String) summary

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

Returns:

  • (String)

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

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