【发布时间】:2011-08-11 15:58:18
【问题描述】:
使用 RSpec 和 Factory Girl,我创建了一条记录,该记录在创建时会在 after_create 中自动创建关联的“小时”记录。
但我想用非默认时间进行测试,最好是我在工厂女孩工厂中定义的时间。以下是我想做的事情:
before (:all) do
@business = Factory(:business_one)
# when that business is saved, a set of default hours is automatically saved as well
# how would I now update the hours with fixtures?
# so, ideally something like:
@business.hours[0] << Factory(:day_one)
@business.hours[1] << Factory(:day_two)
...etc...
end
这是可行的还是我需要以不同的方式解决这个问题?
【问题讨论】:
标签: ruby-on-rails rspec factory-bot