Permalink
Browse files

Make the fact that you can set message expectations on class objects

more obvious.

- Closes #125.

[ci skip]
  • Loading branch information...
1 parent f4f4ec3 commit 155cef321e570449769e0107454ff922793180aa @dchelimsky dchelimsky committed Apr 17, 2012
Showing with 13 additions and 6 deletions.
  1. +13 −6 README.md
View
@@ -116,12 +116,19 @@ Person.stub(:find) { person }
```
In this case we're instrumenting Person to return the person object we've
-defined whenever it receives the `find` message. We can do this with any
-object in a system because rspec-mocks adds the `stub` and `should_receive`
-methods to every object. When we use either, RSpec replaces the method
-we're stubbing or mocking with its own test-double-like method. At the
-end of the example, RSpec verifies any message expectations, and then
-restores the original methods.
+defined whenever it receives the `find` message. We can also set a message
+expectation so that the example fails if `find` is not called:
+
+```ruby
+person = double("person")
+Person.should_receive(:find) { person }
+```
+
+We can do this with any object in a system because rspec-mocks adds the `stub`
+and `should_receive` methods to every object, including class objects. When we
+use either, RSpec replaces the method we're stubbing or mocking with its own
+test-double-like method. At the end of the example, RSpec verifies any message
+expectations, and then restores the original methods.
## Expecting Arguments

0 comments on commit 155cef3

Please sign in to comment.