Created
May 2, 2013 14:32
-
-
Save yock/5502601 to your computer and use it in GitHub Desktop.
Nested factories in FactoryGirl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FactoryGirl.define do | |
factory :user do | |
name "#{Faker::Name.first_name} #{Faker::Name.last_name}" | |
email Faker::Internet.email | |
username Faker::Internet.user_name | |
password 'password' | |
stripe_customer_id 'cus_1' | |
factory :deactivated_user do | |
deactivated true | |
deactivated_reason :user_cancelled | |
stripe_customer_id 'cus_2' | |
end | |
factory :basic_user do | |
stripe_customer_id 'cus_3' | |
stripe_plan StripePlan.where(name: 'basic_20130429').first | |
end | |
factory :pro_user do | |
stripe_customer_id 'cus_4' | |
stripe_plan StripePlan.where(name: 'pro_20130429') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice gist yock!