class RuboCop::Cop::RSpec::ReturnFromStub::BlockBodyCorrector
Constants
- NULL_BLOCK_BODY
Attributes
block[R]
body[R]
node[R]
Public Class Methods
new(block)
click to toggle source
# 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
Public Instance Methods
call(corrector)
click to toggle source
# 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
Private Instance Methods
heredoc?()
click to toggle source
# File lib/rubocop/cop/rspec/return_from_stub.rb, line 160 def heredoc? body.loc.is_a?(Parser::Source::Map::Heredoc) end