-
Notifications
You must be signed in to change notification settings - Fork 341
Mock in more environments #1778
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
Conversation
hadley
commented
Apr 26, 2023
- In package environment for interactive use
- In actual test environment for testing + S3 support
* In package environment for interactive use * In actual test environment for testing + S3 support
R/mock2.R
Outdated
| #' incorporating what we've learned from the mockr, mockery, and mockthat | ||
| #' packages. | ||
| #' | ||
| #' `with_mocked_bindings()` and `local_mocked_bindings()` work by temporarily |
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.
Re: the slack message about "any good description of mocking that people might grok"
Maybe: with_mocked_bindings() and local_mocked_bindings()` work by temporarily redefining an object (usually a function) provided by a package.
I feel like "(re)defining an object" might speak to more people than talking about bindings.
R/mock2.R
Outdated
| #' implementation changes. | ||
| #' Generally, it's only safe to mock packages that you own. | ||
| #' | ||
| #' These functions do not currently affect registered S3 methods. |
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.
Is this still accurate?
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've tried to clarify this a bit more — I think the danger is that you're not just affecting the functions in your package, but all the other functions in that package. (i.e. in the rlang case you're affecting every rlang function that calls check_installed(), not just your functions).
Co-authored-by: Jennifer (Jenny) Bryan <jenny.f.bryan@gmail.com>
So interactive mocking of S3 methods works
Co-authored-by: Jennifer (Jenny) Bryan <jenny.f.bryan@gmail.com>