Skip to content

Instantly share code, notes, and snippets.

@yock
Created May 2, 2013 14:32
Show Gist options
  • Save yock/5502601 to your computer and use it in GitHub Desktop.
Save yock/5502601 to your computer and use it in GitHub Desktop.
Nested factories in FactoryGirl
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
@livando
Copy link

livando commented May 2, 2013

nice gist yock!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment