Search code examples
ruby-on-railsrspecfactory-botrspec-rails

Rails / Factory Girl: Uninitialized constant FactoryGirl (NameError)


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?


Solution

  • This must be your answer.

    The required addition should be made in spec/support/factory_girl.rb

    https://stackoverflow.com/a/25649064/1503970