If I add:
config.include FactoryGirl::Syntax::Methods
under
RSpec.configure do |config|
and run rspec, I see this error:
/Users/perry_mac/rails_projects/mymri/spec/spec_helper.rb:21:in `block
in ': uninitialized constant FactoryGirl (NameError)
my gemfile.lock can be seen in this pastebin
my gemfile can be seen in this pastebin
If I omit the Rspec.comfigure statment, my tests all run fine. I'd like to make use of the abbreviated syntax, but am not sure what I am doing wrong here.
You must add this string in file 'spec/RAILS_helper.rb' not in 'spec_helper.rb'
Got it.
This link showed me the way.
The required addition should be made in spec/support/factory_girl.rb
and it should look like this:
# RSpec
# spec/support/factory_girl.rb
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end
Also make sure to require 'factory_bot'
in spec/support/factory_bot.rb
That's what ended up being the issue for me.
Make sure to include require 'support/factory_girl'
in spec/rails_helper.rb
after require 'rspec/rails'
.
I was getting this error after putting it right after require 'spec_helper'
.
I think it's worth mentioning here that, going forward, if using FactoryGirl, you will receive a deprecation message:
The factory_girl gem has been deprecated and has been replaced by factory_bot. Please switch to factory_bot as soon as possible.
Just a note for developers in the future that are trying to use FactoryGirl.