Created
December 14, 2011 18:19
-
-
Save brucecrevensten/1477803 to your computer and use it in GitHub Desktop.
backbone-jasmine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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