homepage: https://github.com/akshaymankar/polysemy-mocks#readme
changelog-type: markdown
hash: f2d7068e5cd74cfd1e34f23d15c2610f0a1608e0f0a02539f8d432a9971ad094
test-bench-deps:
  base: '>=4.7 && <5'
  hspec: -any
  polysemy-mocks: -any
  polysemy: -any
maintainer: itsakshaymankar@gmail.com
synopsis: Mocking framework for polysemy effects
changelog: |
  # Changelog for polysemy-mocks

  ## 0.1.0.0

  * First release. Can mock effects.
basic-deps:
  base: '>=4.7 && <5'
  polysemy: -any
  template-haskell: -any
all-versions:
- 0.1.0.0
author: Akshay Mankar
latest: 0.1.0.0
description-type: markdown
description: |
  # Polysemy Mocks

  ## Overview

  `polysemy-mocks` aims to provide a structure to write all mocks for polysemy and to generate those.

  ## Example

  ```haskell
  {-# LANGUAGE DataKinds #-}
  {-# LANGUAGE FlexibleContexts #-}
  {-# LANGUAGE FlexibleInstances #-}
  {-# LANGUAGE GADTs #-}
  {-# LANGUAGE LambdaCase #-}
  {-# LANGUAGE MultiParamTypeClasses #-}
  {-# LANGUAGE ScopedTypeVariables #-}
  {-# LANGUAGE TemplateHaskell #-}
  {-# LANGUAGE TypeApplications #-}
  {-# LANGUAGE TypeFamilies #-}
  {-# LANGUAGE TypeOperators #-}

  module TeletypeSpec where

  import Data.Kind
  import Polysemy
  import Polysemy.Internal (send)
  import Test.Hspec
  import Test.Polysemy.Mock
  import Test.Polysemy.Mock.TH (genMock)
  import Prelude hiding (read)

  data Teletype (m :: Type -> Type) a where
    Read :: Teletype m String
    Write :: String -> Teletype m ()

  makeSem ''Teletype

  genMock ''Teletype

  program :: Member Teletype r => Sem r ()
  program = do
    write "Name: "
    name <- read
    write $ "Hello " <> name

  spec :: Spec
  spec =
    describe "program" $ do
      it "greets" $ runM @IO . evalMock $ do
        mockReadReturns (pure "Akshay")
        mock @Teletype @IO program
        writes <- mockWriteCalls
        embed $ writes `shouldBe` ["Name: ", "Hello Akshay"]
  ```
license-name: BSD-3-Clause

Update from Hackage at 2021-02-10T15:07:06Z
Update from Hackage at 2021-02-10T15:07:06Z
