Skip to main content

to_contain

Method of AlephExpectation.

Overloads

NameDescription
to_contain(const Object expected) -> voidRecords a failure unless the actual value contains the expected value.
to_contain(const Object expected, const Map options) -> voidRecords a failure unless the actual value contains the expected value.

to_contain(const Object expected) -> void

Records a failure unless the actual value contains the expected value.

Parameters

  • expected: The item or substring expected to be present.

Returns

Nothing. Failed expectations are collected in the active test result.

Example


expect([1, 2, 3]).to_contain(2)

to_contain(const Object expected, const Map options) -> void

Records a failure unless the actual value contains the expected value.

Parameters

  • expected: The item or substring expected to be present.
  • options: Optional matcher options.
    • message (String): Custom failure message to record when the matcher fails.
    • stop (Bool): Stops collecting further expectations in the current test when this matcher fails.

Returns

Nothing. Failed expectations are collected in the active test result.

Example


expect("hamiltonian").to_contain("ton")