heroku/geronte — pull request #2 by mrappleton (2014-10-31 16:21:07+00:00)
Title: Expectations

Adds functionality to make expectations against stubbed requests. For example:

```js
server.expect('PUT', '/foo');
// stuff that doesn't POST to /foo
server.done();
Error: Expected POST /foo to have been requested.
```

Also allows for expectations on request headers, body and form data:

```js
geronte.expect('PUT', '/bar').with({
headers: { 'Content-Type': 'application/json' },
body: '{"bar":"baz"}'
});
// stuff that doesn't PUT to /bar with the correct headers and body
server.done();
Error: Expected PUT /bar with headers: {"Content-Type": "application/json" } body: {"bar":"baz"} to have been requested.
```

`server.reset()` also calls `done` so all pending expectations are flushed.

Here's how we can use it in our tests:

```js
describe('saving an app', function() {
it('POSTs to /apps with some custom header', function() {
server.expect('POST', '/apps').with({
headers: { 'some-custom-header': 'true' },
data: { name: 'Appname' }
});

click('.apps .save');
});
});
```

@JackCA and @jclem what do you think?