factory-girl
Advanced tools
Comparing version 0.1.3 to 0.1.4
22
index.js
@@ -8,3 +8,4 @@ (function() { | ||
defaultAdapter = null, | ||
adapters = {}; | ||
adapters = {}, | ||
created = []; | ||
@@ -22,3 +23,3 @@ var factory = function(name, userAttrs, callback) { | ||
factory.adapterFor(name).save(doc, model, function(err) { | ||
if (!err) factories[name].created.push(doc); | ||
if (!err) created.push([name, doc]); | ||
callback(err, doc); | ||
@@ -34,4 +35,3 @@ }); | ||
model: model, | ||
attributes: attributes, | ||
created: [] | ||
attributes: attributes | ||
}; | ||
@@ -115,10 +115,10 @@ }; | ||
factory.cleanup = function(callback) { | ||
asyncForEach(keys(factories), function(name, cb1) { | ||
var model = factories[name].model, | ||
adapter = factory.adapterFor(name); | ||
asyncForEach(factories[name].created, function(doc, cb2) { | ||
adapter.destroy(doc, model, cb2); | ||
}, cb1); | ||
factories[name].created = []; | ||
asyncForEach(created.reverse(), function(tuple, cb) { | ||
var name = tuple[0], | ||
doc = tuple[1], | ||
adapter = factory.adapterFor(name), | ||
model = factories[name].model; | ||
adapter.destroy(doc, model, cb); | ||
}, callback); | ||
created = []; | ||
}; | ||
@@ -125,0 +125,0 @@ |
@@ -6,3 +6,3 @@ { | ||
"author": "Simon Wade", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"keywords": ["factory", "test", "bdd", "tdd", "fixture"], | ||
@@ -9,0 +9,0 @@ "repository" : { |
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
14973