Class: RSpec::Expectations::FailureAggregator

### Home Classes Methods

### In Files

- lib/rspec/expectations/failure_aggregator.rb

### Parent

Object

### Methods

- ::new
- #aggregate
- #call
- #failures
- #other_errors

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Expectations
- RSpec::Expectations::BlockExpectationTarget
- RSpec::Expectations::Configuration
- RSpec::Expectations::ExpectationHelper
- RSpec::Expectations::ExpectationNotMetError
- RSpec::Expectations::ExpectationTarget
- RSpec::Expectations::FailureAggregator
- RSpec::Expectations::LegacyMacherAdapter
- RSpec::Expectations::LegacyMatcherAdapter
- RSpec::Expectations::LegacyMatcherAdapter::RSpec1
- RSpec::Expectations::LegacyMatcherAdapter::RSpec2
- RSpec::Expectations::MultipleExpectationsNotMetError
- RSpec::Expectations::NegativeExpectationHandler
- RSpec::Expectations::PositiveExpectationHandler
- RSpec::Expectations::Syntax
- RSpec::Expectations::Version
- RSpec::Matchers
- RSpec::Matchers::AliasedMatcher
- RSpec::Matchers::AliasedMatcherWithOperatorSupport
- RSpec::Matchers::AliasedNegatedMatcher
- RSpec::Matchers::BuiltIn
- RSpec::Matchers::BuiltIn::All
- RSpec::Matchers::BuiltIn::BaseMatcher
- RSpec::Matchers::BuiltIn::BaseMatcher::DefaultFailureMessages
- RSpec::Matchers::BuiltIn::BaseMatcher::HashFormatting
- RSpec::Matchers::BuiltIn::Be
- RSpec::Matchers::BuiltIn::BeAKindOf
- RSpec::Matchers::BuiltIn::BeAnInstanceOf
- RSpec::Matchers::BuiltIn::BeBetween
- RSpec::Matchers::BuiltIn::BeComparedTo
- RSpec::Matchers::BuiltIn::BeFalsey
- RSpec::Matchers::BuiltIn::BeHelpers
- RSpec::Matchers::BuiltIn::BeNil
- RSpec::Matchers::BuiltIn::BePredicate
- RSpec::Matchers::BuiltIn::BeTruthy
- RSpec::Matchers::BuiltIn::BeWithin
- RSpec::Matchers::BuiltIn::CaptureStderr
- RSpec::Matchers::BuiltIn::CaptureStdout
- RSpec::Matchers::BuiltIn::CaptureStreamToTempfile
- RSpec::Matchers::BuiltIn::Change
- RSpec::Matchers::BuiltIn::ChangeDetails
- RSpec::Matchers::BuiltIn::ChangeFromValue
- RSpec::Matchers::BuiltIn::ChangeRelatively
- RSpec::Matchers::BuiltIn::ChangeToValue
- RSpec::Matchers::BuiltIn::Compound
- RSpec::Matchers::BuiltIn::Compound::And
- RSpec::Matchers::BuiltIn::Compound::NestedEvaluator
- RSpec::Matchers::BuiltIn::Compound::Or
- RSpec::Matchers::BuiltIn::Compound::SequentialEvaluator
- RSpec::Matchers::BuiltIn::ContainExactly
- RSpec::Matchers::BuiltIn::ContainExactly::PairingsMaximizer
- RSpec::Matchers::BuiltIn::Cover
- RSpec::Matchers::BuiltIn::EndWith
- RSpec::Matchers::BuiltIn::Eq
- RSpec::Matchers::BuiltIn::Eql
- RSpec::Matchers::BuiltIn::Equal
- RSpec::Matchers::BuiltIn::Exist
- RSpec::Matchers::BuiltIn::Exist::ExistenceTest
- RSpec::Matchers::BuiltIn::Has
- RSpec::Matchers::BuiltIn::HaveAttributes
- RSpec::Matchers::BuiltIn::Include
- RSpec::Matchers::BuiltIn::Match
- RSpec::Matchers::BuiltIn::NegativeOperatorMatcher
- RSpec::Matchers::BuiltIn::NullCapture
- RSpec::Matchers::BuiltIn::OperatorMatcher
- RSpec::Matchers::BuiltIn::Output
- RSpec::Matchers::BuiltIn::PositiveOperatorMatcher
- RSpec::Matchers::BuiltIn::RaiseError
- RSpec::Matchers::BuiltIn::RespondTo
- RSpec::Matchers::BuiltIn::Satisfy
- RSpec::Matchers::BuiltIn::SpecificValuesChange
- RSpec::Matchers::BuiltIn::StartAndEndWith
- RSpec::Matchers::BuiltIn::StartOrEndWith
- RSpec::Matchers::BuiltIn::StartWith
- RSpec::Matchers::BuiltIn::ThrowSymbol
- RSpec::Matchers::BuiltIn::YieldControl
- RSpec::Matchers::BuiltIn::YieldProbe
- RSpec::Matchers::BuiltIn::YieldSuccessiveArgs
- RSpec::Matchers::BuiltIn::YieldWithArgs
- RSpec::Matchers::BuiltIn::YieldWithNoArgs
- RSpec::Matchers::Composable
- RSpec::Matchers::DSL
- RSpec::Matchers::DSL::DefaultImplementations
- RSpec::Matchers::DSL::Macros
- RSpec::Matchers::DSL::Macros::Deprecated
- RSpec::Matchers::DSL::Matcher
- RSpec::Matchers::EnglishPhrasing
- RSpec::Matchers::ExpectedsForMultipleDiffs
- RSpec::Matchers::FailMatchers
- RSpec::Matchers::MatcherDelegator
- RSpec::Matchers::MatcherProtocol
- BasicObject
- Object

