ExUnitAssertMatch v0.2.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

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.

Link to this function assert(type, data, opts \\ []) View Source

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.

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 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

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()).

Link to this function nullable_list_of(example) View Source

Helper function to call nullable(list_of(example)).

Link to this function nullable_literal(example) View Source

Helper function to call nullable(literal(example)).

Helper function to call nullable(map()).

Helper function to call nullable(map(example)).