dwyl / dwyl/learn-elixir

Testing Phoenix Controller rendering

Open
#186 0 comments 1 reaction 1 assignee Claimed by @SimonLab View on GitHub
help wanted question technical
Dominant language
Elixir
Stars
1.7k
Forks
112
PR merge metrics
No merged PRs in 30d

Description

Hi there!

I have a basic controller "welcome" that does: `render(conn, "index.html", profile: profile)`
There are some assigns to render

I want to write a test that demonstrates that the rendering is correct

if I do:

```elixir
conn = get(conn, "/welcome")
assert html_response(conn, 200) =~"hi"
```

Since some template assigns are present in the template, my test says that a key is not present.

Using `Plug.Conn.assign(conn, :profile, %{k: v})` is ineffective.

Does anyone know how to do this? The doc is void on this or didn't find where.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.