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

Inherits:
Cop
  • Object
show all
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 inherited from Cop

Cop::DEFAULT_CONFIGURATION

Constants included from RSpec::Language

RSpec::Language::ALL

Instance Method Summary collapse

Methods inherited from Cop

inherited, #relevant_file?

Instance Method Details

#on_send(node) ⇒ Object



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

def on_send(node)
  unverified_double(node) do |name|
    return if name.sym_type? && cop_config['IgnoreSymbolicNames']

    add_offense(node, :expression)
  end
end