Testing plug routes

Hello everyone!

I’m trying to test a route using Plug, but it’s given this error on console:

  1. test returns hello text (LearningElixir.Router)
    test/learningelixir/router_test.exs:9
    ** (UndefinedFunctionError) undefined function LearningElixir.Router.call/2

Thanks !!

The name of your module is the same of your test module and that’s generating a conflict. You should see a warning in your terminal about that. Listen to the warnings, it is worth it. :slight_smile: Change the test module name and you should be good to go.

2 Likes

I haven’t notice that hahaha.

Now I see the warning:
test/learningelixir/router_test.exs:1: warning: redefining module LearningElixir.Router

Thanks Valim!