Skip to content

simonexmachina/factory-girl-bookshelf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This package has been deprecated: Bookshelf support is now included in the factory-girl package

factory-girl-bookshelf

Build Status

A Bookshelf adapter for factory-girl.

Usage

require('factory-girl-bookshelf')();

Or, if you want to specify which models it should be used for:

require('factory-girl-bookshelf')(['User', 'Foo', 'Bar']);

Relationships can be created using assoc:

var Model = Bookshelf.db.Model;
var Parent = Model.extend({
  children: function() {
    return this.hasMany(Child, 'parent_id');
  }
});
var Child = Model.extend({
  parent: function() {
    return this.belongsTo(Parent, 'parent_id');
  }
});
factory.define('parent', Parent);
factory.define('child', Child, {
  parent_id: factory.assoc('parent', 'id')
});

About

A Bookshelf adapter for factory-girl

Resources

License

Stars

Watchers

Forks

Packages

No packages published