按照http://robots.thoughtbot.com/testing-your-factories-first的示例
Rakefile中的行task spec: :factory_specs
告诉rake在“spec”任务之前执行“factory_specs”任务。
我的问题是rake spec
两次加载Rails环境,一个用于执行factory_specs任务,另一个用于执行spec任务。
如何阻止我的rake命令加载Rails两次?
我的筹码:
答案 0 :(得分:0)
使用最新版本的FactoryGirl,您可以使用FactoryGirl.lint
而不是在单独的rake任务中显式测试工厂。只需更新到最新版本,然后将其添加到spec_helper.rb
:
RSpec.configure do |config|
config.before(:suite) do
FactoryGirl.lint
end
end
更多信息位于Getting Started Guide。