Skip to content

Commit

Permalink
Improve assert_reply error messages (#19)
Browse files Browse the repository at this point in the history
Currently the error assertions happen directly on _all_ the messages
that the channel has received, when we only very specifically care about
the specific reply to our message.

This PR splits that assertion into two steps, the first step gets the
reply, and the second step asserts on the expected status and reply.
They are asserted together so that when there's an error you get
detailed information about what the error payload is, otherwise your
initial test failure may simply tell you something like ":ok does not
equal :error"
  • Loading branch information
axelson authored Jul 29, 2024
1 parent 43dab61 commit f71f7e9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/channel_spec/testing.ex
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ defmodule ChannelSpec.Testing do
) do
quote location: :keep do
socket = Process.get(unquote(ref))
assert_reply(unquote(ref), unquote(status), reply = unquote(reply))
assert_reply(unquote(ref), status, reply)
assert {unquote(status), unquote(reply)} = {status, reply}

normalized_reply = reply |> Jason.encode!() |> Jason.decode!()

Expand Down

0 comments on commit f71f7e9

Please sign in to comment.