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

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

Overview

Prefer using verifying doubles over normal doubles.

Examples:

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

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

See Also:

Constant Summary collapse

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

Constants included from RSpec::SpecOnly

RSpec::SpecOnly::DEFAULT_CONFIGURATION

Instance Method Summary collapse

Methods included from RSpec::SpecOnly

#relevant_file?

Instance Method Details

#on_send(node) ⇒ Object



29
30
31
32
33
34
# File 'lib/rubocop/cop/rspec/verified_doubles.rb', line 29

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

  add_offense(node, :expression)
end