2011-04-18 13:32:43 +00:00
|
|
|
/* Backbone helpers. Requires json2 and sinon-server or the full-blown sinon. */
|
|
|
|
|
|
|
|
var withServer = function() {
|
2011-04-18 13:46:57 +00:00
|
|
|
jasmine.getEnv().withServer();
|
2011-04-18 13:32:43 +00:00
|
|
|
};
|
|
|
|
if (isCommonJS) exports.withServer = withServer;
|
|
|
|
|
|
|
|
jasmine.Env.prototype.withServer = function() {
|
|
|
|
this.currentSuite.beforeEach(function() {
|
2011-04-18 13:46:57 +00:00
|
|
|
this.server = sinon.fakeServer.create();
|
2011-04-18 13:32:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.currentSuite.afterEach(function() {
|
|
|
|
this.server.restore();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
this.validJSONResponse = function(data) {
|
|
|
|
return [ 200, { 'Content-type': 'application/json' }, JSON.stringify(data) ];
|
|
|
|
};
|
|
|
|
});
|