File tree Expand file tree Collapse file tree 1 file changed +23
-21
lines changed
Expand file tree Collapse file tree 1 file changed +23
-21
lines changed Original file line number Diff line number Diff line change @@ -346,27 +346,29 @@ defmodule MyTest do
346346 import Mock
347347
348348 test " test_name" do
349- Network .V2 .update (%User {id: 456 , name: " Jane Doe" }, %{name: " John Doe" })
350- Network .V2 .update (123 , %{name: " John Doe" , email: " john.doe@gmail.com" })
351- Network .V2 .update (nil , %{})
352-
353- # assert that `update` was called with user id 456
354- assert_called Network .V2 .update (
355- :meck .is (fn
356- %User {id: 456 } -> true
357- _ -> false
358- end ),
359- :_
360- )
361-
362- # assert that `update` was called with an email change
363- assert_called Network .V2 .update (
364- :_ ,
365- :meck .is (fn
366- %{email: " john.doe@gmail.com" } -> true
367- _ -> false
368- end )
369- )
349+ with_mock Network .V2 , [update: fn (_user , _changes ) - > :ok end ] do
350+ Network .V2 .update (%User {id: 456 , name: " Jane Doe" }, %{name: " John Doe" })
351+ Network .V2 .update (123 , %{name: " John Doe" , email: " john.doe@gmail.com" })
352+ Network .V2 .update (nil , %{})
353+
354+ # assert that `update` was called with user id 456
355+ assert_called Network .V2 .update (
356+ :meck .is (fn
357+ %User {id: 456 } -> true
358+ _ -> false
359+ end ),
360+ :_
361+ )
362+
363+ # assert that `update` was called with an email change
364+ assert_called Network .V2 .update (
365+ :_ ,
366+ :meck .is (fn
367+ %{email: " john.doe@gmail.com" } -> true
368+ _ -> false
369+ end )
370+ )
371+ end
370372 end
371373end
372374````
You can’t perform that action at this time.
0 commit comments