Class: RSpec::Expectations::FailureAggregator

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/expectations/failure_aggregator.rb

Defined Under Namespace

Classes: AggregatedFailure

Constant Summary collapse

AGGREGATED_FAILURE =
AggregatedFailure.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#block_labelObject (readonly)

Returns the value of attribute block_label.



5
6
7
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/expectations/failure_aggregator.rb', line 5

def block_label
  @block_label
end

#metadataObject (readonly)

Returns the value of attribute metadata.



5
6
7
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/expectations/failure_aggregator.rb', line 5

def 
  @metadata
end

Instance Method Details

#aggregateObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/expectations/failure_aggregator.rb', line 22

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 Support::AllExceptionsExceptOnesWeMustNotRescue => 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) ⇒ Object

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



59
60
61
62
63
64
65
66
67
68
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/expectations/failure_aggregator.rb', line 59

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

  AGGREGATED_FAILURE
end

#failuresObject



49
50
51
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/expectations/failure_aggregator.rb', line 49

def failures
  @failures ||= []
end

#other_errorsObject



53
54
55
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.2/lib/rspec/expectations/failure_aggregator.rb', line 53

def other_errors
  @other_errors ||= []
end