factory-girl-backbone
v0.0.1
Published
A Backbone adapter for factory-girl
Downloads
4
Maintainers
Readme
- factory-girl-jugglingdb
A [[https://github.com/jashkenas/backbone][Backbone]] adapter for [[https://github.com/aexmachina/factory-girl][factory-girl]]
** Usage
Load =factory-girl= and set the adapter
#+BEGIN_SRC javascript var factory = require("factory-girl"); var BackboneAdapter = require("../factory-girl-backbone").BackboneAdapter; factory.setAdapter(BackboneAdapter); #+END_SRCCreate your Backbone Model #+BEGIN_SRC javascript var User = Backbone.Model.extend({ urlRoot: '' }); #+END_SRC
Define your factories #+BEGIN_SRC javascript factory.define("user", User, { name:"Rudy" });
#+END_SRCUse your factories #+BEGIN_SRC javascript factory.create("user", function(err, user){ // user is a `User' object }); #+END_SRC
Destroy all factories #+BEGIN_SRC javascript factory.cleanup(function(){ // ... }); #+END_SRC