1
我知道如何定義一個工廠當創建一個has_many關聯:添加(has_many)關聯到FactoryGirl.create?
factory :user do
name "John Doe"
factory :user_with_posts do
ignore do
posts_count 5
end
after(:create) do |user, evaluator|
create_list(:post, evaluator.posts_count, user: user)
end
end
end
但我會怎麼做,當我實際創建工廠,如:
Factory.create(:user, :posts << ??)