A
Play 2.4 アプリケーション内で Scaldi を使用してアクターをテストしようとしています。このアクターはinjectActorRef[B]
、私がTestKit.TestProbe
.
B
私のspecs2内では、対応するTestKit.TestProbe.refをactorに提供しながら、mockedのプローブを取得できるようにしたいと考えていますA
。
私はこのようなことをしたいと思います:
implicit val inj = (new TestModule(){
bind[TestProbe] identifiedBy 'probeForB to TestProbe()
bind[B] to inject[TestProbe]('probeForB).ref
}).injector
inject[TestProbe]('probeForB).expectMsgType[] must ...
問題は、ref が であるため、予期されるタイプActorRef
と一致しないことです。B
それを行うためのきれいな方法はありますか?によって返される ActorRef を指定できますinjectActorRef[B]
か?
Actor のバインドをオーバーライドすることになりましたA
。
val probeForB = TestProbe()
implicit val inj = (new Module() {
bind[A] to new A() {
override def injectB(): ActorRef = probeForB.ref
}
}).injector