struct_assert v0.4.0 StructAssert

A useful tool for testing sturct and map in Elixir.

Link to this section Summary

Link to this section Functions

Link to this macro assert_subset?(got, expect) (macro)

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)
Link to this macro expect_value_to_map(expect) (macro)
Link to this macro got_value_to_map(got) (macro)