Pavlov.Matchers
Provides several matcher functions.
Matchers accept up to two values, actual
and expected
,
and return a Boolean.
Using “Expects” syntax, all matchers have positive and negative
forms. For a matcher eq
, there is a positive to_eq
and a negative
not_to_eq
method.
Summary↑
be_empty(list) | Checks if a Dict is empty |
be_falsey(exp) | Performs a falsey check with a given expression |
be_nil(exp) | Performs a nil check with a given expression |
be_true(exp) | Performs an equality test between a given expression and ‘true’ |
be_truthy(exp) | Performs a truthy check with a given expression |
eq(actual, expected) | Performs an equality test between two values using == |
have_exited(fun) | Tests whether the process has exited |
have_key(key, dict) | Performs has_key? operation on a Dict |
have_raised(exception, fun) | Tests whether a given exception was raised |
have_thrown(expected, fun) | Tests whether a given value was thrown |
include(member, list) | Tests whether a given value is part of an array |
Types ↑
t :: list | %{}
Functions
Specs:
- be_empty(t | char_list) :: boolean
Checks if a Dict is empty.
Example:
be_empty(%{}) # => true
be_empty(%{:a => 1}) # => false
Specs:
- be_falsey(any) :: boolean
Performs a falsey check with a given expression.
Example:
be_falsey(1) # => false
be_falsey("a") # => false
be_falsey(nil) # => true
be_falsey(false) # => true
Specs:
- be_nil(any) :: boolean
Performs a nil check with a given expression.
Example:
be_nil(nil) # => true
be_nil("a") # => false
Specs:
- be_true(any) :: boolean
Performs an equality test between a given expression and ‘true’.
Example:
be_true(1==1) # => true
be_true("a"=="b") # => false
Specs:
- be_truthy(any) :: boolean
Performs a truthy check with a given expression.
Example:
be_truthy(1) # => true
be_truthy("a") # => true
be_truthy(nil) # => false
be_truthy(false) # => false
Specs:
- eq(any, any) :: boolean
Performs an equality test between two values using ==.
Example:
eq(1, 2) # => false
eq("a", "a") # => true
Specs:
- have_exited(function) :: boolean
Tests whether the process has exited.
Example:
have_exited(fn -> exit "x" end) # => true
have_thrown(fn -> :ok end) # => false
Specs:
- have_key(node, t) :: boolean
Performs has_key? operation on a Dict.
Example:
have_key(%{:a => 1}, :a) # => true
have_key(%{:a => 1}, :b) # => false
Specs:
- have_raised(any, function) :: boolean
Tests whether a given exception was raised.
Example:
have_raised(fn -> 1 + "test") end, ArithmeticError) # => true
have_raised(fn -> 1 + 2) end, ArithmeticError) # => false
Specs:
- have_thrown(any, function) :: boolean
Tests whether a given value was thrown.
Example:
have_thrown(fn -> throw "x" end, "x") # => true
have_thrown(fn -> throw "x" end, "y") # => false
Specs:
- include(any, list | char_list) :: boolean
Tests whether a given value is part of an array.
Example:
include([1, 2, 3], 1) # => true
include([1], 2) # => false