factory-girl
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -6,3 +6,3 @@ { | ||
"author": "Simon Wade", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"keywords": [ | ||
@@ -9,0 +9,0 @@ "factory", |
@@ -13,12 +13,12 @@ # factory-girl | ||
``` | ||
``` bash | ||
npm install factory-girl | ||
``` | ||
Also works in the browser or other JavaScript environments. | ||
To use `factory-girl` in the browser or other JavaScript environments, just include `index.js` and access `window.Factory`. | ||
## Defining Factories | ||
``` | ||
var factory = require('factory-lady'), | ||
``` javascript | ||
var factory = require('factory-girl'), | ||
User = require('../../app/models/user'), | ||
@@ -46,3 +46,4 @@ Post = require('../../app/models/post'); | ||
// create associations using factory.assoc(model, attr) | ||
user_id: factory.assoc('user', 'id'), // or factory.assoc('user') returns the user object | ||
// or factory.assoc('user') for user object itself | ||
user_id: factory.assoc('user', 'id'), | ||
subject: 'Hello World', | ||
@@ -59,13 +60,13 @@ // you can refer to other attributes using `this` | ||
``` | ||
``` javascript | ||
factory.build('post', function(err, post) { | ||
// build a Post instance that is not saved | ||
// post is a Post instance that is not saved | ||
}); | ||
factory.build('post', {title: 'Foo', content: 'Bar'}, function(err, post) { | ||
// build a post and override the title and content | ||
// build a post and override title and content | ||
}); | ||
factory.create('post', function(err, post) { | ||
// build and save a Post instance | ||
// post is a saved Post instance | ||
}); | ||
@@ -78,3 +79,3 @@ ``` | ||
``` | ||
``` javascript | ||
factory.buildMany('post', 10, function(err, posts) { | ||
@@ -103,3 +104,3 @@ // build 10 posts | ||
``` | ||
``` javascript | ||
var doc = factory.buildSync('post', {title: 'Foo'}); | ||
@@ -110,5 +111,5 @@ ``` | ||
Use Adapters for different databases and ORMs. | ||
Adapters provide [support for different databases and ORMs](https://www.npmjs.org/browse/keyword/factory-girl). | ||
``` | ||
``` javascript | ||
var anotherFactory = new factory.Factory(); | ||
@@ -115,0 +116,0 @@ var BookshelfAdapter = require('factory-girl-bookshelf').BookshelfAdapter; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101271
126