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.3.0 to 1.4.0

7

index.js

@@ -33,7 +33,8 @@ (function() {

factory.assoc = function(name, attr) {
factory.assoc = function(name, key, attrs) {
attrs = attrs || {};
return function(callback) {
factory.create(name, function(err, doc) {
factory.create(name, attrs, function(err, doc) {
if (err) return callback(err);
callback(null, attr ? doc[attr] : doc);
callback(null, key ? doc[key] : doc);
});

@@ -40,0 +41,0 @@ };

@@ -6,3 +6,3 @@ {

"author": "Simon Wade",
"version": "1.3.0",
"version": "1.4.0",
"keywords": [

@@ -9,0 +9,0 @@ "factory",

@@ -44,4 +44,4 @@ # factory-girl

factory.define('post', Post, {
// create associations using factory.assoc(model, attr)
// or factory.assoc('user') for user object itself
// create associations using factory.assoc(model, key)
// or factory.assoc('user') to return the user object itself.
user_id: factory.assoc('user', 'id'),

@@ -57,2 +57,6 @@ subject: 'Hello World',

### Factory#assoc
You can optionally provide attributes to the associated factory by passing an object as third argument.
## Using Factories

@@ -59,0 +63,0 @@

@@ -41,3 +41,3 @@ /* global describe, beforeEach, afterEach */

age: 25,
job: factory.assoc('job'),
job: factory.assoc('job', null, { company: 'Bazqux Co.' }),
title: factory.assoc('job', 'title')

@@ -83,3 +83,3 @@ });

person.job.title.should.eql('Engineer');
person.job.company.should.eql('Foobar Inc.');
person.job.company.should.eql('Bazqux Co.');
person.job.saveCalled.should.be.true;

@@ -86,0 +86,0 @@ person.title.should.eql('Engineer');

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