Skip to content

Leverages pattern matching & pipeline in Elixir tests!

License

Notifications You must be signed in to change notification settings

siiibo/assert_match

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AssertMatch

Elixir CI

Leverages pattern matching & pipeline in Elixir tests!

Motivation

In short, we wanted this:

test "/some/api should work", context do
  conn
  |> post("/some/api")
  |> json_response(200)
  |> assert_match(%{
    "success" => true,
    "id" => ^context.some_fixture.id,
    "bytesize" => ^byte_size(context.some_fixture.contents)
  })
end
  • Write assertions in pipeline
  • Assert by patterns, not just concrete values (utilizing pattern-matching diffs in Elixir 1.10+)
  • Expand function calls inside pins, inspired by Ecto.Query

Introductory talk

Further leveraging pattern matches in Elixir unit tests!

Installation

def deps do
  [
    # If available in Hex
    {:assert_match, "~> 1.0", only: [:test]}
    # If not, or, if you need bleeding edge
    {:assert_match, github: "siiibo/assert_match", ref: "main", only: [:test]}
  ]
end

About

Leverages pattern matching & pipeline in Elixir tests!

Topics

Resources

License

Stars

Watchers

Forks