-
-
Notifications
You must be signed in to change notification settings - Fork 277
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/EmptyOutput cop #1854
Conversation
471010f
to
4c96fce
Compare
cc @pirj |
One exception I can think of is a compund expectation like Otherwise - looks good, thanks! |
I actually did look into the compound marchers, and I think |
I’ll have a look. Actually what should we recommend if someone matches e.g. expect {}.to output("foo").to_stdout.and output("").to_stderr I don’t think there’s a way to do e.g. expect {}.to output("foo").to_stdout.and not output.to_stderr
# or
expect {}.to_not output.to_stderr.and output("foo").to_stdout The last code tells me that
Maybe in that case it’s fine that we don’t detect an offense on compound expectations. |
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, thank you!
For the other cop, we register an offence, but don’t autocorrect, since it’s not guaranteed that the negated matcher (not_change) is defined in the user’s codebase. expect { :nop }
.to not_output.to_stdout
.and not_output.to_stderr should work, just like a combination of output.to_stderr with eg not_output.to_stdout |
Yeah, I think it’s too much if we ask the user to implement a |
Instead of calling `output` with an empty string, you should use the inverse runner and call `output` without an argument. E.g. instead of expect { foo }.to output('').to_stdout you should call expect { foo }.not_to output.to_stdout
Just to be sure, the |
I checked with real-world-rspec. There seems to be no errors or false positives ✅
|
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!
Instead of calling
output
with an empty string, you should use the inverse runner and calloutput
without an argument. E.g. instead ofyou should call
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
.