class RuboCop::Cop::RSpec::MessageChain

Check that chains of messages are not being stubbed.

@example

# bad
allow(foo).to receive_message_chain(:bar, :baz).and_return(42)

# better
thing = Thing.new(baz: 42)
allow(foo).to receive(:bar).and_return(thing)

Constants

MSG
RESTRICT_ON_SEND

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/rspec/message_chain.rb, line 20
def on_send(node)
  add_offense(
    node.loc.selector, message: format(MSG, method: node.method_name)
  )
end