I have a service:
trait MyService extends HttpService {
def getDao(implicit dao: SomeDAO) = dao
def someRoute = path("foo") {
get {
complete(getDao getSomething)
}
}
}
Then, I have an actor:
class MyActor extends MyService with Actor {
override def receive: Receive = runRoute(someRoute)
def actorRefFactory: ActorRefFactory = context
}
My test class looks like this:
class MyServiceTest extends FlatSpec with ScalatestRouteTest with MyService with Matchers with MockFactory {
override implicit def actorRefFactory: ActorSystem = system
implicit val _dao: SomeDAO = mock[SomeDAO]
"My service" should "return something" in {
Get("/foo") ~> someRoute ~> check {
status should be(OK)
}
}
}
But when I run the test, the compiler complains that the implicit value for SomeDAO
cannot be found. How do I manage to get the SomeDAO
into my service? What am I missing / what am I doing wrong?