Sha256: 322cd34ce81d474aacf22ac6186da6b8b5798ea3eb4d8e9f4e29c1c733122111

Contents?: true

Size: 713 Bytes

Versions: 17

Compression:

Stored size: 713 Bytes

Contents

# frozen_string_literal: true

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).and_return(thing)
      #
      class MessageChain < Base
        MSG = 'Avoid stubbing using `%<method>s`.'
        RESTRICT_ON_SEND = %i[receive_message_chain stub_chain].freeze

        def on_send(node)
          add_offense(
            node.loc.selector, message: format(MSG, method: node.method_name)
          )
        end
      end
    end
  end
end

Version data entries

17 entries across 15 versions & 2 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-rspec-2.12.1/lib/rubocop/cop/rspec/message_chain.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-rspec-2.9.0/lib/rubocop/cop/rspec/message_chain.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-rspec-2.12.1/lib/rubocop/cop/rspec/message_chain.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-rspec-2.9.0/lib/rubocop/cop/rspec/message_chain.rb
rubocop-rspec-2.12.1 lib/rubocop/cop/rspec/message_chain.rb
rubocop-rspec-2.12.0 lib/rubocop/cop/rspec/message_chain.rb
rubocop-rspec-2.11.1 lib/rubocop/cop/rspec/message_chain.rb
rubocop-rspec-2.11.0 lib/rubocop/cop/rspec/message_chain.rb
rubocop-rspec-2.10.0 lib/rubocop/cop/rspec/message_chain.rb
rubocop-rspec-2.9.0 lib/rubocop/cop/rspec/message_chain.rb
rubocop-rspec-2.8.0 lib/rubocop/cop/rspec/message_chain.rb
rubocop-rspec-2.7.0 lib/rubocop/cop/rspec/message_chain.rb
rubocop-rspec-2.6.0 lib/rubocop/cop/rspec/message_chain.rb
rubocop-rspec-2.5.0 lib/rubocop/cop/rspec/message_chain.rb
rubocop-rspec-2.4.0 lib/rubocop/cop/rspec/message_chain.rb
rubocop-rspec-2.3.0 lib/rubocop/cop/rspec/message_chain.rb
rubocop-rspec-2.2.0 lib/rubocop/cop/rspec/message_chain.rb