Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 1.13 KB

UPGRADE_FROM_FACTORY_GIRL.md

File metadata and controls

48 lines (36 loc) · 1.13 KB

Upgrade from factory_girl

Upgrading your codebase should involve only a few steps, and in most cases, it involves updating the Gemfile, factories file(s), and support file configuring the testing framework.

Modify your Gemfile

Replace references to factory_girl_rails or factory_girl with factory_bot_rails or factory_bot. Both new gems are available starting at version 4.8.2.

# Gemfile

# old
group :development, :test do
  gem "factory_girl_rails"
  # or
  gem "factory_girl"
end

# new
group :development, :test do
  gem "factory_bot_rails"
  # or
  gem "factory_bot"
end

Replace All Constant References

A global find-and-replace of FactoryGirl to FactoryBot across the codebase to replace all references with the new constant should do the trick. For example, on OS X:

grep -e FactoryGirl **/*.rake **/*.rb -l | xargs sed -i "" "s|FactoryGirl|FactoryBot|"

Replace All Path References

If you're requiring files from factory_girl or factory_girl_rails directly, you'll have to update the paths.

grep -e factory_girl **/*.rake **/*.rb -l | xargs sed -i "" "s|factory_girl|factory_bot|"