Chaitali
Chaitali

Reputation: 97

Factory_girl deprecation for rails 5

I'm currently upgrading my rails application from rails 4 to rails 5. Is it necessary to change from Factory_girl to Factory_bot? What will happen if I proceed with a deprecation warning? further, I might be upgrading that application to rails 6, so would factory_girl work for rails 6?

Upvotes: 2

Views: 1692

Answers (1)

Tom Lord
Tom Lord

Reputation: 28305

FactoryGirl was renamed to FactoryBot in October 2017. (The original name was based on some inside joke/pop culture reference, which some argued was a poor decision.)

This has got nothing to do with upgrading rails, and everything to do with upgrading factory_girl/factory_bot.

Use the new name. It makes no sense to keep the old name - and regardless, your code will break at some point when updating versions, if you don't perform the rename.

The change is quite straightforward, and there are various guides people have written about the upgrade, such as this.

Essentially, all you need to do is:

  1. Rename factory_girl and/or factory_girl_rails in the Gemfile, to factory_bot and factory_bot_rails.
  2. Rename any mention of FactoryGirl to FactoryBot. (You could use git grep to ensure nothing is missed.)

Upvotes: 0

Related Questions