-
-
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
False positives on SubjectStub? #981
Comments
Is this a complete example? First of what comes to mind is an odd usage of Another thing is how you use class A
def a
b
end
def b
1
end
end
RSpec.describe(A) do
specify do
subject.a
expect(subject).to have_received(:b)
end
end
Do you happen to stub your The example you have referenced does not look like a false positive to me at all. |
It is a complete example yeah, there's no mocking of subject. The only thing that happens before this is setting up the subject with spies, where dependency injection is used.
Typically I'm not testing subjects directly and testing spies instead so I agree, however there are a few tests in my project that tests subject methods like this one. Didn't realise |
It depends on how you set the boundaries. Sorry, I can't really reason about this spec without seeing the whole thing. And I'm still struggling to understand how |
Fair enough, in the case of this spec I can definitely remove it and the other place I noticed this cop being raised could do with some refactoring to check spies instead of the subject itself. Relatively old specs now that I look at it. Thanks for the info above. Definitely avoidable. |
You're always welcome! |
Using version 1.42.0.
This spec is not stubbing subject, it's testing that a method within the subject gets called when the main entry point (
call
) is called.This seems like a false positive to me, it shouldn't be raising an offence here. According to the docs this is how it's supposed to work. Shouldn't this cop only look for
allow
statements though, and notexpect
?The text was updated successfully, but these errors were encountered: