简体   繁体   中英

FactoryGirl error : rspec

I cannot run rpsec after merging my code from Github.

I keep getting FactoryGirl error : 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 '

Please help.

It appears that FactoryGirl may be missing some definitions. Try declaring the following in your spec_helper :

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

如果这是针对Rails项目,则可以避免使用factory_girl_rails手动查找定义,这将自动为您加载定义。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM