How to have multiple assertions in an ExUnit doctest

316 Views Asked by At

I am trying to write the majority of my tests in documentation. They form a very helpful set of documentation.

Several of the tests have a moderate amount of setup and it would be cleanest if I could have several assertions in the doctest.

I tried the following but I get a warning about unused literal for the first value I am trying to assert against.

  iex> response = Raxx.response(200)
  ...> |> Raxx.set_header("content-type", "text/html")
  ...> |> Raxx.set_body("Hello, World!")
  ...> {head, body} =  Raxx.HTTP1.serialize(response)
  ...> :erlang.iolist_to_binary(head)
  "HTTP/1.1 200 OK\\r\\ncontent-length: 13\\r\\ncontent-type: text/html\\r\\n"
  ...> body
  "Hello, World!"

This is being done in the context of this PR https://github.com/CrowdHailer/raxx/pull/115

0

There are 0 best solutions below