These are chat archives for etorreborre/specs2

Oct 2017
Raphael Mäder
Oct 25 2017 21:48

Hi there. I have a problem creating a mock:

val pm = mock[PageService[IO]].smart
pm.findVisible returns IO { List(idPage) }

fails (no exception, test just hangs veeery long, possibly indefinetly), but

val a = mock[PageRepository[IO]].smart
a.findVisible returns IO { List(idPage) }
val pm = new PageService[IO](a, null)

works. IO is from cats.effect. PageService is defined as class PageService[M[_] : Monad](pageRepository: PageRepository[M], contentRepository: ContentRepository[M]). Does someone know this problem and how to solve it? Am I making some kind of mistake? I thought I'd ask here before posting a question on StackOverflow or creating an issue on GitHub... If you want to take a closer look, code is here:
Thanks :)

(services findVisible just calls repositorys findVisible at this point)
Eric Torreborre
Oct 25 2017 22:47
My usual advice is to try to further reduce the problem by desugaring the specs2 syntax on top of Mockito, then get rid of .smart to see if that affects the outcome, then try to pass implicits manually because that could also be a problem.
My other advice is to stay away from Mockito for code which is too far from Java (implicits, lazy values)