Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Improve RSpec/SubjectStub cop #770
1. Use consistent wording in docstrings
2. Improve stub detection
Previously, the following code would still be detected as an offence:
even though there are no message expectations.
3. Add detection of negated runners (
4. Add support for chain and multiple stub detection (
5. Add more reasoning references
6. Improve offence message
7. Remove special case
This special case treatment was added to address one use case, of an object that acts as a container for and a delegator of method calls to containing items by inheriting from an
The original code that suffered from a false detection was:
However, it has been reworked to:
and can be further simplified to:
which in case of this specific object design is more indicative of what happens.
8. Added support for
9. Fixed detection of the unnamed subject stubbing when the subject is named.
Before submitting the PR make sure the following are checked:
I’m not sure I understand the case for removing the
Or is the code removed unnecessarily complex?
I just need a bit more clarification on why we should remove this feature.
I'm sorry, but I disagree that if RSpec allows something, it's a valid (correct) use case.
As an experiment, I've run a modified version of this cop that only detects
PS Analysis of the latest
I don't have a strong opinion if this special
What do you think?
Tried simplifying that spec on RuboCop side, and it turns out another cop,
I'll try my chances with changing the enforced style for
Would you accept this pull request with the removal of
One last known use case for
I'll be more than happy to bring
Is there anything else left to be addressed in this pull request?