ruby on rails - Factory girl association with more than one trait -
i have association :
association :address, :factory => [:address, :closer_address]
where factory this:
factory :address address1 "12 street" latitude 22.4583397 longitude -11.06776 state 'pending_verification' trait :closer_address latitude 33.4783397 longitude -11.06776 end trait :verified state 'verified' end end
so can somehow create association more 1 trait? or there way around it? idea want have closer_address
verified, , in case might want closer_address
not verified, that's why keeping them separate.
any ideas?
you have 2 different trait options:
factory :address address1 "12 street" latitude 22.4583397 longitude -11.06776 state 'pending_verification' trait :closer_address latitude 33.4783397 longitude -11.06776 end trait :verified_closer_address latitude 33.4783397 longitude -11.06776 state 'verified' end end
you create objects this:
. . . :factory => [:address, :closer_address]
or this:
. . . :factory => [:address, :verified_closer_address]
or without changing current factory:
factory :address address1 "12 street" latitude 22.4583397 longitude -11.06776 state 'pending_verification' trait :closer_address latitude 33.4783397 longitude -11.06776 end trait :verified state 'verified' end end
you create objects this:
. . . :factory => [:address, :closer_address, :verified]
it possible use multiple traits simultaneously when creating object factorygirl.
Comments
Post a Comment