Spectator::Mocked
Inherits Spectator::Stubbable
Mix-in used for mocked types.
Bridges functionality between mocks and stubs
Implements the abstracts methods from Stubbable.
Types including this module will need to implement #_spectator_stubs.
It should return a mutable list of stubs.
This is used to store the stubs for the mocked type.
Additionally, the #_spectator_calls (getter with no arguments) must be implemented.
It should return a mutable list of method calls.
This is used to store the calls to stubs for the mocked type.
Instance methods
Method called when a stub isn't found.
This is similar to #_spectator_stub_fallback,
but called when the original (un-stubbed) method isn't available.
The received message is captured in call.
The expected return type is provided by type.
The stubbed method returns the value returned by this method.
This method can also raise an error if it's impossible to return something.
Method called when a stub isn't found.
This is similar to #_spectator_stub_fallback,
but called when the original (un-stubbed) method isn't available.
The received message is captured in call.
The stubbed method returns the value returned by this method.
This method can also raise an error if it's impossible to return something.
Defines a stub to change the behavior of a method.
Saves a call that was made to a stubbed method.
Method called when a stub isn't found.
The received message is captured in call. The expected return type is provided by type. Yield to call the original method's implementation. The stubbed method returns the value returned by this method. This method can also raise an error if it's impossible to return something.
Method called when a stub isn't found.
The received message is captured in call. Yield to call the original method's implementation. The stubbed method returns the value returned by this method. This method can also raise an error if it's impossible to return something.
Utility method that looks for stubs for methods with the name specified.