ExUnitAssertMatch v0.3.0 ExUnitAssertMatch View Source
Provedes functionality to assert that given data structure is as expected.
The usage is on README.
Link to this section Summary
Functions
Matches everything
Assert that given data
match type
specification
Matches any atom
Matches any binary. You can pass regex
Same as literal/1
Matches any float
Matches any integer
Matches any list
Matches a list that satisfies example
specification
Matches if they are equal.
This uses ==
to compare them
Matches any map
Matches a map that satisfies example
specification
Matches if it satisfies example
or equals to nil
Helper function to call nullable(atom())
Helper function to call nullable(binary())
Helper function to call nullable(float())
Helper function to call nullable(integer())
Helper function to call nullable(list())
Helper function to call nullable(list_of(example))
Helper function to call nullable(literal(example))
Helper function to call nullable(map())
Helper function to call nullable(map(example))
Link to this section Functions
Matches everything.
Assert that given data
match type
specification.
alias ExUnitAssertMatch, as: Match
Match.assert Match.binary(), "Hello"
#=> pass
Match.assert Match.binary(), 123
#=> fail
This calls ExUnit assert
macro internally.
Matches any atom.
Matches any binary. You can pass regex.
alias ExUnitAssertMatch, as: Match
Match.assert Match.binary(), "foo"
#=> pass
Match.assert Match.binary(regex: ~r/bar/), "foo"
#=> fail
Same as literal/1
.
Matches any float.
Matches any integer.
Matches any list.
Matches a list that satisfies example
specification.
alias ExUnitAssertMatch, as: Match
Match.assert Match.list_of(Match.binary()), ["1", "2"]
#=> pass
Match.assert Match.list_of(Match.binary()), ["1", 2]
#=> fail
Matches if they are equal.
This uses ==
to compare them.
Matches any map.
Matches a map that satisfies example
specification.
alias ExUnitAssertMatch, as: Match
Match.assert Match.map(%{name: Match.binary()}), %{name: "John"}
#=> pass
Match.assert Match.map(%{name: Match.binary()}), %{name: nil}
#=> fail
You can assert that the map and example
have exact same keys.
Match.assert Match.map(%{name: Match.binary()}, exact_same_keys: true), %{name: "Bob", age: 28}
#=> fail
Matches if it satisfies example
or equals to nil
.
Helper function to call nullable(atom())
.
Helper function to call nullable(binary())
.
Helper function to call nullable(float())
.
Helper function to call nullable(integer())
.
Helper function to call nullable(list())
.
Helper function to call nullable(list_of(example))
.
Helper function to call nullable(literal(example))
.
Helper function to call nullable(map())
.
Helper function to call nullable(map(example))
.