Exception: RSpec::Expectations::MultipleExpectationsNotMetError

Inherits:
ExpectationNotMetError show all
Defined in:
lib/rspec/expectations.rb,
lib/rspec/expectations/failure_aggregator.rb

Overview

Exception raised from aggregate_failures when multiple expectations fail.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Array<Exception>) all_exceptions (readonly)

Returns The list of expectation failures and other exceptions, combined.

Returns:

  • (Array<Exception>)

    The list of expectation failures and other exceptions, combined.

108
109
110
# File 'lib/rspec/expectations/failure_aggregator.rb', line 108
def all_exceptions
  @all_exceptions
end

Instance Method Details

- (String) aggregation_block_label

Returns The user-assigned label for the aggregation block.

Returns:

  • (String)

    The user-assigned label for the aggregation block.

111
112
113
# File 'lib/rspec/expectations/failure_aggregator.rb', line 111
def aggregation_block_label
  @failure_aggregator.block_label
end

- (Hash) aggregation_metadata

Returns The metadata hash passed to aggregate_failures.

Returns:

  • (Hash)

    The metadata hash passed to aggregate_failures.

116
117
118
# File 'lib/rspec/expectations/failure_aggregator.rb', line 116
def 
  @failure_aggregator.
end

- (Object) exception_count_description

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

127
128
129
130
131
132
# File 'lib/rspec/expectations/failure_aggregator.rb', line 127
def exception_count_description
  failure_count = pluralize("failure", failures.size)
  return failure_count if other_errors.empty?
  error_count = pluralize("other error", other_errors.size)
  "#{failure_count} and #{error_count}"
end

- (Array<RSpec::Expectations::ExpectationNotMetError>) failures

Returns The list of expectation failures.

Returns:

98
99
100
# File 'lib/rspec/expectations/failure_aggregator.rb', line 98
def failures
  @failure_aggregator.failures
end

- (String) message

Returns The fully formatted exception message.

Returns:

  • (String)

    The fully formatted exception message.

93
94
95
# File 'lib/rspec/expectations/failure_aggregator.rb', line 93
def message
  @message ||= (["#{summary}:"] + enumerated_failures + enumerated_errors).join("\n\n")
end

- (Array<Exception>) other_errors

Returns The list of other exceptions.

Returns:

  • (Array<Exception>)

    The list of other exceptions.

103
104
105
# File 'lib/rspec/expectations/failure_aggregator.rb', line 103
def other_errors
  @failure_aggregator.other_errors
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.

121
122
123
124
# File 'lib/rspec/expectations/failure_aggregator.rb', line 121
def summary
  "Got #{exception_count_description} from failure aggregation " \
  "block#{block_description}"
end