Mutare.Phoenix.Body (mutare_phoenix v0.1.0)

Copy Markdown View Source

:controller_body — blanks a rendered response body: the data argument of Phoenix.Controller.json/2 becomes %{}, and that of text/2 and html/2 becomes "". A surviving mutant means no test reads the response body — the action answered, with the right status and content type, and nothing checked what it said.

json(conn, %{id: user.id})        # → json(conn, %{})
text(conn, "pong")                # → text(conn, "")
conn |> html(render_page(page))   # → conn |> html("")

The blank is the emptiest value each renderer still sends cleanly: %{} encodes to {} — a well-formed, empty JSON document — while "" is a text/html body with nothing in it. A body that is already that blank literal is left alone (the mutant would change nothing).

Matches each call written directly (Phoenix.Controller.json(conn, ...)), aliased, or bare-imported (json(conn, ...), the form use MyAppWeb, :controller produces). The Plug.Conn-level bodies (send_resp/3, resp/3) are mutare_plug's :resp_body; render/3 is out of scope — its argument names a template, not a body.

Because the mutation is the original call with exactly the body argument substituted, Mutare.Transform.Overlap treats it as covering that node: on a literal text/html body the built-in :string leaves (""/"mutare") are pruned automatically, so this family supersedes them rather than double-firing on the same range. A json map literal's entries are descendants, not the body node, so the built-in mutators keep their own mutants inside it.