Link Search Menu Expand Document

Embedding Factories

To use factories with factories, the following pattern is recommended:

FakerMaker.factory :item do
  name { Faker::Commerce.product_name }
  price { Faker::Commerce.price }

FakerMaker.factory :basket do
  items( has: 10 ) { FakerMaker[:item].build }

You might have to manage your dependencies and require your referenced factory.

Copyright © 2019-2020 Nigel Brookes-Thomas. Distributed by an MIT license.