Creating the controller code (with tests)

Next, following the example of other bits of functionality we've been adding along the way in this chapter, we'll also simultaneously write some tests as we go along to make the general process of testing all of this significantly easier. The controller code will start off like this:

defmodule VocialWeb.UserController do  use VocialWeb, :controller  def new(conn, _) do    conn  end  def create(conn, _) do    conn  end  def show(conn, _) do    conn  endend

The test code (located at test/vocial_web/controllers/user_controller_test.exs) will start off like this:

defmodule VocialWeb.UserControllerTest do  use VocialWeb.ConnCase  test "GET /users/new", %{conn: conn} do    conn = get conn, "/users/new" assert html_response(conn, ...

Get Phoenix Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.