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

Shortcut for expecting method call with matching arguments & stub calls with non-matching arguments #489

Open
floehopper opened this issue Aug 27, 2020 · 1 comment

Comments

@floehopper
Copy link
Member

floehopper commented Aug 27, 2020

See #487 (comment) by @Bennet-Sunder. Maybe something like this:

foo.expects(:bar).with(123).once.but_otherwise_stubs

foo.bar(123) # expected
foo.bar(456) # stubbed
foo.bar('a', 'b', 'c') # stubbed
@floehopper
Copy link
Member Author

My initial thought is that the chained but_otherwise_stubs method goes a bit against the grain of the internal model, because it would need to create a separate Expectation instance rather than just modifying the one from foo.expects(:bar). However, I'm pretty sure it would be possible to implement.

My other concern is whether this is a common enough scenario to make having a shortcut worthwhile. Nobody else has asked for anything similar in over 10 years!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant