GitXplorerGitXplorer
t

forgery

public
8 stars
1 forks
1 issues

Commits

List of commits on branch master.
Unverified
58bdabec826e6c454e1cca9c1007b5128212c73a

Updated license and removed outdated warning

ttheycallmeswift committed 12 years ago
Unverified
7f243f6dd69e22bfe0b7034542cc94c9d4134493

Fixed typo in README

ttheycallmeswift committed 12 years ago
Unverified
9a5602b6c9b8e2dea0876125352285bc158c7a87

Bump to v0.0.3

ttheycallmeswift committed 12 years ago
Unverified
af97949c620b9142621ca3b95dff58ea4a2a3e0d

Added ability to specify the ID field

ttheycallmeswift committed 12 years ago
Unverified
e41c741dd5c410355b653ed943430e9b5ef6bd2c

Why the hell was I testing the version number?

ttheycallmeswift committed 12 years ago
Unverified
1b244aee093baad50998d6b290ed65e3626bfb9a

Merge pull request #2 from travis4all/clean

ttheycallmeswift committed 12 years ago

README

The README file for this repository.

build status

Forgery

Forgery is a set of testing tools for Node.js and client-side MVC applications. Specifically it's designed to integrate well with popular testing frameworks like:

Installation & Setup

To install the latest stable version of Forgery, use npm with the following command:

npm install forgery

Factory

Forgery.Factory is a JSON fixtures library for Node.js. It is usful for stubbing out API responses and creating JSON unique JSON objects for testing.

Setup and Usage

Forgery's Factory functionality is heavily inspired by Factory Girl. In order to use it, all you have to do is require it and define some factories. For example:

var Factory = require('forgery').Factory;

Factory.define('MyFactory', {
  "foo": "bar",
});

... etc ...

Now when ever you need to create a new factory, you have access to it through the Factory method:

Factory('MyFactory') 
//=> { id: '9e55f9ad9411aea49d554ae4e0b5c306', foo:'bar' }

We can also easily override the default attributes by passing in an options hash as a second parameter.

Factory('MyFactory', { foo: 'tab' }) 
//=> { id: '9e55f9ad9411aea49d554ae4e0b5c306', foo:'tab' }

Changing the ID field

Sometimes you will want the ID field to have a different format. For instance, if you are mocking Mongo objects, they have an _id attribute instead. You can specify to use a differnt ID field or none at all using the third parameter.

// Alternative ID field
Factory('MyFactory', { foo: 'tab' }, { idField: '_id' }) 
//=> { _id: '9e55f9ad9411aea49d554ae4e0b5c306', foo:'tab' }

// No ID field (must set explicitly to false)
Factory('MyFactory', { foo: 'tab' }, { idField: false }) 
//=> { foo:'tab' }

License

/* ----------------------------------------------------------------------------
 * "THE BEER-WARE LICENSE" (Revision 42):
 *
 * Swift <theycallmeswift@gmail.com> wrote this file. As long as you retain
 * this notice you can do whatever you want with this stuff. If we meet some
 * day, and you think this stuff is worth it, you can buy me a beer in return.
 * ----------------------------------------------------------------------------
 */