Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way in factory_girl to get attributes_for and create for the same instance element?

If I want to create and instance using "create" build strategy and then want to use "attributes_for" build strategy for verification, is it possible to do? And if I use sequences in the factory? Is it possible in Machinist gem?

like image 727
Alexey Avatar asked Nov 30 '10 19:11

Alexey


1 Answers

Not quite sure I fully understand. And I'm not a user of machinist. But it sounds like you just want to do something like this.

@attributes = FactoryGirl.attributes_for(:my_object)
my_object = MyObject.create(@attributes)
my_object.some_property.should == @attributes[:some_property]
like image 166
John Hinnegan Avatar answered Sep 20 '22 01:09

John Hinnegan