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: thing)

Constants

MSG

Public Instance Methods

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