Sha256: 66494aa46ee6307dba7aede39c2a478b4c37d006614532c1616ce4e9a0d7ceb1

Contents?: true

Size: 814 Bytes

Versions: 4

Compression:

Stored size: 814 Bytes

Contents

# encoding: utf-8

module RuboCop
  module Cop
    module RSpec
      # Prefer using verifying doubles over normal doubles.
      # see: https://relishapp.com/rspec/rspec-mocks/docs/verifying-doubles
      #
      # @example
      #   # bad
      #   it '...' do
      #     widget = double("Widget")
      #   end
      #
      #   # good
      #   it '...' do
      #     widget = instance_double("Widget")
      #   end
      class VerifiedDoubles < Cop
        MSG = 'Prefer using verifying doubles over normal doubles.'

        def on_send(node)
          _receiver, method_name, *_args = *node
          return unless method_name == :double
          add_offense(node,
                      :expression,
                      format(MSG, node.loc.expression.source))
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-rspec-1.3.1 lib/rubocop/cop/rspec/verified_doubles.rb
rubocop-rspec-1.3.0 lib/rubocop/cop/rspec/verified_doubles.rb
rubocop-rspec-1.2.2 lib/rubocop/cop/rspec/verified_doubles.rb
rubocop-rspec-1.2.1 lib/rubocop/cop/rspec/verified_doubles.rb