https://github.com/siiibo/assert_match
Leverages pattern matching & pipeline in Elixir tests!
https://github.com/siiibo/assert_match
elixir testing
Last synced: 3 months ago
JSON representation
Leverages pattern matching & pipeline in Elixir tests!
- Host: GitHub
- URL: https://github.com/siiibo/assert_match
- Owner: siiibo
- License: apache-2.0
- Created: 2022-09-13T12:21:01.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-01-31T06:52:51.000Z (over 1 year ago)
- Last Synced: 2025-10-21T15:51:30.416Z (8 months ago)
- Topics: elixir, testing
- Language: Elixir
- Homepage:
- Size: 62.5 KB
- Stars: 8
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AssertMatch
[](https://github.com/siiibo/assert_match/actions/workflows/build.yml)
Leverages pattern matching & pipeline in Elixir tests!
## Motivation
In short, we wanted this:
```elixir
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](https://hexdocs.pm/ecto/Ecto.Query.html#module-interpolation-and-casting)
### Introductory talk
## Installation
```elixir
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
```
