スプレー ルートでは、アクターに委任してリクエストを処理します。はRequestContextメッセージでそのアクターに送信されます。
path("mypath") {
parameters("thing".as[String]) { thing => ctx =>
myActor ! ProcessThingAndResondToContext(thing, ctx)
}
}
私のテストではTestProbe、アクターの処理はコストがかかるため、アクターを a に置き換えました。
class MySpec extends Specification with Specs2RouteTest with ScalaCheck with MyService {
val testProbe = TestProbe()
override val myActor = testProbe.ref
def is = s2"""
it should $doTheRightThing
"""
def doTheRightThing = {
Get(s"/mypath?thing=fruit") ~> route ~> check {
testProbe.expectMsgClass(classOf[ProcessThingAndResondToContext])
status mustEqual StatusCodes.Success
}
}
がないため、この仕様は失敗しますstatus。TestProbe は何もしないため、ctxは応答されませんでした。
Request was neither completed nor rejected within 1 second
この行status mustEqual StatusCodes.Successは私のテストにとって重要ではありませんが、仕様がコンパイルされないため、削除できません。メソッドはMatchResult.
アクターに委任されたルートをテストするにはどうすればよいですか?