All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kirill5k.common.test.cats.IOWordSpec.scala Maven / Gradle / Ivy

There is a newer version: 0.1.9
Show newest version
package kirill5k.common.test.cats

import cats.effect.IO
import cats.effect.unsafe.IORuntime
import kirill5k.common.test.MockitoMatchers
import org.scalatest.{Assertion, EitherValues}
import org.scalatest.matchers.must.Matchers
import org.scalatest.wordspec.AsyncWordSpec

import scala.concurrent.Future

trait IOWordSpec extends AsyncWordSpec with Matchers with MockitoMatchers with EitherValues {

  extension [A](io: IO[A])
    def assertVoid: Future[Assertion] = asserting(_ mustBe ())
    def assertThrows(error: Throwable): Future[Assertion] =
      io.attempt.asserting(_ mustBe Left(error))
    def asserting(f: A => Assertion): Future[Assertion] =
      io.map(f).unsafeToFuture()(IORuntime.global)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy