Implement a custom version of assert_receive.

This commit is contained in:
Felipe Sere
2016-04-18 23:08:21 +01:00
parent 45619f6bdb
commit 211355b1a5
2 changed files with 18 additions and 2 deletions

View File

@@ -33,7 +33,14 @@ defmodule BlankAssertions do
end
else
quote do
ExUnit.Assertions.assert_receive(var!(expr), 100)
receive do
unquote(expr) -> :ok
after
100 -> {:messages, messages} = Process.info(self(), :messages)
mailbox = Enum.map_join(messages, ", ", &inspect/1)
message = inspect(unquote(expr))
ExUnit.Assertions.flunk("message #{message} not found in [#{mailbox}]")
end
end
end
end