Skip to content

Commit

Permalink
Fix readme for .expect(fn), fixes #253 (#262)
Browse files Browse the repository at this point in the history
Clarifies the current behavior of custom assertion functions.
  • Loading branch information
brigand authored and mikelax committed Apr 13, 2016
1 parent 480b9bb commit 25665c0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,7 @@ describe('request.agent(app)', function(){

### .expect(function(res) {})

Pass a custom assertion function. It'll be given the response object to check. If the response is ok, it should return falsy, most commonly by not returning anything. If the check fails, throw an error or return a truthy value like a string that'll be turned into an error.

Here the string or error throwing options are both demonstrated:
Pass a custom assertion function. It'll be given the response object to check. If the check fails, throw an error.

```js
request(app)
Expand All @@ -205,7 +203,7 @@ describe('request.agent(app)', function(){
.end(done);

function hasPreviousAndNextKeys(res) {
if (!('next' in res.body)) return "missing next key";
if (!('next' in res.body)) throw new Error("missing next key");
if (!('prev' in res.body)) throw new Error("missing prev key");
}
```
Expand Down

0 comments on commit 25665c0

Please sign in to comment.