Skip to content

Commit

Permalink
Cover ancestor.send_type? branch in UnspecifiedException
Browse files Browse the repository at this point in the history
Wraps a non-send type conditional branch around `raise_error` spec
  • Loading branch information
corsonknowles committed Oct 31, 2024
1 parent e80d28c commit 4faeb39
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions spec/rubocop/cop/rspec/unspecified_exception_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,10 @@ def raise_error
RUBY
end

it 'allows a subject function to be named raise_error' do
expect_no_offenses(<<~RUBY)
def raise_error
raise StandardError
end
expect {
raise_error
}.to raise_exception(StandardError)
it 'detects even when a non-send node is an ancestor' do
expect_offense(<<~RUBY)
expect { raise 'error' }.to (branch_conditional ? raise_error : handle_exception)
^^^^^^^^^^^ Specify the exception being captured
RUBY
end
end
Expand Down

0 comments on commit 4faeb39

Please sign in to comment.