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

Prevent MultipleExceptionError#add from allowing self to be added to the list of all_exceptions #2133

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/rspec/core/formatters/exception_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ def add(exception)
# ignore it.
return if Pending::PendingExampleFixedError === exception

return if exception == self

all_exceptions << exception

if exception.class.name =~ /RSpec/
Expand Down
6 changes: 6 additions & 0 deletions spec/rspec/core/formatters/exception_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,12 @@ def new_multiple_exception_error
end
end

it "does not let you add itself to the list of all_exceptions" do
m = MultipleExceptionError.new
m.add(m)
expect(m.all_exceptions).to_not include(m)
end

it 'supports the same interface as `RSpec::Expectations::MultipleExpectationsNotMetError`' do
skip "Skipping to allow an rspec-expectations PR to add a new method and remain green" if ENV['NEW_MUTLI_EXCEPTION_METHOD']

Expand Down