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

Starting our channel tests

We'll also want to finish up by writing some appropriate tests for our channels. We'll create test/vocial_web/channels/polls_channel_test.exs and start off by declaring our test module, including the appropriate set of testing macros and alias statements:

defmodule VocialWeb.PollChannelTest do  use VocialWeb.ChannelCase  alias VocialWeb.PollsChannelend

Similar to our controller tests, we'll also need to create a nice big setup block that will create a user account that we can use:

  setup do    {:ok, user} = Vocial.Accounts.create_user(%{      username: "test",      email: "test@test.com",      password: "test",      password_confirmation: "test"    })

We'll also need to make a pre-created poll:

 {:ok, poll} = Vocial.Votes.create_poll_with_options( ...
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