Method Two: Child Factory factory :user do username “Bob” age 30 trait :drinking_age do age 21 end factory :drinking_buddy, :traits => [:drinking_age] end
:drinking_age do age 21 end trait :admin do admin true end factory :go_home_admin_your_drunk, :traits => [:drinking_age, :admin] end This is like factory multiple inheritance
“user#{n}” } age 30 factory :user_with_posts do ignore do post_count 1 end after(:create) do |user, factory| create_list :post, factory.post_count, user: user end end end