public
Description: Fixture replacement for focused and readable tests.
Homepage: http://thoughtbot.com/projects/factory_girl
Clone URL: git://github.com/thoughtbot/factory_girl.git
jferris (author)
Sat May 31 10:46:33 -0700 2008
commit  0a6a54c6b95112e0bc5a691d9e1ef2a684a3cec5
tree    61dc5bcc6dfb13bf5962053e5f7f42cdd0b93231
parent  6fb322f169bba567924f9d4ee5a2767479c63c6a
name age message
file .gitignore Wed May 28 15:28:02 -0700 2008 Added a schema to test with [jferris]
file README Loading commit data...
file Rakefile
directory lib/
directory test/
README
= factory_girl

== Defining factories

  # This will guess the User class
  Factory.define :user do |u|
    u.first_name 'John'
    u.last_name  'Doe'
    u.admin false
  end

  # This will use the User class (Admin would have been guessed)
  Factory.define :admin, :class => User do |u|
    u.first_name 'Admin'
    u.last_name  'User'
    u.admin true
  end

It is recommended that you create a test/factories.rb file and define your
factories there. This file can be included from test_helper or directly from
your test files. Don't forget:
  require 'factory_girl'

== Using factories

  # Build and save a User instance
  Factory(:user)

  # Build a User instance and override the first_name property
  Factory.build(:user, :first_name => 'Joe')

  # Return an attributes Hash that can be used to build a User instance
  attrs = Factory.attributes_for(:user)