在factory_girl中有没有办法获取attributes_for并为同一个实例元素创建?

Ale*_*xey 6 ruby factory machinist factory-bot

如果我想创建和实例使用"创建"构建策略然后想要使用"attributes_for"构建策略进行验证,是否可以这样做?如果我在工厂使用序列?机械师宝石有可能吗?

Joh*_*gan 11

我不完全明白.而且我不是机械师的用户.但听起来你只想做这样的事情.

@attributes = FactoryGirl.attributes_for(:my_object)
my_object = MyObject.create(@attributes)
my_object.some_property.should == @attributes[:some_property]
Run Code Online (Sandbox Code Playgroud)