-
Notifications
You must be signed in to change notification settings - Fork 76
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
Make stub_with work with skip_optional_callbacks #96
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -524,7 +524,9 @@ defmodule Mox do | |
|
||
for behaviour <- behaviours, | ||
{fun, arity} <- behaviour.behaviour_info(:callbacks) do | ||
stub(mock, fun, :erlang.make_fun(module, fun, arity)) | ||
if function_exported?(mock, fun, arity) do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something along these lines:
We should add a test that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that you should always implement the full behaviour in the Stub module, but enforcing this would possibly break a lot of current usage. Currently this test succeeds:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be happy to change that you can only stub full behaviour implementations of course. |
||
stub(mock, fun, :erlang.make_fun(module, fun, arity)) | ||
end | ||
end | ||
|
||
mock | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should only skip if they are optional though. Otherwise we can stop raising for functions that are required .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure because this checks if the mock function had been defined on the mock. So when you use
skip_optional_callbacks
with a specific set of callbacks it still works correctly.Just checking if it's optional wouldn't cover that, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I misunderstood. Looks good as is then!