dream_test/matchers/equality

Equality matchers for dream_test.

These matchers compare values using Gleam’s structural equality and are re-exported through dream_test/matchers.

Example

2 + 3
|> should
|> be_equal(5)
|> or_fail_with("2 + 3 should equal 5")

Values

pub fn be_equal(
  value_or_result value_or_result: types.MatchResult(a),
  expected expected: a,
) -> types.MatchResult(a)

Assert that a value equals the expected value.

Uses Gleam’s structural equality (==). Works with any type that supports equality comparison.

Example

2 + 3
|> should
|> be_equal(5)
|> or_fail_with("2 + 3 should equal 5")

Parameters

  • value_or_result: the MatchResult(a) produced by should (or a previous matcher)
  • expected: the value you expect the actual value to equal

Returns

A MatchResult(a):

  • On success, preserves the original value for further chaining.
  • On failure, the chain becomes failed and later matchers are skipped.
pub fn not_equal(
  value_or_result value_or_result: types.MatchResult(a),
  unexpected unexpected: a,
) -> types.MatchResult(a)

Assert that a value does not equal the unexpected value.

Uses Gleam’s structural inequality (!=).

Example

10 + 3
|> should
|> not_equal(3)
|> or_fail_with("10 + 3 should not equal 3")

Parameters

  • value_or_result: the MatchResult(a) produced by should (or a previous matcher)
  • unexpected: the value you expect the actual value to not equal

Returns

A MatchResult(a):

  • On success, preserves the original value for further chaining.
  • On failure, the chain becomes failed and later matchers are skipped.
Search Document