If I have types defined in a module inside a model, and an array of these types also defined in the same model, how can I call a value from this array randomly when defining a new factory?
Thanks!
John
Checkout this answer - use Array#sample
:
FactoryGirl.define do
factory :user do
name "Foo Bar"
foo { [:a, :list, :of, :values].sample }
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With