Top Level Namespace
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Classes:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
Instance Method Summary
-
#as_null_object
Tells the object to respond to all messages.
-
#null_object?
Returns true if this object has received ‘as_null_object`.
-
#should_not_receive
Sets and expectation that this object should not receive a message during this example.
-
#should_receive
Sets an expectation that this object should receive a message before the end of the example.
-
#stub
Tells the object to respond to the message with the specified value.
-
#stub_chain(method1, method2)
Stubs a chain of methods.
-
#unstub
Removes a stub.
Instance Method Details
#as_null_object
This is only available when you have enabled the ‘should` syntax.
Tells the object to respond to all messages. If specific stub values are declared, they’ll work as expected. If not, the receiver is returned.
#null_object?
This is only available when you have enabled the ‘should` syntax.
Returns true if this object has received ‘as_null_object`
#should_not_receive
Sets and expectation that this object should not receive a message during this example.
#should_receive
This is only available when you have enabled the ‘should` syntax.
Sets an expectation that this object should receive a message before the end of the example.
#stub
This is only available when you have enabled the ‘should` syntax.
Tells the object to respond to the message with the specified value.
#stub_chain(method1, method2)
#stub_chain("method1.method2")
#stub_chain(method1, method_to_value_hash)
This is only available when you have enabled the ‘should` syntax.
Stubs a chain of methods.
## Warning:
Chains can be arbitrarily long, which makes it quite painless to violate the Law of Demeter in violent ways, so you should consider any use of ‘stub_chain` a code smell. Even though not all code smells indicate real problems (think fluent interfaces), stub_chain
still results in brittle examples. For example, if you write `foo.stub_chain(:bar, :baz
=> 37)` in a spec and then the implementation calls foo.baz.bar
, the stub will not work.
#unstub
This is only available when you have enabled the ‘should` syntax.
Removes a stub. On a double, the object will no longer respond to ‘message`. On a real object, the original method (if it exists) is restored.
This is rarely used, but can be useful when a stub is set up during a shared ‘before` hook for the common case, but you want to replace it for a special case.