Created
November 1, 2016 02:25
-
-
Save rlgreen91/082e8fe8b145e37be595c1500cccec26 to your computer and use it in GitHub Desktop.
Fun with Factories!
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 :micropost do | |
content Faker::Lorem.characters(140) | |
user | |
end | |
factory :relationship do | |
follower_id | |
followed_id | |
end | |
factory :user do | |
name Faker::Name.name | |
sequence(:email) { |n| "example-#{n}@example.com"} | |
password 'password' | |
password_confirmation 'password' | |
activated true | |
activated_at Time.zone.now | |
factory :user_with_posts do | |
transient do | |
posts_count 1 | |
end | |
after(:create) do |user,evaluator| | |
create_list(:micropost, evaluator.posts_count, user: user) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment