tests/testthat/test-utils.R

test_that("replace_in_file works", {
  tpf <- tempfile()
  write("hola hola hey", tpf)
  replace_in_file(
    tpf,
    "hola",
    "hello"
  )
  res <- readLines(
    tpf
  )
  #' @description The modified file should contain "hello"
  expect_true(
    grepl("hello", res)
  )
  #' @description The modified file should contain "hola"
  expect_false(
    grepl("hola", res)
  )
})
ThinkR-open/testdown documentation built on April 17, 2023, 3:21 a.m.