Method: RSpec::Mocks::ExampleMethods#instance_spy
- Defined in:
- lib/rspec/mocks/example_methods.rb
#instance_spy(doubled_class) ⇒ Object #instance_spy(doubled_class, name) ⇒ Object #instance_spy(doubled_class, stubs) ⇒ Object #instance_spy(doubled_class, name, stubs) ⇒ Object
Constructs a test double that is optimized for use with have_received
against a specific class. If the given class name has been loaded, only
instance methods defined on the class are allowed to be stubbed. With
a normal double one has to stub methods in order to be able to spy
them. An instance_spy automatically spies on all instance methods to
which the class responds.
144 145 146 |
# File 'lib/rspec/mocks/example_methods.rb', line 144 def instance_spy(*args) instance_double(*args).as_null_object end |