We need to start off by creating a new file to handle the tests for our Poll Controller. Open up test/vocial_web/controllers/poll_controller_test.exs and begin to update the tests in it. Its contents should be as follows:
defmodule VocialWeb.PollControllerTest do use VocialWeb.ConnCase test "GET /polls", %{conn: conn} do {:ok, poll} = Vocial.Votes.create_poll_with_options(%{title: "Poll 1"}, [ "Choice 1", "Choice 2", "Choice 3" ]) conn = get(conn, "/polls") assert html_response(conn, 200) =~ poll.title Enum.each(poll.options, fn option -> assert html_response(conn, 200) =~ "#{option.title}" assert html_response(conn, 200) =~ ": #{option.votes}" end) endend
We should already have a user created and ready ...