elixir - Testing Phoenix.Controller.redirect -


i'm new phoenix , i'm testing custom plug should redirect /404.html page if condition not met. code works correctly when try success/failure paths i'm having difficult time understanding why testing approach blowing up.

the test failure boils down following:

%plug.conn{} |> phoenix.controller.redirect(to: "/404.html") 

my expectation should return conn object can run assertions on. however, when try run above code following error:

** (undefinedfunctionerror) function plug.conn.send_resp/4 undefined or private. did mean 1 of: 

this bit weird since phoenix.controller module implements send_resp/4 function , imports plug.conn @ top of definition.

why ignoring function , trying hit plug.conn directly? i'm not calling private function, public function delegating it, should kosher unless i've missed obvious. there easy solution problem or should take approach?

edit

here full stack trace iex:

%plug.conn{} |> phoenix.controller.redirect(to: "/404.html")  ** (undefinedfunctionerror) function plug.conn.send_resp/4 undefined or private. did mean 1 of:    * send_resp/1   * send_resp/3  (plug) plug.conn.send_resp(nil, 302, [{"content-type", "text/html; charset=utf-8"}, {"cache-control", "max-age=0, private, must-revalidate"}, {"location", "/404.html"}], "<html><body>you being <a href=\"/404.html\">redirected</a>.</body></html>") (plug) lib/plug/conn.ex:393: plug.conn.send_resp/1 

the redirect function's implementation can found here: https://github.com/phoenixframework/phoenix/blob/v1.2.3/lib/phoenix/controller.ex#l297

the send_resp function expect hit can found here: https://github.com/phoenixframework/phoenix/blob/v1.2.3/lib/phoenix/controller.ex#l748


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -