Skip to content

Commit

Permalink
Add documentation for Spies in README
Browse files Browse the repository at this point in the history
* Add documentation and code example for Test Spies implemented in PR rspec#241
* Original PR rspec#241
  • Loading branch information
Adarsh Pandit committed May 27, 2013
1 parent 303bf06 commit 5e19fe9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Expand Up @@ -87,6 +87,26 @@ zipcode = Zipcode.new("02134", validator)
zipcode.valid?
```

## Test Spies

Verifies the given object received the expected message during the course of the
test. The method must have previously been stubbed in order for messages to be
verified.

Stubbing and verifying messages received in this way implements the Test Spy
pattern.

```ruby
invitation = double('invitation', accept: true)

user.accept_invitation(invitation)

expect(invitation).to have_received(:accept)

# You can also use most message expectations:
expect(invitation).to have_received(:accept).with(mailer).once
```

## Nomenclature

### Mock Objects and Test Stubs
Expand Down

0 comments on commit 5e19fe9

Please sign in to comment.