Class: RuboCop::Cop::RSpec::MessageChain
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::RSpec::MessageChain
- Includes:
- RSpec::SpecOnly
- Defined in:
- lib/rubocop/cop/rspec/message_chain.rb
Overview
Check that chains of messages are not being stubbed.
Constant Summary collapse
- MESSAGE =
'Avoid stubbing using `%<method>s`'.freeze
- MESSAGE_CHAIN_METHODS =
[ :receive_message_chain, :stub_chain ].freeze
Constants included from RSpec::SpecOnly
RSpec::SpecOnly::DEFAULT_CONFIGURATION
Instance Method Summary collapse
Methods included from RSpec::SpecOnly
Instance Method Details
#on_send(node) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/rubocop/cop/rspec/message_chain.rb', line 24 def on_send(node) _receiver, method_name, *_args = *node return unless MESSAGE_CHAIN_METHODS.include?(method_name) add_offense(node, :selector, MESSAGE % { method: method_name }) end |