Sha256: f6f8e8be82d5c52f269ca701ee006b5973353f1448a31c5e3370fb6144cb013c
Contents?: true
Size: 837 Bytes
Versions: 2
Compression:
Stored size: 837 Bytes
Contents
module RuboCop module Cop module RSpec # 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) # class MessageChain < Cop include RuboCop::RSpec::SpecOnly MESSAGE = 'Avoid stubbing using `%<method>s`'.freeze MESSAGE_CHAIN_METHODS = [ :receive_message_chain, :stub_chain ].freeze 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 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-rspec-1.8.0 | lib/rubocop/cop/rspec/message_chain.rb |
rubocop-rspec-1.7.0 | lib/rubocop/cop/rspec/message_chain.rb |