Can I modify subcut modules in spray route test?

125 views Asked by At

I have a Specs2RouteTest

"test a route with some modified dependencies" in {
  bindingModule.modifyBindings { implicit module =>
    module.bind[AuthorizationService].toModuleSingle { createMockAuthService("1") }
    val req = createMockRequest("1")
    val testApi = module.inject [ApiEndpoints](None)
    Post(s"/api/v1/service", JsonEntity(req.toJson)) ~> testApi.routes ~> check {
      ....
    }
  }
}

I confirm that the modified binding is set within the test. But once it gets into the route I am back to seeing the bindings as set up in the test module. Generally this modifyBindings{} technique seems to work to keep tests isolated and when I'm doing unit testing I can swap out dependencies no problem... but on these integration tests I can't seem to make the route under test pick up any binding modifications. Am I doing something obviously wrong?

0

There are 0 answers