-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
Require VoidExpect to operate inside an example block #1975
Require VoidExpect to operate inside an example block #1975
Conversation
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.
Thanks!
@rubocop/rubocop-rspec I’d merge this right away, as this allows to remove some nonsensical examples for this cop in the coverage tightening PR.
38a6f78
to
3f38ff9
Compare
@pirj Can you review 1 more time please? I think I solved this, but it entails removing this guard clause At this point, I can probably drop all VoidExpect changes from the other PR, so it's just amending that 1 other spec file. |
RUBY | ||
end | ||
|
||
context 'when expect has no parent node' do |
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.
I’d just removed all this except the first one.
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 need the block version below to cover the new guard clause in on_block
I'll delete the rest and get this merged in.
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.
A huge 👍 from me, thank you!
3f38ff9
to
7484a9a
Compare
@pirj Feel free to merge at will |
We usually get consensus on things that might be user-facing, so I’ll pass on merging to the next reviewer. May I kindly ask to add a short changelog note that the cop was fixed to only inspect code inside examples? |
7484a9a
to
7718880
Compare
Thanks! CHANGELOG entry added. |
7718880
to
3e0cb99
Compare
3e0cb99
to
7e3149d
Compare
@bquorning Would you be up for doing the 2nd review on this one? |
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!
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.
Yep, looks good 👍🏼
This PR completes branch coverage for
VoidExpect
.This PR copies the
inside_example?
method and re-uses it here to get more coherent behavior from the VoidExpect cop.Note that if we were thinking of copying
inside_example?
a 3rd time, I'd suggest factoring it out into a utility (Sandi Metz' rule of 3).Note that I remove the
return true unless parent
guard clause, because we expect theinside_example?
guard clause to fully cover that condition.Split from:
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
.Enabled: true
in.rubocop.yml
.VersionAdded: "<<next>>"
indefault/config.yml
.If you have modified an existing cop's configuration options:
VersionChanged: "<<next>>"
inconfig/default.yml
.