Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update assertions.ex #1

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions lib/assertions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ defmodule Assertions do
true

"""
@spec assert_map_in_list(map, [map], [any]) :: true | no_return
@spec assert_map_in_list(map, [map], comparison) :: true | no_return
@spec assert_map_in_list(map, [map], nonempty_list(any)) :: true | no_return
defmacro assert_map_in_list(map, list, keys_or_comparison) do
assertion =
assertion(
Expand All @@ -282,13 +281,6 @@ defmodule Assertions do
keys = unquote(stringify_list(keys_or_comparison))
message = "Map matching the values for keys `#{keys}` not found"
{Enum.member?(list, map), map, list, message}
else
comparison = keys_or_comparison
map = unquote(map)
list = unquote(list)
message = "Map not found in list using given comparison"

{Enum.any?(list, &comparison.(map, &1)), map, list, message}
end

if in_list? do
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Assertions.MixProject do
[
app: :assertions,
version: "0.19.0",
elixir: "~> 1.7",
elixir: "~> 1.14",
deps: deps(),
description: description(),
package: package(),
Expand Down