Disha
Disha

Reputation: 796

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.

Upvotes: 0

Views: 289

Answers (2)

Joe Ferris
Joe Ferris

Reputation: 2732

If this is for a Rails project, you can avoid finding definitions manually by using factory_girl_rails, which will automatically load your definitions for you.

Upvotes: 0

zeantsoi
zeantsoi

Reputation: 26193

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 

Upvotes: 2

Related Questions