Home Rails Rspec Factory Girl
Post
Cancel

Rails Rspec Factory Girl

例子,如果某个model对应的factory定义为:

factory  :tx do
   block
end

block为一个独立的model,  tx belongs_to block

那么,在创建的该tx的时候,我们应该:

create :tx, block: Block.new

不应该这样调用:  

create :tx, block_id: 3
This post is licensed under CC BY 4.0 by the author.