Class: RuboCop::Cop::RSpec::ReturnFromStub::BlockBodyCorrector
- Inherits:
-
Object
- Object
- RuboCop::Cop::RSpec::ReturnFromStub::BlockBodyCorrector
- Defined in:
- lib/rubocop/cop/rspec/return_from_stub.rb
Overview
:nodoc:
Instance Method Summary collapse
- #call(corrector) ⇒ Object
-
#initialize(block) ⇒ BlockBodyCorrector
constructor
A new instance of BlockBodyCorrector.
Constructor Details
#initialize(block) ⇒ BlockBodyCorrector
Returns a new instance of BlockBodyCorrector.
140 141 142 143 144 |
# File 'lib/rubocop/cop/rspec/return_from_stub.rb', line 140 def initialize(block) @block = block @node = block.parent @body = block.body || NULL_BLOCK_BODY end |
Instance Method Details
#call(corrector) ⇒ Object
146 147 148 149 150 151 152 153 154 |
# File 'lib/rubocop/cop/rspec/return_from_stub.rb', line 146 def call(corrector) # Heredoc autocorrection is not yet implemented. return if heredoc? corrector.replace( block, "#{block.send_node.source}.and_return(#{body.source})" ) end |