diff --git a/tests/testthat/test-cpp11.R b/tests/testthat/test-cpp11.R index b26be2060..b45e6c909 100644 --- a/tests/testthat/test-cpp11.R +++ b/tests/testthat/test-cpp11.R @@ -24,10 +24,10 @@ test_that("use_cpp11() creates files/dirs, edits DESCRIPTION and .gitignore", { expect_proj_dir("src") ignores <- read_utf8(proj_path("src", ".gitignore")) - expect_true(all(c("*.o", "*.so", "*.dll") %in% ignores)) + expect_contains(ignores, c("*.o", "*.so", "*.dll")) namespace <- read_utf8(proj_path("NAMESPACE")) - expect_true(any(grepl("useDynLib", namespace))) + expect_match(namespace, "useDynLib", all = FALSE) }) test_that("check_cpp_register_deps is silent if all installed, emits todo if not", { diff --git a/tests/testthat/test-github-actions.R b/tests/testthat/test-github-actions.R index 5c6d3b4ba..808f3a173 100644 --- a/tests/testthat/test-github-actions.R +++ b/tests/testthat/test-github-actions.R @@ -104,10 +104,10 @@ test_that("use_github_action() accepts a name", { yml <- yaml::yaml.load_file(proj_path(".github/workflows/R-CMD-check.yaml")) expect_identical(yml$name, "R-CMD-check") - expect_identical(names(yml$jobs), "R-CMD-check") + expect_named(yml$jobs, "R-CMD-check") readme_lines <- read_utf8(proj_path("README.md")) - expect_true(any(grepl("R-CMD-check", readme_lines))) + expect_match(readme_lines, "R-CMD-check", all = FALSE) # .github has been Rbuildignored expect_true(is_build_ignored("^\\.github$")) @@ -130,17 +130,17 @@ test_that("use_tidy_github_actions() configures the full check and pr commands", yml <- yaml::yaml.load_file(proj_path(".github/workflows/R-CMD-check.yaml")) expect_identical(yml$name, "R-CMD-check") - expect_identical(names(yml$jobs), "R-CMD-check") + expect_named(yml$jobs, "R-CMD-check") size_build_matrix <- length(yml[["jobs"]][["R-CMD-check"]][["strategy"]][["matrix"]][["config"]]) - expect_true(size_build_matrix >= 6) # release, r-devel, 4 previous versions + expect_gte(size_build_matrix, 6) # release, r-devel, 4 previous versions expect_proj_file(".github/workflows/pkgdown.yaml") expect_proj_file(".github/workflows/test-coverage.yaml") expect_proj_file(".github/workflows/pr-commands.yaml") readme_lines <- read_utf8(proj_path("README.md")) - expect_true(any(grepl("R-CMD-check", readme_lines))) - expect_true(any(grepl("test coverage", readme_lines))) + expect_match(readme_lines, "R-CMD-check", all = FALSE) + expect_match(readme_lines, "test coverage", all = FALSE) }) diff --git a/tests/testthat/test-helpers.R b/tests/testthat/test-helpers.R index 8afbd90ff..22ceb5cf1 100644 --- a/tests/testthat/test-helpers.R +++ b/tests/testthat/test-helpers.R @@ -69,7 +69,7 @@ test_that("use_dependency() upgrades a dependency", { expect_message(use_dependency("usethis", "Imports"), "Moving 'usethis'") expect_match(desc::desc_get("Imports"), "usethis") - expect_false(grepl("usethis", desc::desc_get("Suggests"))) + expect_no_match(desc::desc_get("Suggests"), "usethis") }) ## https://github.com/r-lib/usethis/issues/99 @@ -82,7 +82,7 @@ test_that("use_dependency() declines to downgrade a dependency", { expect_warning(use_dependency("usethis", "Suggests"), "no change") expect_match(desc::desc_get("Imports"), "usethis") - expect_false(grepl("usethis", desc::desc_get("Suggests"))) + expect_no_match( desc::desc_get("Suggests"), "usethis") }) test_that("can add LinkingTo dependency if other dependency already exists", { @@ -95,7 +95,7 @@ test_that("can add LinkingTo dependency if other dependency already exists", { ) deps <- proj_deps() expect_setequal(deps$type, c("Imports", "LinkingTo")) - expect_true(all(deps$package == "rlang")) + expect_setequal(deps$package, "rlang") }) test_that("use_dependency() does not fall over on 2nd LinkingTo request", { @@ -121,6 +121,6 @@ test_that("use_dependency() can level up a LinkingTo dependency", { expect_snapshot(use_package("rlang")) deps <- proj_deps() expect_setequal(deps$type, c("Imports", "LinkingTo")) - expect_true(all(deps$package == "rlang")) + expect_setequal(deps$package, "rlang") }) diff --git a/tests/testthat/test-use_standalone.R b/tests/testthat/test-use_standalone.R index ba4ee9cab..638411c27 100644 --- a/tests/testthat/test-use_standalone.R +++ b/tests/testthat/test-use_standalone.R @@ -11,7 +11,8 @@ test_that("can import standalone file with dependencies", { desc <- proj_desc() imports <- proj_desc()$get_field("Imports") - expect_true(grepl("rlang \\(", imports)) + expect_length(imports, 1) + expect_match(imports, "rlang") }) test_that("can use full github url", {