October 2019
Intermediate to advanced
358 pages
8h 22m
English
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.
First we’ll need a few helper functions to make it easier to create users and videos. Make the file test/support/test_helpers.ex look like this:
| | defmodule RumblWeb.TestHelpers do |
| | |
| | defp default_user() do |
| | %{ |
| | name: "Some User", |
| | username: "user#{System.unique_integer([:positive])}", |
| | password: "supersecret" |
| | } |
| | end |
| | |
| | def insert_user(attrs ... |
Read now
Unlock full access