Skip to Content
Phoenix Web Development
book

Phoenix Web Development

by Brandon Richey
April 2018
Beginner to intermediate content levelBeginner to intermediate
406 pages
9h 33m
English
Packt Publishing
Content preview from Phoenix Web Development

Writing the poll controller test

Since we're now experts on controller tests, let's start writing our poll controller test. Open up our test/vocial_web/controllers/poll_controller_test.exs file and let's write our first major test:

 test "GET /polls", %{conn: conn} do   conn = get conn, "/polls"   assert html_response(conn, 200) =~ "My First Poll" end

Then we'll run mix test and verify that our new test passes:

$ mix test.....Finished in 0.2 seconds5 tests, 0 failuresRandomized with seed 169967

Fantastic! Remember that in our dummy object, we gave the poll a title of "My First Poll", so that's why that test is structured the way it is! One habit you’ll want to get into, especially as you’re starting out, is slightly changing tests to make sure ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Phoenix in Action

Phoenix in Action

Geoffrey Lessel
Real-Time Phoenix

Real-Time Phoenix

Stephen Bussey

Publisher Resources

ISBN: 9781787284197Supplemental Content