tests/testthat/test-rmarkdown.R

test_that("Rmd documents with parameters are analyzed", {
  skip_on_cran()

  # we need to skip this test if we don't have an up-to-date version of knitr available
  if (packageVersion("knitr") < "1.11")
    skip("requires knitr 1.11 or greater")

  parameterDocPath <- file.path("resources", "params-example.Rmd")
  deps <- packrat:::fileDependencies(parameterDocPath)
  expect_true("rmarkdown" %in% deps, "all Rmd docs have an rmarkdown dependency")
  expect_true("shiny" %in% deps, "Rmd docs with parameters have a shiny dependency for the customization app")
  expect_true("stringr" %in% deps, "dependencies in parameter expressions are extracted")
})

test_that("We can discover dependencies with an evaluate hook", {
  skip_on_cran()

  path <- "resources/evaluate-deps.Rmd"
  deps <- fileDependencies.evaluate(path)
  expect_equal(deps, c("abc", "def", "ghi", "jkl"))

})

Try the packrat package in your browser

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

packrat documentation built on Sept. 8, 2023, 5:44 p.m.