kirill5k.common.test.cats.IOWordSpec.scala Maven / Gradle / Ivy
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