Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined method `FactoryGirl' -- upgrading from 2.0.2 to 3.4.2

Tags:

factory-bot

I'm in the process of upgrading from factory_girl (2.0.2 to 3.4.2) and factory_girl_rails (1.1.0 -> 3.4.0) and I'm having issues with my rspec tests seeing factory girl.

I think I've successfully altered my factories to deal with the new syntax, and have removed the extra require statements that were bringing in multiple copies of the same files. My server now starts up, so I know that the factories.rb file is correctly getting parsed.

Now when I run my rspec tests, I'm getting this error:

NoMethodError: undefined method `FactoryGirl' for #

it 'can be created' do
  course = FactoryGirl(:course)
  ….
end
like image 515
Himani Avatar asked Jul 02 '12 21:07

Himani


1 Answers

With Factory Girl 3.4.2, you will need to explicitly use the create method.

course = FactoryGirl.create(:course)
like image 128
Professor Todd Avatar answered Sep 25 '22 10:09

Professor Todd