scala - Unit testing controllers with ScalaTest in Play! framework -


i'm working play 2.2 , scalatest. it's first time i'm trying test controller in play application. way:

class testartistcontroller extends playspec oneapppersuite {    "artistcontroller" must {      "returns artists" in new withapplication {       val eventuallyresult = controllers.artistcontroller.findnearcity("lyon")(fakerequest())       whenready(eventuallyresult, timeout(span(2, seconds))) { result =>         println(result.body) //it enumerator[array[byte]]         result.header.status mustbe 200       }     }   } } 

it allows me correctly test return result don't know how test body of result. result.body returns enumerator[array[bytes]] , totally don't know how transform retrieve json i'm sending.

what way this?

import play.api.test.helpers._ , use helper functions such contentasjson(res) or status(res), res being result of action (you may need use res.run in cases async actions).


Comments