FactoryGirl瞬态变量的未定义方法
我在version 4.4
使用FactoryGirl
。 我正在尝试创建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
不幸的是我得到了
NoMethodError: undefined method `links_count' for FactoryGirl::SyntaxRunner:0x007fcefb1ff780>
根据官方工厂女孩指南我正在做的一切正确: https : //github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md#associations
任何建议如何使transient variable
工作?
所以解决方案是改变
transient do links_count 5 end
至
ignore do links_count 5 end
原因:硕士论文为FactoryGirl v.5.0
做好准备。 瞬态将在5.0
版本上发布。
更多阅读: http : //github.com/thoughtbot/factory_girl/issues/658
- 使用OmniAuth在Factory Girl中创建用户?
- 何时在BDD循环中从黄瓜切换到rspec以进行登录过程
- 如何在rspec测试中存根gmaps4rails地理编码function?
- ArgumentError:工厂未注册
- Factory Girl + Rspec给出以下错误:ActionView :: Template :: Error :(对象id)不是id值
- Factory Girl怎么没有对独特属性进行排序?
- FactoryBot工厂中`transient do`块的目的是什么?
- Rspec validates_uniqueness_of测试失败并出现其他validation错误
- 带载波上传字段的工厂