{"_id":"factory-castrado","_rev":"27-d0199bc22c1916f72fe7369baa43eee7","name":"factory-castrado","description":"Node.js library for generating test data with factories. Inspired by factory_girl","dist-tags":{"latest":"0.0.12"},"versions":{"0.0.1":{"name":"factory-castrado","version":"0.0.1","description":"Node.js library for generating test data with factories. Inspired by factory_girl","keywords":[],"author":{"name":"David Govea","email":"govea.d@gmail.com"},"main":"index","engines":{"node":">= 0.4.x"},"scripts":{"test":"make test","prepublish":"make test && make build"},"dependencies":{"lodash":"~1.1.1"},"devDependencies":{"coffee-script":">= 1.6.0","mocha":">= 0.11.0","should":">= 0.5.1","backbone":"~1.0.0"},"readme":"# factory-castrado\n[![Build Status](https://travis-ci.org/davidgovea/factory-castrado.png)](https://travis-ci.org/davidgovea/factory-castrado)\n\nFactory Castrado is a library for Node.js which provides factories for objects creation. It is designed for use with Backbone-style models which use ```new Model(attributes)``` for initialization and ```model.create(function(err, model){...})``` for saving.  \n  \nIt is highly inspired by:\n- [factory_girl](https://github.com/thoughtbot/factory_girl) - ruby\n- [factory-lady](https://github.com/petejkim/factory-lady) - node.js\n- [factory-boy](https://github.com/kbackowski/factory-boy) - node.js\n\n## Installation\n\nNode.js:\n\n```\nnpm install factory-castrado\n```\n\n## Usage\n\n### Defining factories\nCoffeescript:\n```coffee\nFactory\t= require 'factory-castrado'\nModel\t= require('backbone').Model\n\ncounter = 1\n\n# Define with (name, model, attributes)\nFactory.define 'user', Model, \n\temail: (cb) -> cb(\"user#{counter++}@test.com\")\n\tname: \"Test name\"\n\tpassword: 'abc123'\n\n# With associations, using (name, options):\nFactory.define 'post',\n\tmodel: Model\n\tattributes:\n\t\ttitle: \"Test title\"\n\t\tcontent: \"Test content\"\n\tassociations:\n\t\tuser:\n\t\t\tfactory: 'user'\t# Defaults to association name (user here)\n\t\t\tkey: 'user_id'\t# Defaults to name + _id\n\n```\n\n### Using factories\nCoffeescript:\n```coffee\nFactory.build 'user', (user) ->\n\t# user is an unsaved user model\n\nFactory.build 'user', name:\"New\", (user) ->\n\t# user is an unsaved user model with name \"New\"\n\nFactory.build 'post', (post) ->\n\t# post is an unsaved post model\n\t# post.user is a saved associated user model\n\t# post has new attribute 'user_id' with the user's id\n\nFactory.create 'user', (user) -> \n\t# User is SAVED model\n\n```\n\n### Associations\nCoffeescript:\n```coffee\nFactory.define 'post',\n\tmodel: Model\n\tassociations:\n\t\tuser:\n\t\t\t# Defaults to association name (user here)\n\t\t\tfactory: 'user'\t\n\t\t\t\n\t\t\t# Defaults to name + _id\n\t\t\tkey: 'user_id'\t\n\t\t\t\n\t\t\t# Gets foreign key from associated model\n\t\t\t# Default getter, just grabs id\n\t\t\tgetter: (assocObj) -> return assocObj.id  \n\t\t\t\n\t\t\t# Sets foreign key on factory's built model\n\t\t\t# Default setter (pseudocode - uses 'key' from above if setter not overridden)\n\t\t\tsetter: (obj, val) -> obj.set {{key}}, val\n\t\t\t\n\t\t\t # Conveniently provides default setters/getters\n\t\t\ttype: 'id' # Currently supported: \"id\", \"ids[]\"\n\t\t\t# Using type: \"ids[]\" provides a default setter than inserts id into object's array of ids\n```\n\n\n## License\n\nWTFPL v2\n","readmeFilename":"README.md","_id":"factory-castrado@0.0.1","dist":{"shasum":"694d6eeb5c65007f230b7dd3043762aadee0aeca","tarball":"https://registry.npmjs.org/factory-castrado/-/factory-castrado-0.0.1.tgz","integrity":"sha512-Qk0vdYyWTXTSSXVWHkVz66ZoWFdu2IDbWPAC3rkLNuJbzaVMrCdZs8zviGx73inUC9ufXzRNDqJAWilXEWlUHw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICTfomlU9o5eaLWVYcecegyB1Ees5YT6Lajaz8hG/Wc8AiEAvcTJIjBhqI9HBsGW0+uaEroG4mwcXG0QY8EdxZNZaKc="}]},"_from":".","_npmVersion":"1.2.17","_npmUser":{"name":"davidgovea","email":"govea.d@gmail.com"},"maintainers":[{"name":"davidgovea","email":"govea.d@gmail.com"}]},"0.0.2":{"name":"factory-castrado","version":"0.0.2","description":"Node.js library for generating test data with factories. Inspired by factory_girl","keywords":[],"author":{"name":"David Govea","email":"govea.d@gmail.com"},"main":"index","engines":{"node":">= 0.4.x"},"scripts":{"test":"make test","prepublish":"make test && make build"},"dependencies":{"lodash":"~1.1.1"},"devDependencies":{"coffee-script":">= 1.6.0","mocha":">= 0.11.0","should":">= 0.5.1","backbone":"~1.0.0"},"readme":"# factory-castrado\n[![Build Status](https://travis-ci.org/davidgovea/factory-castrado.png)](https://travis-ci.org/davidgovea/factory-castrado)\n\nFactory Castrado is a library for Node.js which provides factories for objects creation. It is designed for use with Backbone-style models which use ```new Model(attributes)``` for initialization and ```model.create(function(err, model){...})``` for saving.  \n  \nIt is highly inspired by:\n- [factory_girl](https://github.com/thoughtbot/factory_girl) - ruby\n- [factory-lady](https://github.com/petejkim/factory-lady) - node.js\n- [factory-boy](https://github.com/kbackowski/factory-boy) - node.js\n\n## Installation\n\nNode.js:\n\n```\nnpm install factory-castrado\n```\n\n## Usage\n\n### Defining factories\nCoffeescript:\n```coffee\nFactory\t= require 'factory-castrado'\nModel\t= require('backbone').Model\n\ncounter = 1\n\n# Define with (name, model, attributes)\nFactory.define 'user', Model, \n\temail: (cb) -> cb(\"user#{counter++}@test.com\")\n\tname: \"Test name\"\n\tpassword: 'abc123'\n\n# With associations, using (name, options):\nFactory.define 'post',\n\tmodel: Model\n\tattributes:\n\t\ttitle: \"Test title\"\n\t\tcontent: \"Test content\"\n\tassociations:\n\t\tuser:\n\t\t\tfactory: 'user'\t# Defaults to association name (user here)\n\t\t\tkey: 'user_id'\t# Defaults to name + _id\n\n```\n\n### Using factories\nCoffeescript:\n```coffee\nFactory.build 'user', (user) ->\n\t# user is an unsaved user model\n\nFactory.build 'user', name:\"New\", (user) ->\n\t# user is an unsaved user model with name \"New\"\n\nFactory.build 'post', (post) ->\n\t# post is an unsaved post model\n\t# post.user is a saved associated user model\n\t# post has new attribute 'user_id' with the user's id\n\nFactory.create 'user', (user) -> \n\t# User is SAVED model\n\n```\n\n### Associations\nCoffeescript:\n```coffee\nFactory.define 'post',\n\tmodel: Model\n\tassociations:\n\t\tuser:\n\t\t\t# Defaults to association name (user here)\n\t\t\tfactory: 'user'\t\n\t\t\t\n\t\t\t# Defaults to name + _id\n\t\t\tkey: 'user_id'\t\n\t\t\t\n\t\t\t# Gets foreign key from associated model\n\t\t\t# Default getter, just grabs id\n\t\t\tgetter: (assocObj) -> return assocObj.id  \n\t\t\t\n\t\t\t# Sets foreign key on factory's built model\n\t\t\t# Default setter (pseudocode - uses 'key' from above if setter not overridden)\n\t\t\tsetter: (obj, val) -> obj.set {{key}}, val\n\t\t\t\n\t\t\t # Conveniently provides default setters/getters\n\t\t\ttype: 'id' # Currently supported: \"id\", \"ids[]\"\n\t\t\t# Using type: \"ids[]\" provides a default setter than inserts id into object's array of ids\n\n\n# Id-array associations\n# This will generate a message model with:\n# user_ids: [id1, id2]\n# as well as user models attached directly at msg.to , msg.from\nFactory.define 'message',\n\tmodel: MessageModel\n\tattributes:\n\t\ttitle: \"Hello World\"\n\tassociations:\n\t\tfrom:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n\t\tto:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n```\n\n\n## License\n\nWTFPL v2\n","readmeFilename":"README.md","_id":"factory-castrado@0.0.2","dist":{"shasum":"7d06724f47be990a7b2b8d2098913f87a67a1715","tarball":"https://registry.npmjs.org/factory-castrado/-/factory-castrado-0.0.2.tgz","integrity":"sha512-S29ODwcbayddFNcYYxHKVs47OENM4XjXHk7QQGxh111okWPpMFCsKwlju23RwazslLShmlmeKPrfgx45Kybmyg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHwjLMqodZaUP1okThlncehBSty96ceM+LnnLMPlg5XLAiEA8xdk9z6WdC519+yZko7vpBa1CUtat/pM5vPnPvoqRFU="}]},"_from":".","_npmVersion":"1.2.17","_npmUser":{"name":"davidgovea","email":"govea.d@gmail.com"},"maintainers":[{"name":"davidgovea","email":"govea.d@gmail.com"}]},"0.0.3":{"name":"factory-castrado","version":"0.0.3","description":"Node.js library for generating test data with factories. Inspired by factory_girl","keywords":[],"author":{"name":"David Govea","email":"govea.d@gmail.com"},"main":"index","engines":{"node":">= 0.4.x"},"scripts":{"test":"make test","prepublish":"make test && make build"},"dependencies":{"lodash":"~1.1.1"},"devDependencies":{"coffee-script":">= 1.6.0","mocha":">= 0.11.0","should":">= 0.5.1","backbone":"~1.0.0"},"readme":"# factory-castrado\n[![Build Status](https://travis-ci.org/davidgovea/factory-castrado.png)](https://travis-ci.org/davidgovea/factory-castrado)\n\nFactory Castrado is a library for Node.js which provides factories for objects creation. It is designed for use with Backbone-style models which use ```new Model(attributes)``` for initialization and ```model.create(function(err, model){...})``` for saving.  \n  \nIt is highly inspired by:\n- [factory_girl](https://github.com/thoughtbot/factory_girl) - ruby\n- [factory-lady](https://github.com/petejkim/factory-lady) - node.js\n- [factory-boy](https://github.com/kbackowski/factory-boy) - node.js\n\n## Installation\n\nNode.js:\n\n```\nnpm install factory-castrado\n```\n\n## Usage\n\n### Defining factories\nCoffeescript:\n```coffee\nFactory\t= require 'factory-castrado'\nModel\t= require('backbone').Model\n\ncounter = 1\n\n# Define with (name, model, attributes)\nFactory.define 'user', Model, \n\temail: (cb) -> cb(\"user#{counter++}@test.com\")\n\tname: \"Test name\"\n\tpassword: 'abc123'\n\n# With associations, using (name, options):\nFactory.define 'post',\n\tmodel: Model\n\tattributes:\n\t\ttitle: \"Test title\"\n\t\tcontent: \"Test content\"\n\tassociations:\n\t\tuser:\n\t\t\tfactory: 'user'\t# Defaults to association name (user here)\n\t\t\tkey: 'user_id'\t# Defaults to name + _id\n\n```\n\n### Using factories\nCoffeescript:\n```coffee\nFactory.build 'user', (user) ->\n\t# user is an unsaved user model\n\nFactory.build 'user', name:\"New\", (user) ->\n\t# user is an unsaved user model with name \"New\"\n\nFactory.build 'post', (post) ->\n\t# post is an unsaved post model\n\t# post.user is a saved associated user model\n\t# post has new attribute 'user_id' with the user's id\n\nFactory.create 'user', (user) -> \n\t# User is SAVED model\n\n```\n\n### Associations\nCoffeescript:\n```coffee\nFactory.define 'post',\n\tmodel: Model\n\tassociations:\n\t\tuser:\n\t\t\t# Defaults to association name (user here)\n\t\t\tfactory: 'user'\t\n\t\t\t\n\t\t\t# Defaults to name + _id\n\t\t\tkey: 'user_id'\t\n\t\t\t\n\t\t\t# Gets foreign key from associated model\n\t\t\t# Default getter, just grabs id\n\t\t\tgetter: (assocObj) -> return assocObj.id  \n\t\t\t\n\t\t\t# Sets foreign key on factory's built model\n\t\t\t# Default setter (pseudocode - uses 'key' from above if setter not overridden)\n\t\t\tsetter: (obj, val) -> obj.set {{key}}, val\n\t\t\t\n\t\t\t # Conveniently provides default setters/getters\n\t\t\ttype: 'id' # Currently supported: \"id\", \"ids[]\"\n\t\t\t# Using type: \"ids[]\" provides a default setter than inserts id into object's array of ids\n\n\n# Id-array associations\n# This will generate a message model with:\n# user_ids: [id1, id2]\n# as well as user models attached directly at msg.to , msg.from\nFactory.define 'message',\n\tmodel: MessageModel\n\tattributes:\n\t\ttitle: \"Hello World\"\n\tassociations:\n\t\tfrom:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n\t\tto:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n```\n\n\n## License\n\nWTFPL v2\n","readmeFilename":"README.md","_id":"factory-castrado@0.0.3","dist":{"shasum":"7580a761e227dba7b3ae0dcf30d4e9adf81fd9f2","tarball":"https://registry.npmjs.org/factory-castrado/-/factory-castrado-0.0.3.tgz","integrity":"sha512-VKhjtH0TesG9cTX97S3bpi0nT9oMteFWSI3r5249xGBr9KpBHjD1o2inp82rpJTKaoDHh+shYWgkHimqNLfCbg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDsctvV82mWn8dORWMaSS1mPmxxwOXx72cisaZBKkykogIgcJStDHFmFgi5FvqZ/VQFkh+on6ym/CLIrmis6X2opUs="}]},"_from":".","_npmVersion":"1.2.17","_npmUser":{"name":"davidgovea","email":"govea.d@gmail.com"},"maintainers":[{"name":"davidgovea","email":"govea.d@gmail.com"}]},"0.0.4":{"name":"factory-castrado","version":"0.0.4","description":"Node.js library for generating test data with factories. Inspired by factory_girl","keywords":[],"author":{"name":"David Govea","email":"govea.d@gmail.com"},"main":"index","engines":{"node":">= 0.4.x"},"scripts":{"test":"make test","prepublish":"make test && make build"},"dependencies":{"lodash":"~1.1.1"},"devDependencies":{"coffee-script":">= 1.6.0","mocha":">= 0.11.0","should":">= 0.5.1","backbone":"~1.0.0"},"readme":"# factory-castrado\n[![Build Status](https://travis-ci.org/davidgovea/factory-castrado.png)](https://travis-ci.org/davidgovea/factory-castrado)\n\nFactory Castrado is a library for Node.js which provides factories for objects creation. It is designed for use with Backbone-style models which use ```new Model(attributes)``` for initialization and ```model.create(function(err, model){...})``` for saving.  \n  \nIt is highly inspired by:\n- [factory_girl](https://github.com/thoughtbot/factory_girl) - ruby\n- [factory-lady](https://github.com/petejkim/factory-lady) - node.js\n- [factory-boy](https://github.com/kbackowski/factory-boy) - node.js\n\n## Installation\n\nNode.js:\n\n```\nnpm install factory-castrado\n```\n\n## Usage\n\n### Defining factories\nCoffeescript:\n```coffee\nFactory\t= require 'factory-castrado'\nModel\t= require('backbone').Model\n\ncounter = 1\n\n# Define with (name, model, attributes)\nFactory.define 'user', Model, \n\temail: (cb) -> cb(\"user#{counter++}@test.com\")\n\tname: \"Test name\"\n\tpassword: 'abc123'\n\n# With associations, using (name, options):\nFactory.define 'post',\n\tmodel: Model\n\tattributes:\n\t\ttitle: \"Test title\"\n\t\tcontent: \"Test content\"\n\tassociations:\n\t\tuser:\n\t\t\tfactory: 'user'\t# Defaults to association name (user here)\n\t\t\tkey: 'user_id'\t# Defaults to name + _id\n\n```\n\n### Using factories\nCoffeescript:\n```coffee\nFactory.build 'user', (user) ->\n\t# user is an unsaved user model\n\nFactory.build 'user', name:\"New\", (user) ->\n\t# user is an unsaved user model with name \"New\"\n\nFactory.build 'post', (post) ->\n\t# post is an unsaved post model\n\t# post.user is a saved associated user model\n\t# post has new attribute 'user_id' with the user's id\n\nFactory.create 'user', (user) -> \n\t# User is SAVED model\n\n```\n\n### Associations\nCoffeescript:\n```coffee\nFactory.define 'post',\n\tmodel: Model\n\tassociations:\n\t\tuser:\n\t\t\t# Defaults to association name (user here)\n\t\t\tfactory: 'user'\t\n\t\t\t\n\t\t\t# Defaults to name + _id\n\t\t\tkey: 'user_id'\t\n\t\t\t\n\t\t\t# Gets foreign key from associated model\n\t\t\t# Default getter, just grabs id\n\t\t\tgetter: (assocObj) -> return assocObj.id  \n\t\t\t\n\t\t\t# Sets foreign key on factory's built model\n\t\t\t# Default setter (pseudocode - uses 'key' from above if setter not overridden)\n\t\t\tsetter: (obj, val) -> obj.set {{key}}, val\n\t\t\t\n\t\t\t # Conveniently provides default setters/getters\n\t\t\ttype: 'id' # Currently supported: \"id\", \"ids[]\"\n\t\t\t# Using type: \"ids[]\" provides a default setter than inserts id into object's array of ids\n\n\n# Id-array associations\n# This will generate a message model with:\n# user_ids: [id1, id2]\n# as well as user models attached directly at msg.to , msg.from\nFactory.define 'message',\n\tmodel: MessageModel\n\tattributes:\n\t\ttitle: \"Hello World\"\n\tassociations:\n\t\tfrom:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n\t\tto:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n```\n\n\n## License\n\nWTFPL v2\n","readmeFilename":"README.md","_id":"factory-castrado@0.0.4","dist":{"shasum":"d331be23623d6f7fad842f3c43e444374fc8df16","tarball":"https://registry.npmjs.org/factory-castrado/-/factory-castrado-0.0.4.tgz","integrity":"sha512-1jlnEIUMcvlcrtuUTIRLomXfLWb/Q3ak1SeFkT5RMt98dzrcBkfBF60BH0MSnUAO/zLg4oMjxN/NU/XmlegGEg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDtnYgVlgWyXKYX+bNZ041aavkjGayw82WZ+ouYTXH0/gIgGLSK1sipMrpoviuBstH9P209caDeu8q/kXYZMjts/y0="}]},"_from":".","_npmVersion":"1.2.17","_npmUser":{"name":"davidgovea","email":"govea.d@gmail.com"},"maintainers":[{"name":"davidgovea","email":"govea.d@gmail.com"}]},"0.0.5":{"name":"factory-castrado","version":"0.0.5","description":"Node.js library for generating test data with factories. Inspired by factory_girl","keywords":[],"author":{"name":"David Govea","email":"govea.d@gmail.com"},"main":"index","engines":{"node":">= 0.4.x"},"scripts":{"test":"make test","prepublish":"make test && make build"},"dependencies":{"lodash":"~1.1.1"},"devDependencies":{"coffee-script":">= 1.6.0","mocha":">= 0.11.0","should":">= 0.5.1","backbone":"~1.0.0"},"readme":"# factory-castrado\n[![Build Status](https://travis-ci.org/davidgovea/factory-castrado.png)](https://travis-ci.org/davidgovea/factory-castrado)\n\nFactory Castrado is a library for Node.js which provides factories for objects creation. It is designed for use with Backbone-style models which use ```new Model(attributes)``` for initialization and ```model.create(function(err, model){...})``` for saving.  \n  \nIt is highly inspired by:\n- [factory_girl](https://github.com/thoughtbot/factory_girl) - ruby\n- [factory-lady](https://github.com/petejkim/factory-lady) - node.js\n- [factory-boy](https://github.com/kbackowski/factory-boy) - node.js\n\n## Installation\n\nNode.js:\n\n```\nnpm install factory-castrado\n```\n\n## Usage\n\n### Defining factories\nCoffeescript:\n```coffee\nFactory\t= require 'factory-castrado'\nModel\t= require('backbone').Model\n\ncounter = 1\n\n# Define with (name, model, attributes)\nFactory.define 'user', Model, \n\temail: (cb) -> cb(\"user#{counter++}@test.com\")\n\tname: \"Test name\"\n\tpassword: 'abc123'\n\n# With associations, using (name, options):\nFactory.define 'post',\n\tmodel: Model\n\tattributes:\n\t\ttitle: \"Test title\"\n\t\tcontent: \"Test content\"\n\tassociations:\n\t\tuser:\n\t\t\tfactory: 'user'\t# Defaults to association name (user here)\n\t\t\tkey: 'user_id'\t# Defaults to name + _id\n\n```\n\n### Using factories\nCoffeescript:\n```coffee\nFactory.build 'user', (user) ->\n\t# user is an unsaved user model\n\nFactory.build 'user', name:\"New\", (user) ->\n\t# user is an unsaved user model with name \"New\"\n\nFactory.build 'post', (post) ->\n\t# post is an unsaved post model\n\t# post.user is a saved associated user model\n\t# post has new attribute 'user_id' with the user's id\n\nFactory.create 'user', (user) -> \n\t# User is SAVED model\n\n```\n\n### Associations\nCoffeescript:\n```coffee\nFactory.define 'post',\n\tmodel: Model\n\tassociations:\n\t\tuser:\n\t\t\t# Defaults to association name (user here)\n\t\t\tfactory: 'user'\t\n\t\t\t\n\t\t\t# Defaults to name + _id\n\t\t\tkey: 'user_id'\t\n\t\t\t\n\t\t\t# Gets foreign key from associated model\n\t\t\t# Default getter, just grabs id\n\t\t\tgetter: (assocObj) -> return assocObj.id  \n\t\t\t\n\t\t\t# Sets foreign key on factory's built model\n\t\t\t# Default setter (pseudocode - uses 'key' from above if setter not overridden)\n\t\t\tsetter: (obj, val) -> obj.set {{key}}, val\n\t\t\t\n\t\t\t # Conveniently provides default setters/getters\n\t\t\ttype: 'id' # Currently supported: \"id\", \"ids[]\"\n\t\t\t# Using type: \"ids[]\" provides a default setter than inserts id into object's array of ids\n\n\n# Id-array associations\n# This will generate a message model with:\n# user_ids: [id1, id2]\n# as well as user models attached directly at msg.to , msg.from\nFactory.define 'message',\n\tmodel: MessageModel\n\tattributes:\n\t\ttitle: \"Hello World\"\n\tassociations:\n\t\tfrom:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n\t\tto:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n```\n\n### Custom Factories\nCoffeescript: \n```coffee\n# Custom factories can be defined with a function\nFactory.define 'two users and a random number', (callback) ->\n\tFactory.create 'user', (user1) ->\n\t\tFactory.create 'user', (user2) ->\n\n\t\t\trandomNum = ~~(Math.random()*10)\n\t\t\tcallback(user1, user2, randomNum)\n\n# Using it:\nFactory.create 'two users and a random number', (user1, user2, randomNum) ->\n\n# Custom attributes will be passed through to \n# custom factories after callback parameter:\nFactory.define 'helloworld', (callback, options) ->\n\tdata = \"Hello World\"\n\tif options?.caps\n\t\treturn callback(data.toUpperCase())\n\n\tcallback(data)\n\nFactory.create 'helloworld', (string) -> # string == 'Hello World'\nFactory.create 'helloworld', caps:true, (string) -> # string == 'HELLO WORLD'\n```\n\n\n## License\n\nWTFPL v2\n","readmeFilename":"README.md","_id":"factory-castrado@0.0.5","dist":{"shasum":"5ba3fe19523ef38dfa794dc1c57a21751ae14d6b","tarball":"https://registry.npmjs.org/factory-castrado/-/factory-castrado-0.0.5.tgz","integrity":"sha512-WApNcb+y8V37H75mwGSvF3OCk4slD4RnvKcsyvp04yu2kis96NOKstGZBcXK2FtKnvYdYtQBZLEnwJwdN81K4A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDnqGUHne39y+2+CmPWkQbARxzpDSIoWK+f4jKJKaBM8wIhANvga0zGdMeZCCWNJMrj4lygsQaD5eAcR+CnBOPtjTxs"}]},"_from":".","_npmVersion":"1.2.17","_npmUser":{"name":"davidgovea","email":"govea.d@gmail.com"},"maintainers":[{"name":"davidgovea","email":"govea.d@gmail.com"}]},"0.0.6":{"name":"factory-castrado","version":"0.0.6","description":"Node.js library for generating test data with factories. Inspired by factory_girl","keywords":[],"author":{"name":"David Govea","email":"govea.d@gmail.com"},"main":"index","engines":{"node":">= 0.4.x"},"scripts":{"test":"make test","prepublish":"make test && make build"},"dependencies":{"lodash":"~1.1.1"},"devDependencies":{"coffee-script":">= 1.6.0","mocha":">= 0.11.0","should":">= 0.5.1","backbone":"~1.0.0"},"readme":"# factory-castrado\n[![Build Status](https://travis-ci.org/davidgovea/factory-castrado.png)](https://travis-ci.org/davidgovea/factory-castrado)\n\nFactory Castrado is a library for Node.js which provides factories for objects creation. It is designed for use with Backbone-style models which use ```new Model(attributes)``` for initialization and ```model.create(function(err, model){...})``` for saving.  \n  \nIt is highly inspired by:\n- [factory_girl](https://github.com/thoughtbot/factory_girl) - ruby\n- [factory-lady](https://github.com/petejkim/factory-lady) - node.js\n- [factory-boy](https://github.com/kbackowski/factory-boy) - node.js\n\n## Installation\n\nNode.js:\n\n```\nnpm install factory-castrado\n```\n\n## Usage\n\n### Defining factories\nCoffeescript:\n```coffee\nFactory\t= require 'factory-castrado'\nModel\t= require('backbone').Model\n\ncounter = 1\n\n# Define with (name, model, attributes)\nFactory.define 'user', Model, \n\temail: (cb) -> cb(\"user#{counter++}@test.com\")\n\tname: \"Test name\"\n\tpassword: 'abc123'\n\n# With associations, using (name, options):\nFactory.define 'post',\n\tmodel: Model\n\tattributes:\n\t\ttitle: \"Test title\"\n\t\tcontent: \"Test content\"\n\tassociations:\n\t\tuser:\n\t\t\tfactory: 'user'\t# Defaults to association name (user here)\n\t\t\tkey: 'user_id'\t# Defaults to name + _id\n\n```\n\n### Using factories\nCoffeescript:\n```coffee\nFactory.build 'user', (user) ->\n\t# user is an unsaved user model\n\nFactory.build 'user', name:\"New\", (user) ->\n\t# user is an unsaved user model with name \"New\"\n\nFactory.build 'post', (post) ->\n\t# post is an unsaved post model\n\t# post.user is a saved associated user model\n\t# post has new attribute 'user_id' with the user's id\n\nFactory.create 'user', (user) -> \n\t# User is SAVED model\n\n```\n\n### Associations\nCoffeescript:\n```coffee\nFactory.define 'post',\n\tmodel: Model\n\tassociations:\n\t\tuser:\n\t\t\t# Defaults to association name (user here)\n\t\t\tfactory: 'user'\t\n\t\t\t\n\t\t\t# Defaults to name + _id\n\t\t\tkey: 'user_id'\t\n\t\t\t\n\t\t\t# Gets foreign key from associated model\n\t\t\t# Default getter, just grabs id\n\t\t\tgetter: (assocObj) -> return assocObj.id  \n\t\t\t\n\t\t\t# Sets foreign key on factory's built model\n\t\t\t# Default setter (pseudocode - uses 'key' from above if setter not overridden)\n\t\t\tsetter: (obj, val) -> obj.set {{key}}, val\n\t\t\t\n\t\t\t # Conveniently provides default setters/getters\n\t\t\ttype: 'id' # Currently supported: \"id\", \"ids[]\"\n\t\t\t# Using type: \"ids[]\" provides a default setter than inserts id into object's array of ids\n\n\n# Id-array associations\n# This will generate a message model with:\n# user_ids: [id1, id2]\n# as well as user models attached directly at msg.to , msg.from\nFactory.define 'message',\n\tmodel: MessageModel\n\tattributes:\n\t\ttitle: \"Hello World\"\n\tassociations:\n\t\tfrom:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n\t\tto:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n```\n\n### Custom Factories\nCoffeescript: \n```coffee\n# Custom factories can be defined with a function\nFactory.define 'two users and a random number', (callback) ->\n\tFactory.create 'user', (user1) ->\n\t\tFactory.create 'user', (user2) ->\n\n\t\t\trandomNum = ~~(Math.random()*10)\n\t\t\tcallback(user1, user2, randomNum)\n\n# Using it:\nFactory.create 'two users and a random number', (user1, user2, randomNum) ->\n\n# Custom attributes will be passed through to \n# custom factories after callback parameter:\nFactory.define 'helloworld', (callback, options) ->\n\tdata = \"Hello World\"\n\tif options?.caps\n\t\treturn callback(data.toUpperCase())\n\n\tcallback(data)\n\nFactory.create 'helloworld', (string) -> # string == 'Hello World'\nFactory.create 'helloworld', caps:true, (string) -> # string == 'HELLO WORLD'\n```\n\n\n## License\n\nWTFPL v2\n","readmeFilename":"README.md","_id":"factory-castrado@0.0.6","dist":{"shasum":"bcfc11f4b279cf8beab93b85ac648cbfe6b76ae7","tarball":"https://registry.npmjs.org/factory-castrado/-/factory-castrado-0.0.6.tgz","integrity":"sha512-aRWsrNKX1y5I3oabKPu/sFIY9fAiFfnMJxsrewi41HHKtDneN8MhHBRk7kFxvpwenlbNmRAnz1Ie8hZO4pPpBw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDM+JP/+xLxEfiUDKFut/70tUQP0DP62uqFG3XqUJa9zQIgDwWf5cA2S+ZVcAIF3wjt9pzSKy4SCLiRenXe5T8JQbY="}]},"_from":".","_npmVersion":"1.2.17","_npmUser":{"name":"davidgovea","email":"govea.d@gmail.com"},"maintainers":[{"name":"davidgovea","email":"govea.d@gmail.com"}]},"0.0.7":{"name":"factory-castrado","version":"0.0.7","description":"Node.js library for generating test data with factories. Inspired by factory_girl","keywords":[],"author":{"name":"David Govea","email":"govea.d@gmail.com"},"main":"index","engines":{"node":">= 0.4.x"},"scripts":{"test":"make test","prepublish":"make test && make build"},"dependencies":{"lodash":"~1.1.1"},"devDependencies":{"coffee-script":">= 1.6.0","mocha":">= 0.11.0","should":">= 0.5.1","backbone":"~1.0.0"},"readme":"# factory-castrado\n[![Build Status](https://travis-ci.org/davidgovea/factory-castrado.png)](https://travis-ci.org/davidgovea/factory-castrado)\n\nFactory Castrado is a library for Node.js which provides factories for objects creation. It is designed for use with Backbone-style models which use ```new Model(attributes)``` for initialization and ```model.create(function(err, model){...})``` for saving.  \n  \nIt is highly inspired by:\n- [factory_girl](https://github.com/thoughtbot/factory_girl) - ruby\n- [factory-lady](https://github.com/petejkim/factory-lady) - node.js\n- [factory-boy](https://github.com/kbackowski/factory-boy) - node.js\n\n## Installation\n\nNode.js:\n\n```\nnpm install factory-castrado\n```\n\n## Usage\n\n### Defining factories\nCoffeescript:\n```coffee\nFactory\t= require 'factory-castrado'\nModel\t= require('backbone').Model\n\ncounter = 1\n\n# Define with (name, model, attributes)\nFactory.define 'user', Model, \n\temail: (cb) -> cb(\"user#{counter++}@test.com\")\n\tname: \"Test name\"\n\tpassword: 'abc123'\n\n# With associations, using (name, options):\nFactory.define 'post',\n\tmodel: Model\n\tattributes:\n\t\ttitle: \"Test title\"\n\t\tcontent: \"Test content\"\n\tassociations:\n\t\tuser:\n\t\t\tfactory: 'user'\t# Defaults to association name (user here)\n\t\t\tkey: 'user_id'\t# Defaults to name + _id\n\n```\n\n### Using factories\nCoffeescript:\n```coffee\nFactory.build 'user', (user) ->\n\t# user is an unsaved user model\n\nFactory.build 'user', name:\"New\", (user) ->\n\t# user is an unsaved user model with name \"New\"\n\nFactory.build 'post', (post) ->\n\t# post is an unsaved post model\n\t# post.user is a saved associated user model\n\t# post has new attribute 'user_id' with the user's id\n\nFactory.create 'user', (user) -> \n\t# User is SAVED model\n\n```\n\n### Associations\nCoffeescript:\n```coffee\nFactory.define 'post',\n\tmodel: Model\n\tassociations:\n\t\tuser:\n\t\t\t# Defaults to association name (user here)\n\t\t\tfactory: 'user'\t\n\t\t\t\n\t\t\t# Defaults to name + _id\n\t\t\tkey: 'user_id'\t\n\t\t\t\n\t\t\t# Gets foreign key from associated model\n\t\t\t# Default getter, just grabs id\n\t\t\tgetter: (assocObj) -> return assocObj.id  \n\t\t\t\n\t\t\t# Sets foreign key on factory's built model\n\t\t\t# Default setter (pseudocode - uses 'key' from above if setter not overridden)\n\t\t\tsetter: (obj, val) -> obj.set {{key}}, val\n\t\t\t\n\t\t\t # Conveniently provides default setters/getters\n\t\t\ttype: 'id' # Currently supported: \"id\", \"ids[]\"\n\t\t\t# Using type: \"ids[]\" provides a default setter than inserts id into object's array of ids\n\n\n# Id-array associations\n# This will generate a message model with:\n# user_ids: [id1, id2]\n# as well as user models attached directly at msg.to , msg.from\nFactory.define 'message',\n\tmodel: MessageModel\n\tattributes:\n\t\ttitle: \"Hello World\"\n\tassociations:\n\t\tfrom:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n\t\tto:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n```\n\n### Custom Factories\nCoffeescript: \n```coffee\n# Custom factories can be defined with a function\nFactory.define 'two users and a random number', (callback) ->\n\tFactory.create 'user', (user1) ->\n\t\tFactory.create 'user', (user2) ->\n\n\t\t\trandomNum = ~~(Math.random()*10)\n\t\t\tcallback(user1, user2, randomNum)\n\n# Using it:\nFactory.create 'two users and a random number', (user1, user2, randomNum) ->\n\n# Custom attributes will be passed through to \n# custom factories after callback parameter:\nFactory.define 'helloworld', (callback, options) ->\n\tdata = \"Hello World\"\n\tif options?.caps\n\t\treturn callback(data.toUpperCase())\n\n\tcallback(data)\n\nFactory.create 'helloworld', (string) -> # string == 'Hello World'\nFactory.create 'helloworld', caps:true, (string) -> # string == 'HELLO WORLD'\n```\n\n### Getting attributes with attributesFor\nCoffeescript:\n```coffee\n# Get raw object of attributes\nFactory.attributesFor 'user', (attrs) ->\n\n# Specify some options\nFactory.attributesFor 'user', name: \"Bob\", (attrs) ->\n\n```\n\n\n## License\n\nWTFPL v2\n","readmeFilename":"README.md","_id":"factory-castrado@0.0.7","dist":{"shasum":"f680b295ebdb65c2acf5844bcbf2a59ecacc1747","tarball":"https://registry.npmjs.org/factory-castrado/-/factory-castrado-0.0.7.tgz","integrity":"sha512-vXesePpZ15c9sOUTdkfET1TiPiXHbFfHHzFWFX/EsLDBHr1c2uxZPqDX/M+fo+9WTKp3725OtUMg9nWWObGDWA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEfIDzZv7zOtBZPr4QdxAIV/eM4uQW/EddA22J7sZK5rAiBnD3HBbaWubjiKj0Gu91XBPwhtiOoTdkKIxpe4A+bvsQ=="}]},"_from":".","_npmVersion":"1.2.17","_npmUser":{"name":"davidgovea","email":"govea.d@gmail.com"},"maintainers":[{"name":"davidgovea","email":"govea.d@gmail.com"}]},"0.0.8":{"name":"factory-castrado","version":"0.0.8","description":"Node.js library for generating test data with factories. Inspired by factory_girl","keywords":[],"author":{"name":"David Govea","email":"govea.d@gmail.com"},"main":"index","engines":{"node":">= 0.4.x"},"scripts":{"test":"make test","prepublish":"make test && make build"},"dependencies":{"lodash":"~1.1.1"},"devDependencies":{"coffee-script":">= 1.6.0","mocha":">= 0.11.0","should":">= 0.5.1","backbone":"~1.0.0"},"readme":"# factory-castrado\n[![Build Status](https://travis-ci.org/davidgovea/factory-castrado.png)](https://travis-ci.org/davidgovea/factory-castrado)\n\nFactory Castrado is a library for Node.js which provides factories for objects creation. It is designed for use with Backbone-style models which use ```new Model(attributes)``` for initialization and ```model.create(function(err, model){...})``` for saving.  \n  \nIt is highly inspired by:\n- [factory_girl](https://github.com/thoughtbot/factory_girl) - ruby\n- [factory-lady](https://github.com/petejkim/factory-lady) - node.js\n- [factory-boy](https://github.com/kbackowski/factory-boy) - node.js\n\n## Installation\n\nNode.js:\n\n```\nnpm install factory-castrado\n```\n\n## Usage\n\n### Defining factories\nCoffeescript:\n```coffee\nFactory\t= require 'factory-castrado'\nModel\t= require('backbone').Model\n\ncounter = 1\n\n# Define with (name, model, attributes)\nFactory.define 'user', Model, \n\temail: (cb) -> cb(\"user#{counter++}@test.com\")\n\tname: \"Test name\"\n\tpassword: 'abc123'\n\n# With associations, using (name, options):\nFactory.define 'post',\n\tmodel: Model\n\tattributes:\n\t\ttitle: \"Test title\"\n\t\tcontent: \"Test content\"\n\tassociations:\n\t\tuser:\n\t\t\tfactory: 'user'\t# Defaults to association name (user here)\n\t\t\tkey: 'user_id'\t# Defaults to name + _id\n\n```\n\n### Using factories\nCoffeescript:\n```coffee\nFactory.build 'user', (user) ->\n\t# user is an unsaved user model\n\nFactory.build 'user', name:\"New\", (user) ->\n\t# user is an unsaved user model with name \"New\"\n\nFactory.build 'post', (post) ->\n\t# post is an unsaved post model\n\t# post.user is a saved associated user model\n\t# post has new attribute 'user_id' with the user's id\n\nFactory.create 'user', (user) -> \n\t# User is SAVED model\n\n```\n\n### Associations\nCoffeescript:\n```coffee\nFactory.define 'post',\n\tmodel: Model\n\tassociations:\n\t\tuser:\n\t\t\t# Defaults to association name (user here)\n\t\t\tfactory: 'user'\t\n\t\t\t\n\t\t\t# Defaults to name + _id\n\t\t\tkey: 'user_id'\t\n\t\t\t\n\t\t\t# Gets foreign key from associated model\n\t\t\t# Default getter, just grabs id\n\t\t\tgetter: (assocObj) -> return assocObj.id  \n\t\t\t\n\t\t\t# Sets foreign key on factory's built model\n\t\t\t# Default setter (pseudocode - uses 'key' from above if setter not overridden)\n\t\t\tsetter: (obj, val) -> obj.set {{key}}, val\n\t\t\t\n\t\t\t # Conveniently provides default setters/getters\n\t\t\ttype: 'id' # Currently supported: \"id\", \"ids[]\"\n\t\t\t# Using type: \"ids[]\" provides a default setter than inserts id into object's array of ids\n\n\n# Id-array associations\n# This will generate a message model with:\n# user_ids: [id1, id2]\n# as well as user models attached directly at msg.to , msg.from\nFactory.define 'message',\n\tmodel: MessageModel\n\tattributes:\n\t\ttitle: \"Hello World\"\n\tassociations:\n\t\tfrom:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n\t\tto:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n```\n\n### Custom Factories\nCoffeescript: \n```coffee\n# Custom factories can be defined with a function\nFactory.define 'two users and a random number', (callback) ->\n\tFactory.create 'user', (user1) ->\n\t\tFactory.create 'user', (user2) ->\n\n\t\t\trandomNum = ~~(Math.random()*10)\n\t\t\tcallback(user1, user2, randomNum)\n\n# Using it:\nFactory.create 'two users and a random number', (user1, user2, randomNum) ->\n\n# Custom attributes will be passed through to \n# custom factories after callback parameter:\nFactory.define 'helloworld', (callback, options) ->\n\tdata = \"Hello World\"\n\tif options?.caps\n\t\treturn callback(data.toUpperCase())\n\n\tcallback(data)\n\nFactory.create 'helloworld', (string) -> # string == 'Hello World'\nFactory.create 'helloworld', caps:true, (string) -> # string == 'HELLO WORLD'\n```\n\n### Getting attributes with attributesFor\nCoffeescript:\n```coffee\n# Get raw object of attributes\nFactory.attributesFor 'user', (attrs) ->\n\n# Specify some options\nFactory.attributesFor 'user', name: \"Bob\", (attrs) ->\n\n```\n\n\n## License\n\nWTFPL v2\n","readmeFilename":"README.md","_id":"factory-castrado@0.0.8","dist":{"shasum":"b27f7c3792f8c05b211b541f15e405e7649b1cca","tarball":"https://registry.npmjs.org/factory-castrado/-/factory-castrado-0.0.8.tgz","integrity":"sha512-sa0YTPpzs9W/mMrKXr85yijndeg4DKdrTTWUJmBbvs9sfbE+Oauh4DNIDHEWLSk7EC2M6Q7zxJ463bjTQOvXuA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC4LEExKdlckL+bgnZjR3htEwy6x8xIMc0OCh6qPpLVUAiEA4iqf8n6GHNT2koq0EdE8ysCUY8amCOk11Z+Ee7L/HYU="}]},"_from":".","_npmVersion":"1.2.17","_npmUser":{"name":"davidgovea","email":"govea.d@gmail.com"},"maintainers":[{"name":"davidgovea","email":"govea.d@gmail.com"}]},"0.0.9":{"name":"factory-castrado","version":"0.0.9","description":"Node.js library for generating test data with factories. Inspired by factory_girl","keywords":[],"author":{"name":"David Govea","email":"govea.d@gmail.com"},"main":"index","engines":{"node":">= 0.4.x"},"scripts":{"test":"make test","prepublish":"make test && make build"},"dependencies":{"lodash":"~1.1.1"},"devDependencies":{"coffee-script":">= 1.6.0","mocha":">= 0.11.0","should":">= 0.5.1","backbone":"~1.0.0"},"readme":"# factory-castrado\n[![Build Status](https://travis-ci.org/davidgovea/factory-castrado.png)](https://travis-ci.org/davidgovea/factory-castrado)\n\nFactory Castrado is a library for Node.js which provides factories for objects creation. It is designed for use with Backbone-style models which use ```new Model(attributes)``` for initialization and ```model.create(function(err, model){...})``` for saving.\n\nIt is highly inspired by:\n- [factory_girl](https://github.com/thoughtbot/factory_girl) - ruby\n- [factory-lady](https://github.com/petejkim/factory-lady) - node.js\n- [factory-boy](https://github.com/kbackowski/factory-boy) - node.js\n\n## Installation\n\nNode.js:\n\n```\nnpm install factory-castrado\n```\n\n## Usage\n\n### Defining factories\nCoffeescript:\n```coffee\nFactory\t= require 'factory-castrado'\nModel\t= require('backbone').Model\n\nclass Session\n\tcreate: (callback) ->\n\t\tcallback()\n\ncounter = 1\n\n# Define using non Backbone model\nFactory.define 'session', Session,\n\tid: (cb) -> cb(Math.random())\n\n# Define with (name, model, attributes)\nFactory.define 'user', Model,\n\temail: (cb) -> cb(\"user#{counter++}@test.com\")\n\tname: \"Test name\"\n\tpassword: 'abc123'\n\n# With associations, using (name, options):\nFactory.define 'post',\n\tmodel: Model\n\tattributes:\n\t\ttitle: \"Test title\"\n\t\tcontent: \"Test content\"\n\tassociations:\n\t\tuser:\n\t\t\tfactory: 'user'\t# Defaults to association name (user here)\n\t\t\tkey: 'user_id'\t# Defaults to name + _id\n\n```\n\n### Using factories\nCoffeescript:\n```coffee\nFactory.build 'user', (user) ->\n\t# user is an unsaved user model\n\nFactory.build 'user', name:\"New\", (user) ->\n\t# user is an unsaved user model with name \"New\"\n\nFactory.build 'post', (post) ->\n\t# post is an unsaved post model\n\t# post.user is a saved associated user model\n\t# post has new attribute 'user_id' with the user's id\n\nFactory.create 'user', (user) ->\n\t# User is SAVED model\n\n```\n\n### Associations\nCoffeescript:\n```coffee\nFactory.define 'post',\n\tmodel: Model\n\tassociations:\n\t\tuser:\n\t\t\t# Defaults to association name (user here)\n\t\t\tfactory: 'user'\n\n\t\t\t# Defaults to name + _id\n\t\t\tkey: 'user_id'\n\n\t\t\t# Gets foreign key from associated model\n\t\t\t# Default getter, just grabs id\n\t\t\tgetter: (assocObj) -> return assocObj.id\n\n\t\t\t# Sets foreign key on factory's built model\n\t\t\t# Default setter (pseudocode - uses 'key' from above if setter not overridden)\n\t\t\tsetter: (obj, val) -> obj.set {{key}}, val\n\n\t\t\t # Conveniently provides default setters/getters\n\t\t\ttype: 'id' # Currently supported: \"id\", \"ids[]\"\n\t\t\t# Using type: \"ids[]\" provides a default setter than inserts id into object's array of ids\n\n\n# Id-array associations\n# This will generate a message model with:\n# user_ids: [id1, id2]\n# as well as user models attached directly at msg.to , msg.from\nFactory.define 'message',\n\tmodel: MessageModel\n\tattributes:\n\t\ttitle: \"Hello World\"\n\tassociations:\n\t\tfrom:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n\t\tto:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n```\n\n### Custom Factories\nCoffeescript:\n```coffee\n# Custom factories can be defined with a function\nFactory.define 'two users and a random number', (callback) ->\n\tFactory.create 'user', (user1) ->\n\t\tFactory.create 'user', (user2) ->\n\n\t\t\trandomNum = ~~(Math.random()*10)\n\t\t\tcallback(user1, user2, randomNum)\n\n# Using it:\nFactory.create 'two users and a random number', (user1, user2, randomNum) ->\n\n# Custom attributes will be passed through to\n# custom factories after callback parameter:\nFactory.define 'helloworld', (callback, options) ->\n\tdata = \"Hello World\"\n\tif options?.caps\n\t\treturn callback(data.toUpperCase())\n\n\tcallback(data)\n\nFactory.create 'helloworld', (string) -> # string == 'Hello World'\nFactory.create 'helloworld', caps:true, (string) -> # string == 'HELLO WORLD'\n```\n\n### Getting attributes with attributesFor\nCoffeescript:\n```coffee\n# Get raw object of attributes\nFactory.attributesFor 'user', (attrs) ->\n\n# Specify some options\nFactory.attributesFor 'user', name: \"Bob\", (attrs) ->\n\n```\n\n\n## License\n\nWTFPL v2\n","readmeFilename":"README.md","_id":"factory-castrado@0.0.9","dist":{"shasum":"32c52104304284433521e5c19b6b9abcc95a5b34","tarball":"https://registry.npmjs.org/factory-castrado/-/factory-castrado-0.0.9.tgz","integrity":"sha512-g6EzV+aJy8B43ghUmpAP3RBXCnoRov+E0YzMkJ8iDGpDMhTcj4fHtV4MeHsmeH4h5e00KfHequpmvoHcSzy4Ug==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC3tvWC3MuJBTfA5BpMDbRawOrqzeDhJPrQSOCqe10n/gIgNHgnIuybMV8VHXWhtKDYKk50HbO84BemM/fWU+cwyX4="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"davidgovea","email":"govea.d@gmail.com"},"maintainers":[{"name":"davidgovea","email":"govea.d@gmail.com"}]},"0.0.10":{"name":"factory-castrado","version":"0.0.10","description":"Node.js library for generating test data with factories. Inspired by factory_girl","keywords":[],"author":{"name":"David Govea","email":"govea.d@gmail.com"},"main":"index","engines":{"node":">= 0.4.x"},"scripts":{"test":"make test","prepublish":"make test && make build"},"dependencies":{"lodash":"~1.1.1"},"devDependencies":{"coffee-script":">= 1.6.0","mocha":">= 0.11.0","should":">= 0.5.1","backbone":"~1.0.0"},"readme":"# factory-castrado\n[![Build Status](https://travis-ci.org/davidgovea/factory-castrado.png)](https://travis-ci.org/davidgovea/factory-castrado)\n\nFactory Castrado is a library for Node.js which provides factories for objects creation. It is designed for use with Backbone-style models which use ```new Model(attributes)``` for initialization and ```model.create(function(err, model){...})``` for saving.\n\nIt is highly inspired by:\n- [factory_girl](https://github.com/thoughtbot/factory_girl) - ruby\n- [factory-lady](https://github.com/petejkim/factory-lady) - node.js\n- [factory-boy](https://github.com/kbackowski/factory-boy) - node.js\n\n## Installation\n\nNode.js:\n\n```\nnpm install factory-castrado\n```\n\n## Usage\n\n### Defining factories\nCoffeescript:\n```coffee\nFactory\t= require 'factory-castrado'\nModel\t= require('backbone').Model\n\nclass Session\n\tcreate: (callback) ->\n\t\tcallback()\n\ncounter = 1\n\n# Define using non Backbone model\nFactory.define 'session', Session,\n\tid: (cb) -> cb(Math.random())\n\n# Define with (name, model, attributes)\nFactory.define 'user', Model,\n\temail: (cb) -> cb(\"user#{counter++}@test.com\")\n\tname: \"Test name\"\n\tpassword: 'abc123'\n\n# With associations, using (name, options):\nFactory.define 'post',\n\tmodel: Model\n\tattributes:\n\t\ttitle: \"Test title\"\n\t\tcontent: \"Test content\"\n\tassociations:\n\t\tuser:\n\t\t\tfactory: 'user'\t# Defaults to association name (user here)\n\t\t\tkey: 'user_id'\t# Defaults to name + _id\n\n```\n\n### Using factories\nCoffeescript:\n```coffee\nFactory.build 'user', (user) ->\n\t# user is an unsaved user model\n\nFactory.build 'user', name:\"New\", (user) ->\n\t# user is an unsaved user model with name \"New\"\n\nFactory.build 'post', (post) ->\n\t# post is an unsaved post model\n\t# post.user is a saved associated user model\n\t# post has new attribute 'user_id' with the user's id\n\nFactory.create 'user', (user) ->\n\t# User is SAVED model\n\n```\n\n### Associations\nCoffeescript:\n```coffee\nFactory.define 'post',\n\tmodel: Model\n\tassociations:\n\t\tuser:\n\t\t\t# Defaults to association name (user here)\n\t\t\tfactory: 'user'\n\n\t\t\t# Defaults to name + _id\n\t\t\tkey: 'user_id'\n\n\t\t\t# Gets foreign key from associated model\n\t\t\t# Default getter, just grabs id\n\t\t\tgetter: (assocObj) -> return assocObj.id\n\n\t\t\t# Sets foreign key on factory's built model\n\t\t\t# Default setter (pseudocode - uses 'key' from above if setter not overridden)\n\t\t\tsetter: (obj, val) -> obj.set {{key}}, val\n\n\t\t\t # Conveniently provides default setters/getters\n\t\t\ttype: 'id' # Currently supported: \"id\", \"ids[]\"\n\t\t\t# Using type: \"ids[]\" provides a default setter than inserts id into object's array of ids\n\n\n# Id-array associations\n# This will generate a message model with:\n# user_ids: [id1, id2]\n# as well as user models attached directly at msg.to , msg.from\nFactory.define 'message',\n\tmodel: MessageModel\n\tattributes:\n\t\ttitle: \"Hello World\"\n\tassociations:\n\t\tfrom:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n\t\tto:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n```\n\n### Custom Factories\nCoffeescript:\n```coffee\n# Custom factories can be defined with a function\nFactory.define 'two users and a random number', (callback) ->\n\tFactory.create 'user', (user1) ->\n\t\tFactory.create 'user', (user2) ->\n\n\t\t\trandomNum = ~~(Math.random()*10)\n\t\t\tcallback(user1, user2, randomNum)\n\n# Using it:\nFactory.create 'two users and a random number', (user1, user2, randomNum) ->\n\n# Custom attributes will be passed through to\n# custom factories after callback parameter:\nFactory.define 'helloworld', (callback, options) ->\n\tdata = \"Hello World\"\n\tif options?.caps\n\t\treturn callback(data.toUpperCase())\n\n\tcallback(data)\n\nFactory.create 'helloworld', (string) -> # string == 'Hello World'\nFactory.create 'helloworld', caps:true, (string) -> # string == 'HELLO WORLD'\n```\n\n### Getting attributes with attributesFor\nCoffeescript:\n```coffee\n# Get raw object of attributes\nFactory.attributesFor 'user', (attrs) ->\n\n# Specify some options\nFactory.attributesFor 'user', name: \"Bob\", (attrs) ->\n\n```\n\n\n## License\n\nWTFPL v2\n","readmeFilename":"README.md","_id":"factory-castrado@0.0.10","dist":{"shasum":"256a7b9dc48bd40b1787225991fde844db806662","tarball":"https://registry.npmjs.org/factory-castrado/-/factory-castrado-0.0.10.tgz","integrity":"sha512-Jig5jACwpKJThAwUqCqTp7ViFPqwL6E0Fhv79sTpi9x9WNNSidKRjrkahEIbrEZjwhomP8z6zZR+hmNYtGQipg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCuz/tEJdbrYa0ZVZ1M+DfDkLqgPqZeya1NesmWwMJeQQIgFjYPRvve0UuBBs/+UkGlKiWAKSzPO6YsPhnIyXXxNaQ="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"davidgovea","email":"govea.d@gmail.com"},"maintainers":[{"name":"davidgovea","email":"govea.d@gmail.com"}]},"0.0.11":{"name":"factory-castrado","version":"0.0.11","description":"Node.js library for generating test data with factories. Inspired by factory_girl","keywords":[],"author":{"name":"David Govea","email":"govea.d@gmail.com"},"main":"index","engines":{"node":">= 0.4.x"},"scripts":{"test":"make test","prepublish":"make test && make build"},"dependencies":{"lodash":"~1.1.1"},"devDependencies":{"coffee-script":">= 1.6.0","mocha":">= 0.11.0","should":">= 0.5.1","backbone":"~1.0.0"},"readme":"# factory-castrado\n[![Build Status](https://travis-ci.org/davidgovea/factory-castrado.png)](https://travis-ci.org/davidgovea/factory-castrado)\n\nFactory Castrado is a library for Node.js which provides factories for objects creation. It is designed for use with Backbone-style models which use ```new Model(attributes)``` for initialization and ```model.create(function(err, model){...})``` for saving.\n\nIt is highly inspired by:\n- [factory_girl](https://github.com/thoughtbot/factory_girl) - ruby\n- [factory-lady](https://github.com/petejkim/factory-lady) - node.js\n- [factory-boy](https://github.com/kbackowski/factory-boy) - node.js\n\n## Installation\n\nNode.js:\n\n```\nnpm install factory-castrado\n```\n\n## Usage\n\n### Model requirements\nCoffeescript:\n```coffee\n# factory-castrado puts only one requirement on models: \n# they *must be constructor functions* that accept an attributes object.\n# Your model must be comply with:\nmodel = new Model(attributes)\n\n# In order to save to model to a database during Factory.create, \n# factory-castrado uses \"model.create (err, model) ->\"\nModel::create = (done) ->\n\t# ...Insert into db...\n\tdone(error, this)\n\n# If no create method is found, the model is passed back without saving.\n\n# If a non-backbone object is given for a factory's models,\n# the model.get() and model.set() methods are shimmed.\n\n```\n\n### Defining factories\nCoffeescript:\n```coffee\nFactory\t\t= require 'factory-castrado'\nModel\t\t= require('backbone').Model\nPlainModel\t= class extends Object # Bare object\n\ncounter = 1\n\n# Define with (name, model, attributes)\nFactory.define 'user', Model,\n\temail: (cb) -> cb(\"user#{counter++}@test.com\")\n\tname: \"Test name\"\n\tpassword: 'abc123'\n\n# With associations, using (name, options):\nFactory.define 'post',\n\tmodel: Model\n\tattributes:\n\t\ttitle: \"Test title\"\n\t\tcontent: \"Test content\"\n\tassociations:\n\t\tuser:\t\t\t\t# This creates an embedded post.user object, and a user_id attribute\n\t\t\tfactory: 'user'\t# Defaults to association name (user here)\n\t\t\tkey: 'user_id'\t# Defaults to name + _id\n\n# Non-Backbone objects work the same:\n# NOTE: factory-castrado shims model.get() and model.set() methods\nFactory.define 'session', PlainModel,\n\tid: (cb) -> cb(Math.random())\n\texpires: (cb) -> cb (require 'moment')().add('days', 7).toDate()\n\nFactory.define 'plainUser',\n\tmodel: PlainModel,\n\tattributes:\n\t\tname: \"Test\"\n\tassociations:\n\t\tsession:\t\t\t\t\n\t\t\tfactory: 'session'\t# Attaches embedded user.session\n\t\t\tkey: 'session_id'\t# Attaches user.session_id foreign key\n\n\t\t\t# On a backbone-style model, the foreign key would be in \n\t\t\t# the model's attributes hash, accessed using user.get('session_id')\n\n```\n\n### Using factories\nCoffeescript:\n```coffee\nFactory.build 'user', (user) ->\n\t# user is an unsaved user model\n\nFactory.build 'user', name:\"New\", (user) ->\n\t# user is an unsaved user model with name \"New\"\n\nFactory.build 'post', (post) ->\n\t# post is an unsaved post model\n\t# post.user is a saved associated user model\n\t# post has new attribute 'user_id' with the user's id\n\nFactory.create 'user', (user) ->\n\t# User is SAVED model\n\n```\n\n### Associations\nCoffeescript:\n```coffee\nFactory.define 'post',\n\tmodel: Model\n\tassociations:\n\t\tuser:\n\t\t\t# Defaults to association name (user here)\n\t\t\tfactory: 'user'\n\n\t\t\t# Defaults to name + _id\n\t\t\tkey: 'user_id'\n\n\t\t\t# Gets foreign key from associated model\n\t\t\t# Default getter, just grabs id\n\t\t\tgetter: (assocObj) -> return assocObj.id\n\n\t\t\t# Sets foreign key on factory's built model\n\t\t\t# Default setter (pseudocode - uses 'key' from above if setter not overridden)\n\t\t\tsetter: (obj, val) -> obj.set {{key}}, val\n\n\t\t\t # Conveniently provides default setters/getters\n\t\t\ttype: 'id' # Currently supported: \"id\", \"ids[]\"\n\t\t\t# Using type: \"ids[]\" provides a default setter than inserts id into object's array of ids\n\n\n# Id-array associations\n# This will generate a message model with:\n# user_ids: [id1, id2]\n# as well as user models attached directly at msg.to , msg.from\nFactory.define 'message',\n\tmodel: MessageModel\n\tattributes:\n\t\ttitle: \"Hello World\"\n\tassociations:\n\t\tfrom:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n\t\tto:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n```\n\n### Custom Factories\nCoffeescript:\n```coffee\n# Custom factories can be defined with a function\nFactory.define 'two users and a random number', (callback) ->\n\tFactory.create 'user', (user1) ->\n\t\tFactory.create 'user', (user2) ->\n\n\t\t\trandomNum = ~~(Math.random()*10)\n\t\t\tcallback(user1, user2, randomNum)\n\n# Using it:\nFactory.create 'two users and a random number', (user1, user2, randomNum) ->\n\n# Custom attributes will be passed through to\n# custom factories after callback parameter:\nFactory.define 'helloworld', (callback, options) ->\n\tdata = \"Hello World\"\n\tif options?.caps\n\t\treturn callback(data.toUpperCase())\n\n\tcallback(data)\n\nFactory.create 'helloworld', (string) -> # string == 'Hello World'\nFactory.create 'helloworld', caps:true, (string) -> # string == 'HELLO WORLD'\n```\n\n### Getting attributes with attributesFor\nCoffeescript:\n```coffee\n# Get raw object of attributes\nFactory.attributesFor 'user', (attrs) ->\n\n# Specify some options\nFactory.attributesFor 'user', name: \"Bob\", (attrs) ->\n\n```\n\n\n## License\n\nWTFPL v2\n","readmeFilename":"README.md","_id":"factory-castrado@0.0.11","dist":{"shasum":"689bfbffac512106620a4fcc32862765f132285c","tarball":"https://registry.npmjs.org/factory-castrado/-/factory-castrado-0.0.11.tgz","integrity":"sha512-LQPSbsIVPEOOWLgAjdBKkE1PzUjnstvMCMbKD+RfaC/BoiaSVjalaY4gYVFsg4TkOTiAUpwd8kz8jvOuC+4HIg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDwjLZvXWICXmBzXBMF8Qm0+kFYI3ir4Mn8zXF/gruVjgIgNGQP6VhjNvZyldndHqbr7AQEmRZBoakpbKHPzEc4Vws="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"davidgovea","email":"govea.d@gmail.com"},"maintainers":[{"name":"davidgovea","email":"govea.d@gmail.com"}]},"0.0.12":{"name":"factory-castrado","version":"0.0.12","description":"Node.js library for generating test data with factories. Inspired by factory_girl","keywords":["factory","test","testing","data","bdd","tdd","fixture","mock","mocking"],"author":{"name":"David Govea","email":"govea.d@gmail.com"},"repository":{"type":"git","url":"https://github.com/davidgovea/factory-castrado"},"main":"index","engines":{"node":">= 0.4.x"},"scripts":{"test":"make test","prepublish":"make test && make build"},"dependencies":{"lodash":"~1.1.1"},"devDependencies":{"coffee-script":">= 1.6.0","mocha":">= 0.11.0","should":">= 0.5.1","backbone":"~1.0.0"},"readme":"# factory-castrado\n[![Build Status](https://travis-ci.org/davidgovea/factory-castrado.png)](https://travis-ci.org/davidgovea/factory-castrado)\n\nFactory Castrado is a library for Node.js which provides factories for objects creation. It is designed for use with Backbone-style models which use ```new Model(attributes)``` for initialization and ```model.create(function(err, model){...})``` for saving.\n\nIt is highly inspired by:\n- [factory_girl](https://github.com/thoughtbot/factory_girl) - ruby\n- [factory-lady](https://github.com/petejkim/factory-lady) - node.js\n- [factory-boy](https://github.com/kbackowski/factory-boy) - node.js\n\n## Installation\n\nNode.js:\n\n```\nnpm install factory-castrado\n```\n\n## Usage\n\n### Model requirements\nCoffeescript:\n```coffee\n# factory-castrado puts only one requirement on models: \n# they *must be constructor functions* that accept an attributes object.\n# Your model must be comply with:\nmodel = new Model(attributes)\n\n# In order to save to model to a database during Factory.create, \n# factory-castrado uses \"model.create (err, model) ->\"\nModel::create = (done) ->\n\t# ...Insert into db...\n\tdone(error, this)\n\n# If no create method is found, the model is passed back without saving.\n\n# If a non-backbone object is given for a factory's models,\n# the model.get() and model.set() methods are shimmed.\n\n```\n\n### Defining factories\nCoffeescript:\n```coffee\nFactory\t\t= require 'factory-castrado'\nModel\t\t= require('backbone').Model\nPlainModel\t= class extends Object # Bare object\n\ncounter = 1\n\n# Define with (name, model, attributes)\nFactory.define 'user', Model,\n\temail: (cb) -> cb(\"user#{counter++}@test.com\")\n\tname: \"Test name\"\n\tpassword: 'abc123'\n\n# With associations, using (name, options):\nFactory.define 'post',\n\tmodel: Model\n\tattributes:\n\t\ttitle: \"Test title\"\n\t\tcontent: \"Test content\"\n\tassociations:\n\t\tuser:\t\t\t\t# This creates an embedded post.user object, and a user_id attribute\n\t\t\tfactory: 'user'\t# Defaults to association name (user here)\n\t\t\tkey: 'user_id'\t# Defaults to name + _id\n\n# Non-Backbone objects work the same:\n# NOTE: factory-castrado shims model.get() and model.set() methods\nFactory.define 'session', PlainModel,\n\tid: (cb) -> cb(Math.random())\n\texpires: (cb) -> cb (require 'moment')().add('days', 7).toDate()\n\nFactory.define 'plainUser',\n\tmodel: PlainModel,\n\tattributes:\n\t\tname: \"Test\"\n\tassociations:\n\t\tsession:\t\t\t\t\n\t\t\tfactory: 'session'\t# Attaches embedded user.session\n\t\t\tkey: 'session_id'\t# Attaches user.session_id foreign key\n\n\t\t\t# On a backbone-style model, the foreign key would be in \n\t\t\t# the model's attributes hash, accessed using user.get('session_id')\n\n```\n\n### Using factories\nCoffeescript:\n```coffee\nFactory.build 'user', (user) -> # (err, user) -> Also supported\n\t# user is an unsaved user model\n\nFactory.build 'user', name:\"New\", (user) ->\n\t# user is an unsaved user model with name \"New\"\n\nFactory.build 'post', (post) ->\n\t# post is an unsaved post model\n\t# post.user is a saved associated user model\n\t# post has new attribute 'user_id' with the user's id\n\nFactory.create 'user', (user) -> # (err, user) -> Also supported\n\t# User is SAVED model\n\n# A note about Error-first callbacks:\n# factory-castrado checks the callback's arity to determine\n# if it is an error-first callback. These are both supported:\nFactory.create 'user', (err, user) ->\nFactory.create 'user', (user) -> # Don't care about the error\n\n# However, this will NOT work:\nFactory.create 'user', (err) -> # DOES NOT WORK - argument will be user, not err.\n\n```\n\n### Associations\nCoffeescript:\n```coffee\nFactory.define 'post',\n\tmodel: Model\n\tassociations:\n\t\tuser:\n\t\t\t# Defaults to association name (user here)\n\t\t\tfactory: 'user'\n\n\t\t\t# Defaults to name + _id\n\t\t\tkey: 'user_id'\n\n\t\t\t# Gets foreign key from associated model\n\t\t\t# Default getter, just grabs id\n\t\t\tgetter: (assocObj) -> return assocObj.id\n\n\t\t\t# Sets foreign key on factory's built model\n\t\t\t# Default setter (pseudocode - uses 'key' from above if setter not overridden)\n\t\t\tsetter: (obj, val) -> obj.set {{key}}, val\n\n\t\t\t # Conveniently provides default setters/getters\n\t\t\ttype: 'id' # Currently supported: \"id\", \"ids[]\"\n\t\t\t# Using type: \"ids[]\" provides a default setter than inserts id into object's array of ids\n\n\n# Id-array associations\n# This will generate a message model with:\n# user_ids: [id1, id2]\n# as well as user models attached directly at msg.to , msg.from\nFactory.define 'message',\n\tmodel: MessageModel\n\tattributes:\n\t\ttitle: \"Hello World\"\n\tassociations:\n\t\tfrom:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n\t\tto:\n\t\t\tfactory: 'user'\n\t\t\tkey: 'user_ids'\n\t\t\ttype: 'ids[]'\n```\n\n### Custom Factories\nCoffeescript:\n```coffee\n# Custom factories can be defined with a function\nFactory.define 'two users and a random number', (callback) ->\n\tFactory.create 'user', (user1) ->\n\t\tFactory.create 'user', (user2) ->\n\n\t\t\trandomNum = ~~(Math.random()*10)\n\t\t\tcallback(user1, user2, randomNum)\n\n# Using it:\nFactory.create 'two users and a random number', (user1, user2, randomNum) ->\n\n# Custom attributes will be passed through to\n# custom factories after callback parameter:\nFactory.define 'helloworld', (callback, options) ->\n\tdata = \"Hello World\"\n\tif options?.caps\n\t\treturn callback(data.toUpperCase())\n\n\tcallback(data)\n\nFactory.create 'helloworld', (string) -> # string == 'Hello World'\nFactory.create 'helloworld', caps:true, (string) -> # string == 'HELLO WORLD'\n```\n\n### Getting attributes with attributesFor\nCoffeescript:\n```coffee\n# Get raw object of attributes\nFactory.attributesFor 'user', (attrs) ->\n\n# Specify some options\nFactory.attributesFor 'user', name: \"Bob\", (attrs) ->\n\n```\n\n\n## License\n\nWTFPL v2\n","readmeFilename":"README.md","_id":"factory-castrado@0.0.12","dist":{"shasum":"3c57a14ca0410efc7a1ac31ae7fbcec07c3243b7","tarball":"https://registry.npmjs.org/factory-castrado/-/factory-castrado-0.0.12.tgz","integrity":"sha512-jCJblpDXzKJMga64GAYWxEMkz6nOqpRSqWBZ57Dikfl4wjyRzc2ua+NI9/tsaBK1SeKHN7PZYYGdRSmGbFScfA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC7FDKT5uh2x7MyxOqI7j7rpdFOv+bmctjCAhOpI1+SIwIhAI2AaGwofb8uLSeQotdfG5B6eazo3/MwX1OJAqyac9Bi"}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"davidgovea","email":"govea.d@gmail.com"},"maintainers":[{"name":"davidgovea","email":"govea.d@gmail.com"}]}},"readme":"# factory-castrado\n[![Build Status](https://travis-ci.org/davidgovea/factory-castrado.png)](https://travis-ci.org/davidgovea/factory-castrado)\n\nFactory Castrado is a library for Node.js which provides factories for objects creation. It is designed for use with Backbone-style models which use ```new Model(attributes)``` for initialization and ```model.create(function(err, model){...})``` for saving.  \n  \nIt is highly inspired by:\n- [factory_girl](https://github.com/thoughtbot/factory_girl) - ruby\n- [factory-lady](https://github.com/petejkim/factory-lady) - node.js\n- [factory-boy](https://github.com/kbackowski/factory-boy) - node.js\n\n## Installation\n\nNode.js:\n\n```\nnpm install factory-castrado\n```\n\n## Usage\n\n### Defining factories\nCoffeescript:\n```coffee\nFactory\t= require 'factory-castrado'\nModel\t= require('backbone').Model\n\ncounter = 1\n\n# Define with (name, model, attributes)\nFactory.define 'user', Model, \n\temail: (cb) -> cb(\"user#{counter++}@test.com\")\n\tname: \"Test name\"\n\tpassword: 'abc123'\n\n# With associations, using (name, options):\nFactory.define 'post',\n\tmodel: Model\n\tattributes:\n\t\ttitle: \"Test title\"\n\t\tcontent: \"Test content\"\n\tassociations:\n\t\tuser:\n\t\t\tfactory: 'user'\t# Defaults to association name (user here)\n\t\t\tkey: 'user_id'\t# Defaults to name + _id\n\n```\n\n### Using factories\nCoffeescript:\n```coffee\nFactory.build 'user', (user) ->\n\t# user is an unsaved user model\n\nFactory.build 'user', name:\"New\", (user) ->\n\t# user is an unsaved user model with name \"New\"\n\nFactory.build 'post', (post) ->\n\t# post is an unsaved post model\n\t# post.user is a saved associated user model\n\t# post has new attribute 'user_id' with the user's id\n\nFactory.create 'user', (user) -> \n\t# User is SAVED model\n\n```\n\n### Associations\nCoffeescript:\n```coffee\nFactory.define 'post',\n\tmodel: Model\n\tassociations:\n\t\tuser:\n\t\t\t# Defaults to association name (user here)\n\t\t\tfactory: 'user'\t\n\t\t\t\n\t\t\t# Defaults to name + _id\n\t\t\tkey: 'user_id'\t\n\t\t\t\n\t\t\t# Gets foreign key from associated model\n\t\t\t# Default getter, just grabs id\n\t\t\tgetter: (assocObj) -> return assocObj.id  \n\t\t\t\n\t\t\t# Sets foreign key on factory's built model\n\t\t\t# Default setter (pseudocode - uses 'key' from above if setter not overridden)\n\t\t\tsetter: (obj, val) -> obj.set {{key}}, val\n\t\t\t\n\t\t\t # Conveniently provides default setters/getters\n\t\t\ttype: 'id' # Currently supported: \"id\", \"ids[]\"\n\t\t\t# Using type: \"ids[]\" provides a default setter than inserts id into object's array of ids\n```\n\n\n## License\n\nWTFPL v2\n","maintainers":[{"name":"davidgovea","email":"govea.d@gmail.com"}],"time":{"modified":"2022-06-17T23:18:25.555Z","created":"2013-04-14T22:39:16.923Z","0.0.1":"2013-04-14T22:39:18.881Z","0.0.2":"2013-04-14T23:32:56.882Z","0.0.3":"2013-04-14T23:55:32.299Z","0.0.4":"2013-04-15T00:22:05.788Z","0.0.5":"2013-04-15T21:02:30.650Z","0.0.6":"2013-04-17T14:08:05.025Z","0.0.7":"2013-04-24T15:21:03.949Z","0.0.8":"2013-05-12T23:04:33.647Z","0.0.9":"2013-05-19T23:11:42.841Z","0.0.10":"2013-05-20T00:29:40.741Z","0.0.11":"2013-05-20T02:00:19.584Z","0.0.12":"2013-05-23T23:36:47.702Z"},"author":{"name":"David Govea","email":"govea.d@gmail.com"},"repository":{"type":"git","url":"https://github.com/davidgovea/factory-castrado"}}