lib/rubocop/cop/rspec/any_instance.rb in rubocop-rspec-2.1.0 vs lib/rubocop/cop/rspec/any_instance.rb in rubocop-rspec-2.2.0
- old
+ new
@@ -22,21 +22,17 @@
# allow(my_instance).to receive(:foo)
# end
# end
class AnyInstance < Base
MSG = 'Avoid stubbing using `%<method>s`.'
+ RESTRICT_ON_SEND = %i[
+ any_instance
+ allow_any_instance_of
+ expect_any_instance_of
+ ].freeze
- def_node_matcher :disallowed_stub, <<-PATTERN
- (send _ ${:any_instance :allow_any_instance_of :expect_any_instance_of} ...)
- PATTERN
-
def on_send(node)
- disallowed_stub(node) do |method|
- add_offense(
- node,
- message: format(MSG, method: method)
- )
- end
+ add_offense(node, message: format(MSG, method: node.method_name))
end
end
end
end
end