Skip to content

A useful tool for testing sturct and map in Elixir.

Notifications You must be signed in to change notification settings

tokubass/ex_struct_assert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StructAssert

A useful tool for testing sturct and map in Elixir.

Examples

  defmodule MyStruct do
    defstruct a: 1, b: 1, z: 10
  end

  defmodule Example
    use ExUnit.Case
    use StructAssert

    test "example" do
      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}

      assert_subset(%MyStruct{}, [a: 1, b: &is_atom(&1)])
      # code:  assert_subset(%MyStruct{}, [a: 1, b: &(is_atom(&1))])
      # left:  %{a: 1, z: 10, b: 1}
      # right: %{a: 1, z: 10, b: &:erlang.is_atom/1}
    end

  end

Installation

If available in Hex, the package can be installed by adding struct_assert to your list of dependencies in mix.exs:

def deps do
  [{:struct_assert, ">= 0.0.0"}]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/struct_assert.

About

A useful tool for testing sturct and map in Elixir.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages