Mik*_*rin 7 testing rspec factory-bot
我正在编写一些测试,调用FG创建一个特性,即after_create,创建一个关联的对象.有没有办法在制作FG时将参数发送到相关产品,或者之后是否需要设置它们?
在ignore中添加该参数:
FactoryGirl.define do
trait :my_trait do
ignore do
associated_attributes nil
end
after_create do |object, evaluator|
# Use the ignored associated_attributes when creating the associated object
associated_object = AssociatedModel.new(evaluator.associated_attributes)
end
end
end
Run Code Online (Sandbox Code Playgroud)