Skip to content

Instantly share code, notes, and snippets.

@jferris
Created November 5, 2010 18:23
Show Gist options
  • Save jferris/664557 to your computer and use it in GitHub Desktop.
Save jferris/664557 to your computer and use it in GitHub Desktop.
New FactoryGirl definition syntax
FactoryGirl.define do
sequence :email do |n|
"user#{n}@example.com"
end
factory :user do
email
password "test"
aliased_as :author
end
factory :post do
author
title "A post"
end
end
Factory.sequence(:email) { |n| "user#{n}@example.com" }
Factory.define :user do |factory|
factory.email { Factory.next(:email) }
factory.password "test"
end
Factory.define :post do |factory|
factory.association :author, :factory => :user
factory.title "A post"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment