TwirlMatchers

io.github.frikit.twirlspec.TwirlMatchers

ScalaTest matchers over a rendered page.

Attributes

Source
TwirlMatchers.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
Self type

Members list

Value members

Concrete methods

def checkPage(page: Page, expectations: Seq[Expectation]): CheckReport

Assert against a page directly, outside a matcher.

Assert against a page directly, outside a matcher.

Attributes

Source
TwirlMatchers.scala
def display(expectations: Expectation*): Matcher[Page]

The page shows all of this, and holds to every rule standardsRules resolves to: none in the core, and each check trait's own once mixed in.

The page shows all of this, and holds to every rule standardsRules resolves to: none in the core, and each check trait's own once mixed in.

Attributes

Source
TwirlMatchers.scala
def displayOnly(expectations: Expectation*): Matcher[Page]

As display, but without the standards — for the rare page that has to break a rule, or while a legacy view is being brought up to standard.

As display, but without the standards — for the rare page that has to break a rule, or while a legacy view is being brought up to standard.

Attributes

Source
TwirlMatchers.scala
def failOnWarnings: Boolean

Whether warnings fail the test.

Whether warnings fail the test.

Attributes

Source
TwirlMatchers.scala
def matchOutlineSnapshot(file: Path): Matcher[Page]

The page's outline, as page.outline prints it, is the one saved in this file:

The page's outline, as page.outline prints it, is the one saved in this file:

render(view(form)) must matchOutlineSnapshot(Path.of("test/resources/outlines/name.txt"))

A file that is missing, or holds another outline, fails, with the page's outline or the lines that differ, and updateOutlineSnapshots writes it instead. Line endings and spaces at the ends of lines do not count. The outline's format changes only in a minor version, whose changelog says so. A snapshot asserts nothing for coverage: assertEverything still asks for what the page shows to be asserted.

Attributes

Source
TwirlMatchers.scala
def meetStandards: Matcher[Page]

Whatever standardsRules resolves to, for a spec that has its own assertions already.

Whatever standardsRules resolves to, for a spec that has its own assertions already.

Attributes

Source
TwirlMatchers.scala
def meetStandardsExcept(ruleIds: String*): Matcher[Page]

The standards, minus the named rules. Prefer fixing the page: an exclusion here hides the rule on every page it is applied to.

The standards, minus the named rules. Prefer fixing the page: an exclusion here hides the rule on every page it is applied to.

Every id must name an active rule. A misspelt id, or one for a rule this spec does not run, would exclude nothing, so it fails the match instead. The excluded rules still run, silently, so unusedExclusions can tell an exclusion that is still needed from one that has outlived its reason.

Attributes

Source
TwirlMatchers.scala
def meetStandardsExcept(ruleIds: Seq[String], because: String): Matcher[Page]

As meetStandardsExcept, with the reason for the exclusion, which a failure then reports alongside the ids:

As meetStandardsExcept, with the reason for the exclusion, which a failure then reports alongside the ids:

page must meetStandardsExcept(Seq("one-h1"), because = "legacy page, see JIRA-123")

Attributes

Source
TwirlMatchers.scala
def reportWarnings: Boolean

Whether passing tests still surface their warnings in the test output.

Whether passing tests still surface their warnings in the test output.

Attributes

Source
TwirlMatchers.scala

The active rule set as one expectation, for asserting on the result.

The active rule set as one expectation, for asserting on the result.

Attributes

Source
TwirlMatchers.scala
def standardsRules: Seq[Rule]

Which rules run alongside every display(...). Empty here; rule modules add theirs via super.standardsRules.

Which rules run alongside every display(...). Empty here; rule modules add theirs via super.standardsRules.

Attributes

Source
TwirlMatchers.scala
def unusedExclusions: Seq[String]

The rules this spec has excluded with meetStandardsExcept that found nothing on any page they were excluded from, and so exclude nothing.

The rules this spec has excluded with meetStandardsExcept that found nothing on any page they were excluded from, and so exclude nothing.

Ask it in the spec's last test, once every exclusion has run:

"need every exclusion it makes" in { unusedExclusions mustBe empty }

It knows only the tests that have run, so a run of one test can report an exclusion that another test needs.

Attributes

Source
TwirlMatchers.scala
def updateOutlineSnapshots: Boolean

Whether matchOutlineSnapshot writes the file it is given, where the file is missing or holds another outline, rather than failing. On where the environment sets TWIRLSPEC_UPDATE_SNAPSHOTS=true, to write snapshots again locally after a page was changed on purpose. Never in CI, where it would pass whatever a page had become.

Whether matchOutlineSnapshot writes the file it is given, where the file is missing or holds another outline, rather than failing. On where the environment sets TWIRLSPEC_UPDATE_SNAPSHOTS=true, to write snapshots again locally after a page was changed on purpose. Never in CI, where it would pass whatever a page had become.

Attributes

Source
TwirlMatchers.scala