Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support guards in assert_push #5791

Open
marcandre opened this issue Apr 22, 2024 · 1 comment
Open

Support guards in assert_push #5791

marcandre opened this issue Apr 22, 2024 · 1 comment

Comments

@marcandre
Copy link
Contributor

We can't use guards with assert_push and al., e.g.:

assert_push "presence_state", state when state == %{}

Environment

  • Elixir version (elixir -v): Erlang/OTP 26 [erts-14.2.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]
  • Phoenix version (mix deps): 1.7.12
  • Operating system:

Actual behavior

    error: cannot invoke remote function :erlang.==/2 inside a match
    │
 49 │     assert_push "presence_state", state when state == %{}
    │                                                    ^
    │
    └─ test/enaia_web/channels/online_users_channel_test.exs:49:52: EnaiaWeb.OnlineUsersChannelTest.assert_state_push/1

Expected behavior

It would ideally produce code equivalent to

    assert_receive %Phoenix.Socket.Message{
                     event: "presence_state",
                     payload: state
                   }
                   when state == %{}
@josevalim josevalim changed the title assert_push & al. badly expands its arguments Support guards in assert_push May 17, 2024
@josevalim
Copy link
Member

A pull request will be welcome (please ping me if you send one!).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants