Skip to content

Instantly share code, notes, and snippets.

@brucecrevensten
Created December 14, 2011 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brucecrevensten/1477803 to your computer and use it in GitHub Desktop.
Save brucecrevensten/1477803 to your computer and use it in GitHub Desktop.
backbone-jasmine
Model = Backbone.Model.extend({
url: '/something'
});
aModel = new Model({ id: 'else' });
FixturesSync = function(method, model, options) {
var url = model.url || model.collection.url;
switch (method) {
case "read":
return fixtures['read'][model.url][model.id];
break;
case "create":
return fixtures[model.url]['create']; break;
//etc for "update" and "delete" cases
}
options.success(resp);
};
var fixtures = {
'read' : {
'/something' : {
'else' : { // collection of properties }
}
};
describe("how to test this", function() {
beforeEach( function() {
Backbone.sync = FixturesSync; // swap out the sync to map to fixtures
});
it('should work!', function() {} );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment