O'Reilly logo

Programming Phoenix by Jose Valim, Bruce Tate, Chris McCord

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Communicating with a Test Channel

Let’s see how easy it is to test our VideoChannel features. Our plan is simple. We’re going to set up some data to share across our tests and then sign the user in within our setup block. Then, we can write some independent tests against that live connection.

Create a new rumbrella/apps/rumbl/test/channels/video_channel_test.exs file that looks like this:

1: defmodule​ Rumbl.Channels.VideoChannelTest ​do
use​ Rumbl.ChannelCase
import​ Rumbl.TestHelpers
5:  setup ​do
user = insert_user(​name:​ ​"​​Rebecca"​)
video = insert_video(user, ​title:​ ​"​​Testing"​)
token = Phoenix.Token.sign(@endpoint, ​"​​user socket" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required