While writing tests I'm confronted with the following exception:
java.lang.ClassCastException: codegen.java.lang.Object$MockitoMock$641592186 cannot be cast to cats.effect.IO (MyRepositorySpec.scala:19)
Which occurs when running this test code with specs2:
class MyRepositorySpec extends Specification with Mockito with TestData {
...
val m = mock[MyDAO[IO]].smart
m.createTable returns IO { Right[Throwable, Int](1) } // <- this is line 19
val r = new MyRepository[IO](m)
r.setup.unsafeRunSync() must beNone
...
}
MyDAO looks like this:
class MyDAO[M[_] : Monad](val transactor: Transactor[M])(implicit val AE: ApplicativeError[M, Throwable]) extends DataAccessObject[M, MyObject]
and the DataAccessObject like this:
trait DataAccessObject[M[_], T <: Entity]
I'm at a loss how to fix/correctly implement this. Any help would be appreciated. Thank you!