Class: RuboCop::Cop::RSpec::AnyInstance
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::RSpec::AnyInstance
- Defined in:
- lib/rubocop/cop/rspec/any_instance.rb
Overview
Pefer instance doubles over stubbing any instance of a class
Constant Summary collapse
- MESSAGE =
'Avoid stubbing using `%{method}`'.freeze
- ANY_INSTANCE_METHODS =
[ :any_instance, :allow_any_instance_of, :expect_any_instance_of ].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rubocop/cop/rspec/any_instance.rb', line 32 def on_send(node) _receiver, method_name, *_args = *node return unless ANY_INSTANCE_METHODS.include?(method_name) add_offense( node, :expression, format( MESSAGE % { method: method_name }, node.loc.expression.source ) ) end |