No matching classes.

# RSpec::Expectations::FailureAggregator

@private

### Attributes

block_label[R]
metadata[R]

### Public Class Methods

new(block_label, metadata) click to toggle source

    # File lib/rspec/expectations/failure_aggregator.rb, line 73
    def initialize(block_label, metadata)
      @block_label     = block_label
      @metadata        = metadata
      @seen_source_ids = {} # don't want to load stdlib set
    end

### Public Instance Methods

aggregate() click to toggle source

    # File lib/rspec/expectations/failure_aggregator.rb, line 7
    def aggregate
      RSpec::Support.with_failure_notifier(self) do
        begin
          yield
        rescue ExpectationNotMetError => e
          # Normally, expectation failures will be notified via the `call` method, below,
          # but since the failure notifier uses a thread local variable, failing expectations
          # in another thread will still raise. We handle that here and categorize it as part
          # of `failures` rather than letting it fall through and be categorized as part of
          # `other_errors`.
          failures << e
        rescue Exception => e
          # While it is normally a bad practice to rescue `Exception`, it's important we do
          # so here. It's low risk (`notify_aggregated_failures` below will re-raise the exception,
          # or raise a `MultipleExpectationsNotMetError` that includes the exception), and it's
          # essential that the user is notified of expectation failures that may have already
          # occurred in the `aggregate_failures` block. Those expectation failures may provide
          # important diagnostics for understanding why this exception occurred, and if we simply
          # allowed this exception to be raised as-is, it would (wrongly) suggest to the user
          # that the expectation passed when it did not, which would be quite confusing.
          other_errors << e
        end
      end

      notify_aggregated_failures
    end

call(failure, options) click to toggle source

This method is defined to satisfy the callable interface expected by `RSpec::Support.with_failure_notifier`.

    # File lib/rspec/expectations/failure_aggregator.rb, line 44
    def call(failure, options)
      source_id = options[:source_id]
      return if source_id && @seen_source_ids.key?(source_id)

      @seen_source_ids[source_id] = true
      assign_backtrace(failure) unless failure.backtrace
      failures << failure
    end

failures() click to toggle source

    # File lib/rspec/expectations/failure_aggregator.rb, line 34
    def failures
      @failures ||= []
    end

other_errors() click to toggle source

    # File lib/rspec/expectations/failure_aggregator.rb, line 38
    def other_errors
      @other_errors ||= []
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.