Packages

package scalatest

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. Protected

Type Members

  1. trait AssertBIO extends AnyRef
  2. trait AssertCIO extends AnyRef
  3. trait AssertIO extends AnyRef
  4. abstract class DistageBIOEnvSpecScalatest[FR[-_, +_, +_]] extends DistageScalatestTestSuiteRunner[[γ$0$]FR[Any, Throwable, γ$0$]] with DistageAbstractScalatestSpec[[γ$1$]FR[Any, Throwable, γ$1$]]

    Allows summoning objects from DI in tests via ZIO environment intersection types

    Allows summoning objects from DI in tests via ZIO environment intersection types

    trait PetStore[F[_, _]] {
      def purchasePet(name: String, cost: Int): F[Throwable, Boolean]
    }
    
    trait Pets[F[_, _]]
      def myPets: F[Throwable, List[String]]
    }
    
    type PetStoreEnv = Has[PetStore[IO]]
    type PetsEnv = Has[Pets[IO]]
    
    val store = new PetStore[ZIO[PetStoreEnv, ?, ?]] {
      def purchasePet(name: String, cost: Int): RIO[PetStoreEnv, Boolean] = ZIO.accessM(_.get.purchasePet(name, cost))
    }
    val pets = new Pets[ZIO[PetsEnv, ?, ?]] {
      def myPets: RIO[PetsEnv, List[String]] = ZIO.accessM(_.get.myPets)
    }
    
    "test purchase pets" in {
      for {
        _    <- store.purchasePet("Zab", 213)
        pets <- pets.myPets
        _    <- assertIO(pets.contains("Zab"))
      } yield ()
      // : ZIO[PetStoreEnv with PetsEnv, Throwable, Unit]
    }

    Lambda parameters and environment may both be used at the same time to define dependencies:

    "test purchase pets" in {
      (store: PetStore[IO]) =>
      for {
        _    <- store.purchasePet("Zab", 213)
        pets <- pets.myPets
        _    <- assertIO(pets.contains("Zab"))
      } yield ()
      // : ZIO[PetsEnv, Throwable, Unit]
    }
  5. abstract class DistageBIOSpecScalatest[F[+_, +_]] extends DistageScalatestTestSuiteRunner[[β$0$]F[Throwable, β$0$]] with DistageAbstractScalatestSpec[[β$1$]F[Throwable, β$1$]]
  6. abstract class DistageSpecScalatest[F[_]] extends DistageScalatestTestSuiteRunner[F] with DistageAbstractScalatestSpec[F]

Value Members

  1. object AssertBIO extends AssertBIO
  2. object AssertCIO extends AssertCIO
  3. object AssertIO extends AssertIO

Ungrouped