struct_assert v0.4.0 StructAssert
A useful tool for testing sturct and map in Elixir.
Link to this section Summary
Functions
assert only a part of struct and map
Link to this section Functions
assert only a part of struct and map.
defmodule MyStruct do
defstruct a: 1, b: 1, z: 10
end
defmodule Example
use ExUnit.Case
import StructAssert, only: [assert_subset?: 2]
assert_subset?(%MyStruct{}, [a: 1, b: 2])
# code: assert_subset?(%MyStruct{}, [a: 1, b: 2])
# left: %{a: 1, b: 1, z: 10}
# right: %{a: 1, b: 2, z: 10}
end
Link to this function
build_expr_for_error_message(got, expect)