I have a Play 2.3 project with a sub-project inside. Following this tutorial, I am writing a test for sub-project's controller with route
method:
"Get Action" in new WithApplication {
val Some(result) = route(FakeRequest(GET, "/sub/bob/11"))
status(result) mustEqual OK
}
Assumed in routes.conf, the sub-project routes is configured like this:
-> /sub sub.Routes
And in sub.Routes, it contains:
GET /bob/:id controllers.sub.BobController.get(id: Int)
However the route()
method always returns None
. Using route(FakeRequest(GET, "/bob/11"))
doesn't work too.
Currently I can only solve the problem by direct call to the Controller's method:
val result = BobController.get(11)(FakeRequest(GET, "/bob/11"))
In this case, the "11" parameter in the "/bob/11" become useless as it's unused.
So anyone know how to make the route() works for sub-project?
Aucun commentaire:
Enregistrer un commentaire