Hak*_*ari 5 ruby-on-rails cucumber factory-bot
我通常使用此步骤使用factory_girl设置记录:
Given /^the following (.+) records?:$/ do |factory, table|
table.hashes.each do |hash|
Factory(factory, hash)
end
end
Run Code Online (Sandbox Code Playgroud)
这是我在设置关联时的解决方法:
Given the following group record:
| id | name |
| 1 | foo |
And the following item records:
| name | group_id |
| bar | 1 |
| baz | 1 |
# ...
Run Code Online (Sandbox Code Playgroud)
我知道这很糟糕.使用id会使域名人员的优势变得脆弱和神秘.
所以,我的问题是 - 与factory_girl建立关联以及如上所述的表参数的最佳做法是什么?
| 归档时间: |
|
| 查看次数: |
1753 次 |
| 最近记录: |