New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new RSpec/FactoryBot/SyntaxMethods
cop.
#1215
Conversation
6983d3e
to
0d05ba9
Compare
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.
Looks good as is. A few cosmetic notes, and a couple of optional suggestions.
Thanks!
Description: Use the shorthands from `FactoryBot::Syntax::Methods` in your specs. | ||
Enabled: pending | ||
SafeAutoCorrect: false | ||
VersionAdded: "<<next>>" |
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.
We didn't use that notion in the past, but it's quite a useful trick.
e9fe6d6
to
16ce074
Compare
`FactoryBot` provides a mixin called [`FactoryBot::Syntax::Methods'](https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#rspec) which allows to replace ```ruby FactoryBot.create(:bar) FactoryBot.build(:bar) FactoryBot.attributes_for(:bar) ``` with ``` create(:bar) build(:bar) attributes_for(:bar) ``` The auto-correction is unsafe as there is no way to tell just from syntax whether a given example group includes the mixin or not.
16ce074
to
5520d3b
Compare
create_pair | ||
generate | ||
generate_list | ||
null |
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.
TIL ❤️
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.
FactoryBot::Syntax::Methods.instance_methods.sort
😉
Thank you for the contribution! |
FactoryBot
provides a mixin called`FactoryBot::Syntax::Methods'
which allows to replace
with
The auto-correction is unsafe as there is no way to tell just from syntax
whether a given example group includes the mixin or not.
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).CHANGELOG.md
if the new code introduces user-observable changes.bundle exec rake
) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).If you have created a new cop:
config/default.yml
.Enabled: pending
inconfig/default.yml
.VersionAdded
indefault/config.yml
to the next minor version.If you have modified an existing cop's configuration options:
VersionChanged
inconfig/default.yml
to the next major version.