Open
Description
I'm running into situations where I need to validate that the headers and parameters I sent were properly encoded and can be decoded, so I do something like this:
Sham.expect(sham, "POST", "/some/path", fn conn ->
assert ["application/json"] = Plug.Conn.get_req_header(conn, "content-type")
assert ["application/json"] = Plug.Conn.get_req_header(conn, "accept")
Plug.Conn.resp(conn, 200, Jason.encode!(%{"foo" => "bar"}))
end)
But the error I end up getting when running tests is
** (Jason.DecodeError) unexpected byte at position 0: 0x2A ("*")
This my body parser failing, but what I didn't see spit out was the assertion error. My workaround for now is to simply catch the parse error and spit out the error to the warning logs and capture it.
It appears the assertion error is caught and returned as the response body from sham.
** (ExUnit.AssertionError) \n\nmatch (=) failed\ncode: assert [ ..... snip
Metadata
Metadata
Assignees
Labels
No labels