seanmonstar/Shipyard — Issue #3: Mock Requests
Author: seanmonstar
Created: 2011-10-17 19:10:46+00:00
State: open

Since we'd like to be able to test our JS apps without relying on the server, and most apps will make XHR calls to a server using the Server Sync, we should make it really easy to mock those requests in tests.

Testigo (the test runner included in Shipyard) already has powerful Spys, and the `http.Request` class exposes an easy way to override the XHR object with `Request.setXHR()`.

Ideally, a test would look something like so:

```js
it('should mock Requests', function(expect) {
mockXHR({ id: 3, username: 'Sean' });

User.get(3, function(u) {
expect(u.get('username')).toBe('Sean');
});
});
```