Class: RuboCop::Cop::RSpec::Yield
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/rspec/yield.rb
Overview
This cop checks for calling a block within a stub.
Constant Summary collapse
- MSG =
'Use `.and_yield`.'
Instance Method Summary collapse
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language::NodePattern
Instance Method Details
#on_block(node) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rubocop/cop/rspec/yield.rb', line 26 def on_block(node) return unless method_on_stub?(node.send_node) block_arg(node.arguments) do |block| if calling_block?(node.body, block) range = block_range(node) add_offense(range) do |corrector| autocorrect(corrector, node, range) end end end end |