Skip to content

Commit

Permalink
Add test for rescue with safe navigator setter on nil
Browse files Browse the repository at this point in the history
There was a test with the safe navigator setter, but only in the case
where the target is not nil.
  • Loading branch information
herwinw authored and eregon committed Jun 8, 2024
1 parent 517f06f commit a76a91c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions language/rescue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ class ArbitraryException < StandardError
RescueSpecs::SafeNavigationSetterCaptor.should_capture_exception
end

it 'using a safely navigated setter method on a nil target' do
target = nil
begin
raise SpecificExampleException, "Raising this to be handled below"
rescue SpecificExampleException => target&.captured_error
:caught
end.should == :caught
target.should be_nil
end

it 'using a setter method' do
RescueSpecs::SetterCaptor.should_capture_exception
end
Expand Down

0 comments on commit a76a91c

Please sign in to comment.