Skip to contents

expect_rule_red() is a testthat expectation: found has a finding of rule with the status of level that the key allow does not cover. expect_rule_green() is the opposite: found has a PASS line of rule, so the rule ran, and no WARN or FAIL finding of rule.

Usage

expect_rule_red(rule, found, level = "fail")

expect_rule_green(rule, found)

Arguments

rule

The name of the rule.

found

The findings, as folder_findings() gives them.

level

The level of the rule in the rule set of the test project, "fail" or "warn". expect_rule_red() looks for a finding with this status.

Value

found, invisibly.

Details

Each call records rule as red or green, whether the expectation passes or fails. expect_rules_covered() reads these records. An allowed finding has " (allowed)" in its detail, and expect_rule_red() does not count it. The helpers need the package testthat.

See also

Other test helpers: expect_rules_covered()

Examples

found <- data.frame(
  rule = "no_capitals",
  status = "FAIL",
  path = "Notes.txt",
  detail = "Notes.txt: a capital letter in the name. Fix: rename it."
)
if (requireNamespace("testthat", quietly = TRUE)) {
  checkit::expect_rule_red("no_capitals", found)
}