Class: RuboCop::Cop::RSpec::VerifiedDoubles

Inherits:
RuboCop::Cop show all
Defined in:
lib/rubocop/cop/rspec/verified_doubles.rb

Overview

Prefer using verifying doubles over normal doubles. see: relishapp.com/rspec/rspec-mocks/docs/verifying-doubles

Examples:

# bad
it '...' do
  widget = double("Widget")
end

# good
it '...' do
  widget = instance_double("Widget")
end

Constant Summary collapse

MSG =
'Prefer using verifying doubles over normal doubles.'.freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



26
27
28
29
30
31
# File 'lib/rubocop/cop/rspec/verified_doubles.rb', line 26

def on_send(node)
  return unless (name = unverified_double(node))
  return if name.type.equal?(:sym) && cop_config['IgnoreSymbolicNames']

  add_offense(node, :expression)
end