class RuboCop::Cop::RSpec::MessageChain
allow(foo).to receive(bar: thing)
thing = Thing.new(baz: 42)
# better
allow(foo).to receive_message_chain(:bar, :baz).and_return(42)
# bad
@example
Check that chains of messages are not being stubbed.
def on_send(node)
def on_send(node) _receiver, method_name, *_args = *node return unless Matchers::MESSAGE_CHAIN.include?(method_name) add_offense(node, :selector, format(MESSAGE, method: method_name)) end