1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
test_that("can build README in root directory", {
skip_on_cran()
pkg <- local_package_create()
suppressMessages(usethis::with_project(pkg, use_readme_rmd()))
suppressMessages(build_readme(pkg))
expect_true(file_exists(path(pkg, "README.md")))
expect_false(file_exists(path(pkg, "README.html")))
})
test_that("can build README in inst/", {
skip_on_cran()
pkg <- local_package_create()
suppressMessages(usethis::with_project(pkg, use_readme_rmd()))
dir_create(pkg, "inst")
file_move(
path(pkg, "README.Rmd"),
path(pkg, "inst", "README.Rmd")
)
suppressMessages(build_readme(pkg))
expect_true(file_exists(path(pkg, "inst", "README.md")))
expect_false(file_exists(path(pkg, "README.Rmd")))
expect_false(file_exists(path(pkg, "README.md")))
expect_false(file_exists(path(pkg, "inst", "README.html")))
})
test_that("useful errors if too few or too many", {
pkg <- local_package_create()
expect_snapshot(build_readme(pkg), error = TRUE)
suppressMessages(usethis::with_project(pkg, use_readme_rmd()))
dir_create(pkg, "inst")
file_copy(path(pkg, "README.Rmd"), path(pkg, "inst", "README.Rmd"))
expect_snapshot(build_readme(pkg), error = TRUE)
})
|