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

Correctly reset original binding values when using setup-mocks #45

Merged
merged 2 commits into from
Jun 19, 2023

Conversation

jo-sm
Copy link
Contributor

@jo-sm jo-sm commented Jun 19, 2023

This PR fixes setup-mocks by correctly resetting the original binding values. Previously they would be called as if they were functions, which can cause issues in many cases.

jo-sm added 2 commits June 19, 2023 17:11
A regression was caused by #28, such that the original binding values
would be called when put back (due to the change to always reinstantiate
the mocks for each test case). This wasn't covered by the tests and for
non-side-effecting functions, this wouldn't surface, but for non-functions
and for side-effecting functions, calling the original function could
cause issues.

This commit fixes that by wrapping the original binding values in functions
just like the mocks.

This commit also adds some useful comments and renames binding symbols since
every time I look at `with-scoped-redefs` I get confused since the function
was basically copied from `with-redefs`, and the naming there is a bit terse.

Fixes #44.
@jo-sm jo-sm merged commit 95c23e0 into master Jun 19, 2023
@jo-sm jo-sm deleted the fix-mocking-again branch June 19, 2023 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant