Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

extracting get_messages_from_spy helper for reuse in different assert…

…ations
  • Loading branch information...
commit 1676d7a13a208f855510543f77635a6c85a256c8 1 parent c3a96a4
@nruth authored
Showing with 8 additions and 6 deletions.
  1. +8 −6 nspy.erl
View
14 nspy.erl
@@ -27,13 +27,15 @@ spy (Messages, RelayMessagesTo) ->
end.
assert_message_received(Spy, Expected) ->
+ Messages = get_messages_from_spy(Spy),
+ io:format("~n[SPY] expected ~p received ~p~n", [Expected, Messages]),
+ MessageFound = lists:any(fun(Elem) -> Elem =:= Expected end, Messages),
+ ?assert(MessageFound).
+
+get_messages_from_spy(Spy) ->
Spy ! {nspy_list_messages, self()},
- receive
- {nspy_messages, Messages} ->
- io:format("~n[SPY] expected ~p received ~p~n", [Expected, Messages]),
- MessageFound = lists:any(fun(Elem) -> Elem =:= Expected end, Messages),
- ?assert(MessageFound)
- end.
+ receive {nspy_messages, Messages} -> Messages end.
+
assert_message_received_success_test() ->
Spy = nspy:mock(),
Please sign in to comment.
Something went wrong with that request. Please try again.