Sha256: 6f79ee846fa3e3d2d55ea9e9415920170c575e827615778be77894e3ff878840
Contents?: true
Size: 568 Bytes
Versions: 10
Compression:
Stored size: 568 Bytes
Contents
FactoryGirl.define do factory :book do title { Faker::Company.catch_phrase } transient do author { Author.order("RANDOM()").first } end # the after(:create) yields two values; the user instance itself and the # evaluator, which stores all values from the factory, including transient # attributes; `create_list`'s second argument is the number of records # to create and we make sure the user is associated properly to the post after(:create) do |book, evaluator| evaluator.author.add_role(:author, book) end end end
Version data entries
10 entries across 10 versions & 1 rubygems