Skip to content

Instantly share code, notes, and snippets.

@coryschires
Created June 20, 2011 18:33
factory_girl_example.rb
Factory.define :user do |f|
f.sequence(:email) { |n| "foo#{n}@example.com" }
f.email_confirmation { |u| u.email }
f.password "password"
f.password_confirmation { |u| u.password }
end
Factory.define :super_admin, :parent => :user do |f|
f.after_create { |user| user.roles << Role.find_or_create_by_name('super_admin') }
end
Factory.define :institution do |f|
f.sequence(:name) { |n| "University #{n}" }
f.approved true
end
Factory.define :profile do |f|
f.first_name "John"
f.last_name "Doe"
f.department "History"
f.position "Professor"
f.bio "Bio"
f.specialty_list "Gender, Religion, Mathmatics, Science"
f.association :user
f.association :institution
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment