From b3e865781e0ff4370243efd8291cb2a8dc3392e7 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Thu, 24 Oct 2024 13:33:01 -0700 Subject: [PATCH] further condense test code --- tests/testthat/test-commented_code_linter.R | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/testthat/test-commented_code_linter.R b/tests/testthat/test-commented_code_linter.R index 6728b7bbd..5154a5a94 100644 --- a/tests/testthat/test-commented_code_linter.R +++ b/tests/testthat/test-commented_code_linter.R @@ -104,20 +104,12 @@ test_that("commented_code_linter can detect operators in comments and lint corre ) }) -test_that("commented_code_linter can detect commented code ending with a base pipe", { - skip_if_not_r_version("4.1.0") +test_that("commented_code_linter can detect commented code ending with pipes", { + linter <- commented_code_linter() + lint_msg <- rex::rex("Remove commented code.") - expect_lint( - "# f() |>", - rex::rex("Remove commented code."), - commented_code_linter() - ) -}) + expect_lint("# f() %>%", lint_msg, linter) -test_that("commented_code_linter can detect commented code ending with a {magrittr} pipe", { - expect_lint( - "# f() %>%", - rex::rex("Remove commented code."), - commented_code_linter() - ) + skip_if_not_r_version("4.1.0") + expect_lint("# f() |>", lint_msg, linter) })