8000 Test assertions are swallowed inside expect · Issue #3 · andrewtimberlake/sham · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Test assertions are swallowed inside expect #3
Open
@warmwaffles

Description

@warmwaffles

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0