Class: RuboCop::Cop::RSpec::ReturnFromStub
- Includes:
- ConfigurableEnforcedStyle
- Defined in:
- lib/rubocop/cop/rspec/return_from_stub.rb
Overview
Checks for consistent style of stub’s return setting.
Enforces either ‘and_return` or block-style return in the cases where the returned value is constant. Ignores dynamic returned values are the result would be different
This cop can be configured using the ‘EnforcedStyle` option
Constant Summary collapse
- MSG_AND_RETURN =
'Use `and_return` for static values.'.freeze
- MSG_BLOCK =
'Use block for static values.'.freeze
Constants inherited from Cop
Constants included from RSpec::Language
Instance Method Summary collapse
Methods inherited from Cop
Instance Method Details
#on_send(node) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/rubocop/cop/rspec/return_from_stub.rb', line 48 def on_send(node) if style == :block check_and_return_call(node) elsif node.method_name == :receive check_block_body(node) end end |