Multiple groups in my department have started using Spray to develop REST based web services and are all running into a similar problem and there really haven't been great solutions to come out of it so far.
Suppose you had the following:
FooService extends Actor { ??? }
and then elsewhere:
path("SomePath") {
id =>
get {
requestContext =>
// I apologize for the janky Props usage here, just an example
val fooService = actorRefFactory.actorOf(Props(new FooService(requestContext)))
queryService ! SomeMessage(id)
}
}
In other words, every end point has a corresponding actor, and inside of a route an actor of that type will be spun up w/ the request context, a message will be passed to it and that actor will handle the HttpResponse & stop.
I've always had simple enough route trees that I've unit tested just the Actors themselves and let the route testing be handled by integration tests, but I've been overruled here. So the problem is that for unit tests people want to be able to replace FooService with a MockFooService
Is there a standard way of handling this situation?