Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

factory-girl

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

factory-girl - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

package.json

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc