重装工厂_女孩工厂 [英] Reload factory_girl factory
本文介绍了重装工厂_女孩工厂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望在工厂中进行更改时,可以在rails控制台中看到它们而无需重新启动所有控制台.
I want that when I make changes in factories, I see them in rails console without restarting all console.
我找到了一些行,并对其进行了深入的了解,对其进行了测试,文档我不清楚.
I've found some lines and tested them with a poor understanding of what's going on, documentation isn't clear for me.:
FactoryGirl.reload
我也测试过:
> FactoryGirl.factories.clear
> FactoryGirl.find_definitions # also tested FactoryGirl.factories.find_definitions
# but NoMethodError is raised
=> ActiveRecord::RecordNotFound: Couldn't find Address with ID=277 Torphy Squares
推荐答案
我正在使用 Faker .请参阅解决该问题的更改差异:
I was using Faker. See the diff of changes that solved the problem:
# factories/building.rb, address is a string
- address Faker::Address.street_address
+ address { Faker::Address.street_address }
# factories/user.rb, email is a string
- email Faker::Internet.email
+ email { Faker::Internet.email }
然后FactoryGirl.reload
起作用.
这篇关于重装工厂_女孩工厂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文