Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 02d759c

Browse files
author
Sam Phippen
committed
Merge pull request #2133 from rspec/samphippen/fix-multiple-exception-error-infinite-recursion
Prevent `MultipleExceptionError#add` from allowing self to be added to the list of `all_exceptions`
2 parents a9f8475 + da560d7 commit 02d759c

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/rspec/core/formatters/exception_presenter.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ def add(exception)
408408
# ignore it.
409409
return if Pending::PendingExampleFixedError === exception
410410

411+
return if exception == self
412+
411413
all_exceptions << exception
412414

413415
if exception.class.name =~ /RSpec/

spec/rspec/core/formatters/exception_presenter_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,12 @@ def new_multiple_exception_error
695695
end
696696
end
697697

698+
it "does not let you add itself to the list of all_exceptions" do
699+
m = MultipleExceptionError.new
700+
m.add(m)
701+
expect(m.all_exceptions).to_not include(m)
702+
end
703+
698704
it 'supports the same interface as `RSpec::Expectations::MultipleExpectationsNotMetError`' do
699705
skip "Skipping to allow an rspec-expectations PR to add a new method and remain green" if ENV['NEW_MUTLI_EXCEPTION_METHOD']
700706

0 commit comments

Comments
 (0)