class RuboCop::Cop::RSpec::VerifiedDoubleReference
Checks for consistent verified double reference style.
@see rspec.info/features/3-12/rspec-mocks/verifying-doubles
@safety
This cop is unsafe because the correction requires loading the class. Loading before stubbing causes RSpec to only allow instance methods to be stubbed.
@example
# bad let(:foo) do instance_double('ClassName', method_name: 'returned_value') end # good let(:foo) do instance_double(ClassName, method_name: 'returned_value') end
@example Reference is any dynamic variable. No enforcement
# good let(:foo) do instance_double(@klass, method_name: 'returned_value') end
Constants
- MSG
- RESTRICT_ON_SEND
Public Instance Methods
Source
# File lib/rubocop/cop/rspec/verified_double_reference.rb, line 66 def autocorrect(corrector, node) corrector.replace(node, node.value) end
Source
# File lib/rubocop/cop/rspec/verified_double_reference.rb, line 58 def on_send(node) verified_double(node) do |string_argument_node| add_offense(string_argument_node) do |corrector| autocorrect(corrector, string_argument_node) end end end