First of all, thanks for the great framework, I'm having a blast learning Elixir with it! I've bumped into a limitation I think: I want to test that a nested router is correctly getting its params from the parent's route_params. An example:
defmodule Users do
use Maru.Router
namespace :users do
route_param :id do
params do
require :id, type: Integer
end
namespace :posts, do: mount Posts
end
end
end
defmodule Posts do
use Maru.Router
params do
# should be coming from the route_param
require :id, type: Integer
end
get do
# render user's posts
end
end
In this case I'd get the path /users/:id/posts where the nested router grabs the :id param from the route. However, during unit tests of the Posts route, I've no way (afaik) of testing that it's grabbing the id from the route correctly, since all paths are relative to that router (i.e.: /).
I guess I could test this from the Users router, but that doesn't make a lot of sense since the functionality doesn't really belong to it.
I think we should be able to test this, perhaps with Routing unit tests?
First of all, thanks for the great framework, I'm having a blast learning Elixir with it! I've bumped into a limitation I think: I want to test that a nested router is correctly getting its
params
from the parent'sroute_params
. An example:In this case I'd get the path
/users/:id/posts
where the nested router grabs the:id
param from the route. However, during unit tests of thePosts
route, I've no way (afaik) of testing that it's grabbing theid
from the route correctly, since all paths are relative to that router (i.e.:/
).I guess I could test this from the
Users
router, but that doesn't make a lot of sense since the functionality doesn't really belong to it.I think we should be able to test this, perhaps with Routing unit tests?