4
스프레이는 Seq
을 포함한 모든 일반 데이터 유형이 자동으로 JSON과 JSON간에주고받을 것이라고 말합니다. 웬일인지, 나는 이것을 경험하지 않는다.스프레이 GET 응답에서 JSON 배열을 테스트하는 방법은 무엇입니까?
import spray.json._
import DefaultJsonProtocol._
...
class RestAPITest
extends FlatSpec
with Matchers
with ScalatestRouteTest
with MyRoute
{
...
behavior of "MyRoute"
it should "return a list as JSON" in {
Get("/computers") ~> myRoute ~> check {
status should equal(OK)
// 'sbt test' gives:
// "could not find implicit value for evidence parameter of type spray.httpx.unmarshalling.FromResponseUnmarshaller[Seq[String]]"
//
responseAs[Seq[String]] should contain theSameElementsAs(List("A01", "A02", "A03", "E01", "G04"))
}
}
내가 뭘 잘못하고 있니?
봅니다'수입 spray.httpx.SprayJsonSupport._'를 추가. – jrudolph
감사합니다! (좀 더 자세한 문제는 내일 자세히 보게 될 것입니다.) – akauppi
이것은 스프레이 1.3.0으로 업그레이드하는 데 도움이되었습니다. 그것의 간명에서 경이롭게에서 'respondAs'선! Go spray-json and scala! :) 당신이 대답을 해 주면 기꺼이 그것을 찬성하겠습니다. – akauppi