We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 00b6c03 + 5d0fbfb commit f96f5c5Copy full SHA for f96f5c5
lib/rubocop/cop/rspec/unspecified_exception.rb
@@ -64,7 +64,6 @@ def empty_exception_matcher?(node)
64
def find_expect_to(node)
65
node.each_ancestor.find do |ancestor|
66
break if ancestor.block_type?
67
- next unless ancestor.send_type?
68
69
expect_to?(ancestor)
70
end
spec/rubocop/cop/rspec/unspecified_exception_spec.rb
@@ -254,5 +254,12 @@ def raise_error
254
}.to raise_exception(StandardError)
255
RUBY
256
257
+
258
+ it 'detects even when a non-send node is an ancestor' do
259
+ expect_offense(<<~RUBY)
260
+ expect { raise 'error' }.to (branch_conditional ? raise_error : handle_exception)
261
+ ^^^^^^^^^^^ Specify the exception being captured
262
+ RUBY
263
+ end
264
265
0 commit comments