lib/rubocop/cop/rspec/any_instance.rb in rubocop-rspec-1.6.0 vs lib/rubocop/cop/rspec/any_instance.rb in rubocop-rspec-1.7.0
- old
+ new
@@ -1,10 +1,12 @@
module RuboCop
module Cop
module RSpec
- # Pefer instance doubles over stubbing any instance of a class
+ # Check that instances are not being stubbed globally.
#
+ # Prefer instance doubles over stubbing any instance of a class
+ #
# @example
# # bad
# describe MyClass do
# before { allow_any_instance_of(MyClass).to receive(:foo) }
# end
@@ -17,9 +19,11 @@
# allow(MyClass).to receive(:new).and_return(my_instance)
# allow(my_instance).to receive(:foo)
# end
# end
class AnyInstance < Cop
+ include RuboCop::RSpec::SpecOnly
+
MESSAGE = 'Avoid stubbing using `%{method}`'.freeze
ANY_INSTANCE_METHODS = [
:any_instance,
:allow_any_instance_of,