I am trying to test an action on a controller.
It’s a rather simple action, it takes JSON and returns JSON:
def createGroup = Action(parse.json) { request =>
val name = (request.body \ "name").as[String]
val collabs = (request.body \ "collabs").as[List[String]]
Ok(Json.toJson(
Map("status" -> "OK",
"message" -> "%s created".format(name))
))
}
I want to verify that the JSON returned is indeed correct.
How would I use FakeRequest to do this?
Maybe something like:
Note: The
val resultline might now be correct since I took it from a test that uses an Async controller.