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
Deprecate passing block to mock object constructor #290
Deprecate passing block to mock object constructor #290
Conversation
@chrisroos: I'd be grateful if you could review this at some point. |
706286d
to
5925e04
Compare
I've rebased against master and force-pushed in the hope of fixing the Travis CI build for this branch. |
This is to address the confusion experienced by @ggaston095 in #286. I've chosen to use two "@yield" lines in the docs, because YARD converts these into separate bullet points under the "Yields:" heading which seemed better than a single bullet point with a very long line of text.
This mechanism is confusing, because the block is evaluated in the context of the newly instantiated block and not in the context of the current test. The mechanism is also of dubious value, because it's possible to use Object#tap or define stubs/expectations with the mock object as the explicit receiver without the code becoming much more verbose. It's unfortunate that the deprecations make the tests more complicated, but we will be able to simplify them again when this functionality is removed in a later version. See #286 for further details.
5925e04
to
9316807
Compare
I've now introduced an earlier commit which improves the documentation of the existing behaviour, before that behaviour is then deprecated in the subsequent commit. @chrisroos: It'd be great if you could have a look at this when you have a chance. I don't think it should take you long. Let me know if you want help on how to generate the documentation... |
Out of interest, why have you used As an observation, I presume there aren't any tests for this now-deprecated behaviour for Aside from my question and observation this all looks good to me, @floehopper. |
Thanks for reviewing.
In the former, each test is instantiating a new instance of a test case (via
You are correct. I think I'm OK with this on the basis I know that the behaviour is implemented within I'm planning to get this merged, so do shout if you have any more comments or questions. |
This mechanism is confusing, because the block is evaluated in the
context of the newly instantiated block and not in the context of the
current test.
The mechanism is also of dubious value, because it's possible to use
Object#tap or define stubs/expectations with the mock object as the
explicit receiver without the code becoming much more verbose.
It's unfortunate that the deprecations make the tests more complicated,
but we will be able to simplify them again when this functionality is
removed in a later version.
See #286 for further details.