RSpec error "Uninitialized constant FactoryGirl (Name Error)"
17,037
You just have to add the following in your spec_helper.rb file
require 'factory_girl_rails'
Related videos on Youtube
Author by
user3472965
Updated on October 09, 2022Comments
-
user3472965 over 1 year
I try running my RSpec test:
rspec comments.rb
but keep getting the same error (see title). Before anyone asks I have already added
require factory_girl
to spec_helper.rb.The contents of
spec/factories/comments.rb
file are:FactoryGirl.define do factory :comment do comment "MyString" task_id 1 end end
Here is testing group of the gemfile where I included factory_girl_rails:
source 'http://rubygems.org' ... group :development, :test do gem 'debugger' gem 'factory_girl_rails' gem 'rspec-rails' end ...
-
Bryan Ash about 8 yearsThis answer uses the unknown constant
FactoryGirl
. How is this supposed to help? -
oligan almost 8 yearsI'm voting to delete this answer as it's not addressing the question that was asked.
-
Feliks Montez over 6 yearsFactoryGirl has changed its name to FactoryBot, so you will now need to use
require 'factory_bot_rails'
.