-1

I know that FactoryGirl has been deprecated in favor of FactoryBot, but we haven't yet updated our code, so we are still using FactoryGirl. Regardless, requiring FactoryGirl in the Rails Console should work, but it isnt'.

The gem is included properly in my Gemfile

group :test, :development do
   ...  
  gem 'factory_girl_rails', '~> 4.9.0'
   ...
end

And it appears when I run bundle

$ bundle | grep factory
Using factory_girl 4.9.0
Using factory_girl_rails 4.9.0

But when I require it in the console, it fails.

[1] pry(main)> require 'factory_girl_rails'
=> false
[3] pry(main)> require 'factory_girl'
=> false

This doesn't seem to happen with any of the other gems in my Gemfile. Can anyone help me fix this?

Asif
  • 748
  • 3
  • 9
  • 32

2 Answers2

5

When require returns false then this doesn't mean that an error occured. It means that the feature was already loaded.

From the documentation of require:

require(name)true or false

Loads the given name, returning true if successful and false if the feature is already loaded.

When require is not able to load the feature than it will raise a LoadError.

Community
  • 1
  • 1
spickermann
  • 100,941
  • 9
  • 101
  • 131
2

It returns false because it's already been required and loaded. Try

FactoryGirl

to verify the constant exists

Ursus
  • 29,643
  • 3
  • 33
  • 50