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 fad3387 + b097f52 commit 36b5c77Copy full SHA for 36b5c77
lib/rubocop/cop/rspec/return_from_stub.rb
@@ -40,20 +40,21 @@ 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
47
48
def on_send(node)
- return unless contains_stub?(node)
49
return unless style == :block
50
+ return unless contains_stub?(node)
51
52
check_and_return_call(node)
53
end
54
55
def on_block(node)
56
return unless style == :and_return
57
+ return unless stub_with_block?(node)
58
59
check_block_body(node)
60
0 commit comments