Skip to content

Commit

Permalink
Better advice for mocked base functions.
Browse files Browse the repository at this point in the history
If the function is used as an argument somewhere, binding NULL to it causes that call to fail. Instead bind the actual function, and then mock that.

I think it might also be necessary to do the same for the other default packages, but I'm not certain. Will likely know better at the end of TDD!
  • Loading branch information
jonthegeek committed Aug 15, 2024
1 parent f060cce commit 193d4da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions R/mock2.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
#'
#' To mock a function in the base package, you need to make sure that you
#' have a binding for this function in your package. It's easiest to do this
#' by binding the value to `NULL`. For example, if you wanted to mock
#' by binding the name to the function. For example, if you wanted to mock
#' `interactive()` in your package, you'd need to include this code somewhere
#' in your package:
#'
#' ```R
#' interactive <- NULL
#' interactive <- interactive
#' ```
#'
#' Why is this necessary? `with_mocked_bindings()` and `local_mocked_bindings()`
Expand Down
4 changes: 2 additions & 2 deletions man/local_mocked_bindings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 193d4da

Please sign in to comment.