vendredi 13 avril 2018

warning variable unused in assert

I can test the content after a redirection like this

assert "/url" = redir_path = redirected_to(conn, 302)
conn = get(recycle(conn), redir_path)
assert html_response(conn, 200) ==  "Content after redirection"

But I cannot add a param variable to the assert url like this:

id = 10
assert "/url/#{id}" = redir_path = redirected_to(conn, 302)

It complains with:

cannot invoke remote function id/0 inside match

So if I just define the path like this before using it:

url_path = "/url/%{id}"
assert url_path = redir_path = redirected_to(conn, 302)

warning: variable "url_path" is unused

?? unusued? is it being used inside the assert...

Not sure how to silence that warning or how to approach this.

The code is similar to Chris's response here:

https://elixirforum.com/t/following-redirection-in-controllertests/10084

Aucun commentaire:

Enregistrer un commentaire