-
-
Notifications
You must be signed in to change notification settings - Fork 763
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
Show warning for examples that don't include an expectation #759
Comments
This is a duplicate (ish) of #591. My opinion is we shouldn't support this for reasons explained in that issue, but @myronmarston may have a different opinion so I'll leave it open for his comment. |
Oops, I missed that issue by simple researching. Now I've read that issue, how about make this optional stuff? (Don't you like adding configuration like this?) |
There's also been a lot of discussion about this same idea in #404. I had a few concerns at the time of that issue:
I'd say I'm more on board with the idea now than I was before, as long as it's an optional config, it takes into account mock expectations, is not too complex, and doesn't introduce additional coupling between the rspec gems. One other thing to consider is #740. For that one we are discussing an API that rspec-mocks and rspec-expectations can use to register callbacks rspec-core can use to get the counts of expectations/mock-expectations that have been set. I wonder if that could be used here? It's easy to imagine the logic for this implemented by comparing before and after counts of expectations/mock-expectations, and such an API would provide an appropriate level of de-coupling. |
Double plus on the optional setting. Making it required would break "natural assertions" provided by RSpec/Given (https://github.com/jimweirich/rspec-given/tree/natural#natural-assertions) |
Yes, I had same concern. #740 looks good solution to de-couple. (see counter to judge there was no expectations or not) |
+1: As someone who just came across a whole spec file full of 'expectations' looking like Of course one should always write a failing spec first, but sometimes people don't, and this feature would help in making the resulting mess a bit less. In the mean time, I will be trying the method used in http://blog.sorah.jp/2012/12/17/rspec-warn-for-no-expectations |
I think we should reconsider doing this. There's clearly demand for it since it's come up a number of times (and yet again on the mailing list) and I've just thought of an implementation that's really simple:
This could also be used for #740 as an alternative implementation to having rspec-expectations and rspec-mocks expose counts. One downside to this implementation idea is that it only works with the |
Hopefully this can be done in a way that won't break natural assertions in On Tue, Feb 18, 2014 at 10:54 AM, Myron Marston notifications@github.comwrote:
|
I'm imagining this would be a config option that would default to do nothing, so rspec-given users would only be affected if they enabled the config option. Beyond that, are you satisfied with |
@myronmarston thanks for re-opening this after my post on the forum, & thanks for the link to sorah.jp - I'll give that a try for now.
If that was a hook to rspec-core, it would let others develop other extensions like RSpec-Given, and also (potentially) enable reporting like this:
(I know many consider >1 assertions per example a bad practice, but it can be useful.) |
should
I would love to work on this. I talked to @myronmarston and @samphippen a few days ago about how to go about implementing this as a plugin. But I was pointed towards this thread instead since it is a requested feature in RSpec. |
AFAIU it can be done by checking if What I'm missing here? |
(and hacked up |
I'm doing the following hack to do this in our repository.
I want to introduce this to rspec-core, but I can't decide which repository (rspec-{mocks,expectations, etc}) to write a patch and send pull-request.
In that patch, it crosses rspec-mocks and expectations, which should I send a patch? rspec-core?
(I know that patch is little bit ugly (optimized as monkey patch), I'll fix for pull request.)
The text was updated successfully, but these errors were encountered: