第一次喷用户接近扯掉头发。
trait SampleService extends SimpleRoutingApp with JsonProtocol with SprayJsonSupport {
implicit val system: ActorSystem = ActorSystem("test")
implicit def context: ExecutionContext = system.dispatcher
startServer(interface = "localhost", port = 8888) {
path("test") { _ =>
get {
complete {
"test"
}
}
}
}
}
导入 org.scalatest.FlatSpec 导入 spray.testkit.ScalatestRouteTest
class ApiSpec extends FlatSpec with ScalatestRouteTest with SampleService {
"The api service" should "return test" in {
Get("/test/") ~> check {
responseAs[String] === "test"
}
}
}
以及精彩的编译错误信息:
could not find implicit value for parameter ta: ApiSpec.this.TildeArrow[ApiSpec.this.RouteResult,Boolean]
[error] Get("/test/") ~> check {}
谁能指出我正确的方向?从示例中复制粘贴spray-testkit
似乎失败了。