我对 Scala/Play 2.0 和 Specs 有一个简单的问题。
这是我的测试
"Server" should {
"return a valid item with appropriate content type or a 404" in {
val Some(result) = routeAndCall(FakeRequest(GET, "/item/1"))
status(result) match {
case 200 => contentType(result) must beSome("application/json")
case 404 => true
case _ => throw new Exception("The Item server did not return either a 200 application/json or a 404")
}
//false --> It only compiles if I add this line!
}
}
}
由于以下原因,这不会编译:
No implicit view available from Any => org.specs2.execute.Result.
[error] "return a valid item with appropriate content type or a 404" in {
[error] ^
[error] one error found
所以我认为状态(结果)匹配正在评估任何因此错误。鉴于我的默认情况具有错误的返回值,我应该如何指定其结果类型为 Result?