-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate factory_girl and provide upgrade instructions
- Loading branch information
1 parent
f48b90a
commit 48296b9
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# 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. | ||
|
||
```ruby | ||
# 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: | ||
|
||
```sh | ||
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. | ||
|
||
```sh | ||
grep -e factory_girl **/*.rake **/*.rb -l | xargs sed -i "" "s|factory_girl|factory_bot|" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48296b9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this version was not pushed to rubygems.org?