Phoenix.ConnTest there’s the
html_response function to assert that a particular status code is returned.
However, what if I want to check that a particular status code is not returned?
The scenario is that, while most controller actions require authentication, there are a few actions that don’t require any authentication, and I’d like to make sure that I properly excluded them from the authentication requirement. Therefore, I’d like to see that the status code is not 401.
In normal ExUnit there’s the
refute function as the counterpart to
assert. But that doesn’t seem to hold here. Even if I write
refute text_response(conn, 401), the error already occurred.
Of course I’ll have further tests to ensure that those controller actions actually work as intended. But I thought it’d be nice to also have a particular test dedicated to checking the authentication requirement. Is there any way to do it?