-
-
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
Prefer spies over mocks #23
Comments
I like the idea. I'm not sure if this cop can be enabled by default, but I would add it the the selection. So feel free to add a pull request. |
I think the best way for this to work as a cop is to use the Prefer mocksRSpec/MessageExpectation:
EnforcedStyle: expect Prefer spiesRSpec/MessageExpectation:
EnforcedStyle: allow |
Enforces preferred styles of either expect(foo).to receive(:bar) or allow(foo).to receive(:bar) Fixes #23
OK. Looking forward to see it in action. I'm not convinced that there is always only |
I'm very disappointed to see this go in. When I want rspec to check something I use expect, but if I need an unchecked mock, I use allow. They are two different use cases. |
Fixes #296 This is getting too heavy handed and imposing too much maintenence. Here are a few examples: rubocop/rubocop-rspec#149 rubocop/rubocop-rspec#94 rubocop/rubocop-rspec#23
@jcoyne I'm happy to take your input on cops and even improve them if you think they are lacking. It is difficult to work with you though when your opening comments, without asking any questions about why we put time into these cops, are so negative. |
I'm sorry for being negative. It's a bitter pill to swallow when I update my bundle and all the builds start failing. |
@jcoyne thanks for apologizing. Likewise, you can imagine it being unpleasant to see these comments out of no where when I just try to add helpful cops in my free time. With this all said, are you dead set on moving forward with your "Abandon rubocop-rspec" PR you've linked above or would you like me to continue to share context for these other cops? They are all implemented to be configurable and adjust to the user's preference. I'm happy to elaborate later if you're interested but I don't want to waste my time if you've written off this gem |
@backus I'm probably going to abandon rubocop-rspec on that one project, but I have at least a dozen projects that use it. (which is why changes are painful) |
@jcoyne that makes sense. You should look into rolling a gem that just has your shared rubocop configuration in it and also a rubocop + rubocop-rspec dependency. Then you could use rubocop's |
@jcoyne Glad to see you ended up sticking with the gem :) samvera/hyku#298 |
@backus Yeah, tired and cranky last night |
@bquorning I like that (#224)! |
Enforces preferred styles of either expect(foo).to receive(:bar) or allow(foo).to receive(:bar) Fixes rubocop#23
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
Enforces preferred styles of either expect(foo).to receive(:bar) or allow(foo).to receive(:bar) Fixes rubocop#23
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
I think a cop to verify that spies are used instead of stubs would be useful.
See http://robots.thoughtbot.com/spy-vs-spy
I'll try writing a PR for this if you agree with the principle.
The text was updated successfully, but these errors were encountered: