Reputation: 347
I installed the factory_girl
gem, and when I run my tests I get an error:
`block in ': uninitialized constant FactoryGirl (NameError)
This is my spec_helper.rb
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
end
How can it be fixed?
Upvotes: 3
Views: 11791
Reputation: 52967
I'm just putting this here for anyone clumsy like me. Everything was fine, but I was calling FactoryGirl
in one place, when I only have FactoryBot
installed. Newbie error. Hope it might help.
Upvotes: 1
Reputation: 669
In spec/spec_helper.rb
, try adding
FactoryGirl.find_definitions
under
require 'factory_girl_rails'
or make sure you follow factory_bot's Getting Started guide.
Upvotes: 4
Reputation: 1383
This must be your answer.
The required addition should be made in spec/support/factory_girl.rb
https://stackoverflow.com/a/25649064/1503970
Upvotes: 1