ruby - Can one uniquely initialize each object created by the create_list method in FactoryGirl? -
in order this, imagine passing array of hashes create_list
method. considering this:
factorygirl.create_list( :person, 3, [ {name: 'rebekah', description: 'a woman straight brownish hair'}, {name: 'day', description: 'a man curly brownish hair'}, {name: 'ihsan', description: 'a boy wavy blond hair'} ] )
this persist 3 objects initialized custom name , description values.
is there way straight or ought loop through array creating individual instance each set of unique values?
do need them different? if do, see 2 options:
1- set mill properties in sequence. this:
factorygirl.define mill :person sequence(:name) { |n| "person number #{n}" } end
2- create list , set them individually
list = factorygirl.create_list(:person, 3) list.each |person| #setting end
there other answers, go first
ruby rspec tdd factory-girl
No comments:
Post a Comment