April 2016
Beginner to intermediate
300 pages
6h 58m
English
It’s time to test the M of the MVC: the model. We’ll split model tests by their reliance on side effects. Phoenix, like Rumbl.ConnCase, generates a module in test/support/model_case.ex to serve as a foundation for your model tests. Crack it open so you can import our TestHelpers, like this:
| 1: | defmodule Rumbl.ModelCase do |
| - | use ExUnit.CaseTemplate |
| - | |
| - | using do |
| 5: | quote do |
| - | alias Rumbl.Repo |
| - | |
| - | import Ecto |
| - | import Ecto.Changeset |
| 10: | import Ecto.Query, only: [from: 1, from: 2] |
| - | import Rumbl.TestHelpers |
| - | import Rumbl.ModelCase |
| - | end |
| - | end |
| 15: | |
| - | setup tags do |
| - | unless tags[:async] do |
| - |