-
-
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 MessageExpectation cop #169
Conversation
Enforces preferred styles of either expect(foo).to receive(:bar) or allow(foo).to receive(:bar) Fixes #23
I'm not sure about this practicality of this one. Won't the vast majority of specs in any project need to use See https://relishapp.com/rspec/rspec-mocks/docs/basics/spies for some examples of the situations I had in mind for #23. |
@andyw8 I've run this on two projects now and it actually seems very effective. Basically this should be one piece of the puzzle in enforcing one of these two styles: allow(foo).to receive(:bar)
# exercise system under test
expect(foo).to have_received(:bar) expect(foo).to receive(:bar)
# exercise system under test Note that this cop will never flag The second piece of the puzzle (which I haven't implemented yet) would be to find tests where spies are setup but not verified within that test. Basically it could detect (and autocorrect) the following: allow(foo).to receive(:bar)
^^^^^^^^^^ Message expectation specified but not verified
thing.do_something(foo) which could be autocorrected to allow(foo).to receive(:bar)
thing.do_something(foo)
expect(foo).to have_received(:bar) |
Users have expressed confusion over this cop; see - rubocop#23 - rubocop#169 - rubocop#218 - rubocop#224 - rubocop#229
Check that message expectations are set using spies. This relates to various issues: - rubocop#23 - rubocop#169 - rubocop#218 - rubocop#229
Add MessageExpectation cop
Users have expressed confusion over this cop; see - rubocop#23 - rubocop#169 - rubocop#218 - rubocop#224 - rubocop#229
Check that message expectations are set using spies. This relates to various issues: - rubocop#23 - rubocop#169 - rubocop#218 - rubocop#229
Users have expressed confusion over this cop; see - rubocop/rubocop-rspec#23 - rubocop/rubocop-rspec#169 - rubocop/rubocop-rspec#218 - rubocop/rubocop-rspec#224 - rubocop/rubocop-rspec#229
Check that message expectations are set using spies. This relates to various issues: - rubocop/rubocop-rspec#23 - rubocop/rubocop-rspec#169 - rubocop/rubocop-rspec#218 - rubocop/rubocop-rspec#229
Users have expressed confusion over this cop; see - rubocop/rubocop-rspec#23 - rubocop/rubocop-rspec#169 - rubocop/rubocop-rspec#218 - rubocop/rubocop-rspec#224 - rubocop/rubocop-rspec#229
Check that message expectations are set using spies. This relates to various issues: - rubocop/rubocop-rspec#23 - rubocop/rubocop-rspec#169 - rubocop/rubocop-rspec#218 - rubocop/rubocop-rspec#229
Users have expressed confusion over this cop; see - rubocop/rubocop-rspec#23 - rubocop/rubocop-rspec#169 - rubocop/rubocop-rspec#218 - rubocop/rubocop-rspec#224 - rubocop/rubocop-rspec#229
Check that message expectations are set using spies. This relates to various issues: - rubocop/rubocop-rspec#23 - rubocop/rubocop-rspec#169 - rubocop/rubocop-rspec#218 - rubocop/rubocop-rspec#229
Users have expressed confusion over this cop; see - rubocop/rubocop-rspec#23 - rubocop/rubocop-rspec#169 - rubocop/rubocop-rspec#218 - rubocop/rubocop-rspec#224 - rubocop/rubocop-rspec#229
Check that message expectations are set using spies. This relates to various issues: - rubocop/rubocop-rspec#23 - rubocop/rubocop-rspec#169 - rubocop/rubocop-rspec#218 - rubocop/rubocop-rspec#229
Enforces preferred styles of either
or
Fixes #23