-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
Mock a module only from the perspective of a specific module #34
Comments
How is it possible to do that? Parse transform? |
The idea was to actually change the code under test instead, by replacing all calls to that module with a call to the mock module. With the downside of course that you change the code under test, which for some kinds of verification might be too much. |
I though that we might achieve that by forcing all processes in the Erlang VM to apply save_calls flag and whenever a mocked module is called inspect the caller history and see from what module the call was made. I even asked a question on StackOverflow about that. But it seems there is no easy programmatic way to do that. |
Possibly also too heavy-weight. |
Closing and documenting in the wiki instead: https://github.com/eproxus/meck/wiki#feature-ideas Please comment here if you have information or requests to add, and/or want to discuss a PR or possible implementation proposal. |
It should be possible to mock a module only from the perspective of another specific module. This would allow mocking the
file
module for example, which is not possible due to its use from the code module (resulting in a crash when replacing the module).Implementation Proposal
Instead of replacing and compiling the mock module globally, a mocked module is created with another name than the original. Then all calls to the original module in the module under test is replaced with calls to the new mocked module.
The text was updated successfully, but these errors were encountered: