tests/testthat/helper-mocks.R

local_dl_and_read <- function(.env = parent.frame()) {
  local_mocked_bindings(
    dl_and_read = function(url) {
      filename <- stringr::str_replace_all(
        basename(url),
        "[^[:alnum:]]",
        "-"
      )
      path <- test_path("fixtures", filename)
      readr::read_lines(path)
    },
    .env = .env
  )
}

Try the gutenbergr package in your browser

Any scripts or data that you put into this service are public.

gutenbergr documentation built on June 8, 2025, 11:26 a.m.