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.
1 parent 8423de4 commit b097f52Copy full SHA for b097f52
lib/rubocop/cop/rspec/return_from_stub.rb
@@ -40,6 +40,7 @@ class ReturnFromStub < Cop
40
MSG_BLOCK = 'Use block for static values.'
41
42
def_node_search :contains_stub?, '(send nil? :receive (...))'
43
+ def_node_matcher :stub_with_block?, '(block #contains_stub? ...)'
44
def_node_search :and_return_value, <<-PATTERN
45
$(send _ :and_return $(...))
46
PATTERN
@@ -53,7 +54,7 @@ def on_send(node)
53
54
55
def on_block(node)
56
return unless style == :and_return
- return unless contains_stub?(node)
57
+ return unless stub_with_block?(node)
58
59
check_block_body(node)
60
end
0 commit comments