Skip to content
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

Inconsistent behavior of SubjectStub #705

ixti opened this issue Oct 12, 2018 · 2 comments


Copy link

commented Oct 12, 2018

# fails
expect(subject).to receive(:my_method)
expect(subject).to receive(:my_method).and_call_original
expect(subject).to receive(:my_method).and_wrap_original { |m, *| }

# passes
expect(subject).not_to receive(:my_method)

It should either fail on not_to and to_no; or it should pass when matcher has and_call_original or and_wrap_original modifiers.


This comment has been minimized.

Copy link

commented Dec 14, 2018

Somewhat related: with the current implementation/error message it’s not clear to me why that would be a bad thing to begin with. When I stub a method on the subject it’s exactly what I want because I don’t care about testing #my_method itself, only that it gets called, e.g. composing a result.


This comment has been minimized.

Copy link

commented Dec 14, 2018

The problem of stubbing the object under test is described in “Smell 1: Stubject” of, and in this Thoughtbot blog post:

But yes, the cop‘s message is very vague.

@pirj pirj referenced this issue May 15, 2019
5 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.