I would like to write a simple test for a controller, which accepts a json body. But as soon I add the parse.json
BodyParser to the Action my Tests cannot be compiled anymore.
The Setup is basically the plain play-scala-seed project.
Error:
[error] ... could not find implicit value for parameter mat: akka.stream.Materializer
[error] status(home) mustBe OK
[error] ^
HomeController
:
def index() = Action { implicit request =>
Ok
}
def json() = Action(parse.json) { implicit request =>
Ok
}
HomeControllerSpec
:
class HomeControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting {
"HomeController POST" should {
"answer Ok" in {
val controller = new HomeController(stubControllerComponents())
val home = controller.json().apply(FakeRequest(POST, "/"))
status(home) mustBe OK
}
}