Fil*_*uzi 18 rspec ruby-on-rails ruby-on-rails-4 factory-bot
我工作FactoryGirl
在version 4.4
.我正在尝试创建after(:create)
回调,但我在评估变量上失败了.
FactoryGirl.define do
factory :organization do
name 'example'
factory :organization_with_links do
transient do
links_count 5
end
after(:create) do |organization, evaluator|
create_list(:link, evaluator.links_count, organization: organization)
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
不幸的是我得到了
NoMethodError: undefined method `links_count' for FactoryGirl::SyntaxRunner:0x007fcefb1ff780>
Run Code Online (Sandbox Code Playgroud)
根据官方工厂女孩指南我正在做的一切正确:https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md#associations
任何建议如何transient variable
工作?
Fil*_*uzi 35
所以解决方案是改变
transient do
links_count 5
end
Run Code Online (Sandbox Code Playgroud)
至
ignore do
links_count 5
end
Run Code Online (Sandbox Code Playgroud)
原因:主人的文件准备好了FactoryGirl v.5.0
.瞬态将在5.0
发布时开始.
更多阅读:http: //github.com/thoughtbot/factory_girl/issues/658
归档时间: |
|
查看次数: |
4111 次 |
最近记录: |