dream_test/matchers/option
Option matchers for dream_test.
These matchers work with Option(a) values and are re-exported through
dream_test/matchers.
be_some() unwraps Some(value) so you can keep matching on the inner
value. be_none() asserts the option is empty.
Example
Some(42)
|> should
|> be_some()
|> be_equal(42)
|> or_fail_with("expected Some(42)")
Values
pub fn be_none(
value_or_result value_or_result: types.MatchResult(
option.Option(a),
),
) -> types.MatchResult(Nil)
Assert that an Option is None.
Example
None
|> should
|> be_none()
|> or_fail_with("expected None")
Parameters
value_or_result: theMatchResult(Option(a))produced byshould(or a previous matcher)
Returns
A MatchResult(Nil) that continues the chain with Nil on success.
pub fn be_some(
value_or_result value_or_result: types.MatchResult(
option.Option(a),
),
) -> types.MatchResult(a)
Assert that an Option is Some and extract its value.
If the assertion passes, the inner value is passed to subsequent matchers.
This enables chaining like be_some() |> be_equal(42).
Example
Some(42)
|> should
|> be_some()
|> be_equal(42)
|> or_fail_with("expected Some(42)")
Parameters
value_or_result: theMatchResult(Option(a))produced byshould(or a previous matcher)
Returns
A MatchResult(a):
- On
Some(value), the chain continues with the unwrappedvalue. - On
None, the chain becomes failed and later matchers are skipped.