2014-01-07 76 views
0

从Github合并我的代码后,我无法运行rpsec。FactoryGirl错误:rspec

我不断收到FactoryGirl错误: uninitialized constant ControllerMacros::FactoryGirl
1) Question has a valid factory
Failure/Error: expect(FactoryGirl.build(:question)).to be_valid
NameError:
uninitialized constant FactoryGirl
# ./spec/models/question_spec.rb:14:in `block (2 levels) in '

请帮助。

+0

合并后你运行了'bundle install'吗? – hawk

+0

是啊!试过了,但没有成功。 – Disha

回答

2

看来,FactoryGirl可能会缺少一些定义。 Try declaring the followingspec_helper

# spec/spec_helper.rb 
require 'factory_girl' 
FactoryGirl.find_definitions 
+0

它工作。非常感谢你:) 我没有FactoryGirl.find_definitions在我的spec_helper。 – Disha

0

如果这是一个Rails项目,你能避免使用factory_girl_rails,它会自动加载你定义为您手动查找定义。

+0

我之前有factory_girl_rails,但给了我同样的错误。 – Disha