I am using Play! and trying to work with JSON response messages in Specs2 tests without success.
What I'm trying to do is validate the key-> value pairs in JsValue, as in the example below ... but I can't get the correct transfers.
import org.specs2.mutable._ import play.api.libs.json.{Json, JsValue} class JsonSpec extends Specification { "Json Matcher" should { "Correctly match Name->Value pairs" in { val resultJson:JsValue = Json.parse("""{"name":"Yardies"}""") resultJson must /("name" -> "Yardies") } "Correctly match Name->Value pairs with numbers as doubles" in { val resultJson:JsValue = Json.parse("""{"id":1}""") resultJson must /("id" -> 1.0) } } }
The errors I get
{name : Yardies} doesn't contain '(name,Yardies)'
and
{id : 1.0} doesn't contain '(id,1.0)'
Not very useful, I think this is something simple that I am missing (new to both Scala and Play)
Steve
source share