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 2.2.3 to 2.3.0

10

index.js

@@ -222,3 +222,9 @@ /* global window, define */

doc = adapter.build(model, attrs);
callback(null, doc);
if (factories[name].options.afterBuild) {
factories[name].options.afterBuild.call(
this, doc, builder.options, callback);
} else {
callback(null, doc);
}
});

@@ -358,3 +364,3 @@ };

var merge = typeof require === 'function' ? require('lodash.merge') : _.merge;
function copy(obj) {

@@ -361,0 +367,0 @@ var newObj = {};

2

package.json

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

"author": "Simon Wade",
"version": "2.2.3",
"version": "2.3.0",
"keywords": [

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

@@ -38,3 +38,3 @@ # factory-girl

var factory = require('factory-girl');
var Post = require('../models/post');
var User = require('../models/user');

@@ -76,2 +76,6 @@ factory.define('user', User, {

#### `afterBuild: function(instance, options, callback)`
Provides a function that is called after the model is built.
#### `afterCreate: function(instance, options, callback)`

@@ -217,3 +221,3 @@

Copyright (c) 2014 Simon Wade. This software is licensed under the [MIT License](http://github.com/petejkim/factory-lady/raw/master/LICENSE).
Copyright (c) 2011 Peter Jihoon Kim. This software is licensed under the [MIT License](http://github.com/petejkim/factory-lady/raw/master/LICENSE).
Copyright (c) 2014 Simon Wade. This software is licensed under the [MIT License](http://github.com/petejkim/factory-lady/raw/master/LICENSE).
Copyright (c) 2011 Peter Jihoon Kim. This software is licensed under the [MIT License](http://github.com/petejkim/factory-lady/raw/master/LICENSE).

@@ -105,2 +105,39 @@ /* global describe, beforeEach, afterEach */

context('defined with an afterBuild handler', function() {
var spy;
beforeEach(function() {
spy = sinon.spy();
factory.define('job with after build', Job, {
title: 'Engineer',
company: 'Foobar Inc.'
}, {
afterBuild: function(doc, options, done) {
spy.apply(null, arguments);
doc.title = 'Astronaut';
done(null, doc);
}
});
});
it('calls afterBuild', function() {
factory.build('job with after build', function(err, job) {
spy.called.should.be.true;
});
});
it('allows afterBuild to mutate the model', function() {
factory.build('job with after build', function(err, job) {
job.title.should.eql('Astronaut');
});
});
it('calls afterBuild with buildMany', function() {
var num = 10;
factory.buildMany('job with after build', num, function(err) {
spy.callCount.should.equal(num);
});
});
});
context('factory containing an association', function() {

@@ -107,0 +144,0 @@ it('is able to handle that', function(done) {

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