From 8ea3ff1b90704ea8762cd01de45a268414679676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariano=20Vall=C3=A9s?= Date: Wed, 29 Nov 2023 23:18:29 +0100 Subject: [PATCH 1/2] Failing test for assert called with a map --- test/mock_test.exs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/mock_test.exs b/test/mock_test.exs index 2326dfb..4e20e73 100644 --- a/test/mock_test.exs +++ b/test/mock_test.exs @@ -109,6 +109,15 @@ defmodule MockTest do end end + test "assert called with a map" do + with_mock(Map, [ + get: fn (_map, _key) -> "a" end + ]) do + Map.get(%{a: "1", b: "2"}, :a) + assert_called(Map.get(%{a: "1"}, :a)) + end + end + test "assert_called_exactly" do with_mock String, [reverse: fn(x) -> 2*x end] do String.reverse(2) From b8cc0a8bbc923d3d80ddc5270064de4ed227f10a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariano=20Vall=C3=A9s?= Date: Wed, 29 Nov 2023 23:33:18 +0100 Subject: [PATCH 2/2] Make use of refute --- test/mock_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/mock_test.exs b/test/mock_test.exs index 4e20e73..2f3b88d 100644 --- a/test/mock_test.exs +++ b/test/mock_test.exs @@ -114,7 +114,7 @@ defmodule MockTest do get: fn (_map, _key) -> "a" end ]) do Map.get(%{a: "1", b: "2"}, :a) - assert_called(Map.get(%{a: "1"}, :a)) + refute called(Map.get(%{a: "1"}, :a)) end end