nanospec-0.2.1: A lightweight implementation of a subset of Hspec's API

Safe Haskell | Safe
Language | Haskell98

Test.Hspec

Contents

- Types
- Defining a spec
  - Setting expectations
- Running a spec

Description

A lightweight implementation of a subset of Hspec's API.

Synopsis

- data SpecM a
- type Spec = SpecM ()
- describe :: String -> Spec -> Spec
- context :: String -> Spec -> Spec
- it :: String -> Expectation -> Spec
- type Expectation = IO ()
- expect :: String -> Bool -> Expectation
- shouldBe :: (Show a, Eq a) => a -> a -> Expectation
- shouldReturn :: (Show a, Eq a) => IO a -> a -> Expectation
- hspec :: Spec -> IO ()

# Types

data SpecM a Source #

Instances

Monad SpecM Source # |
Methods (>>=) :: SpecM a -> (a -> SpecM b) -> SpecM b # (>>) :: SpecM a -> SpecM b -> SpecM b # return :: a -> SpecM a # fail :: String -> SpecM a #
Functor SpecM Source # |
Methods fmap :: (a -> b) -> SpecM a -> SpecM b # (<$) :: a -> SpecM b -> SpecM a #
Applicative SpecM Source # |
Methods pure :: a -> SpecM a # (<*>) :: SpecM (a -> b) -> SpecM a -> SpecM b # (*>) :: SpecM a -> SpecM b -> SpecM b # (<*) :: SpecM a -> SpecM b -> SpecM a #

type Spec = SpecM () Source #

# Defining a spec

describe :: String -> Spec -> Spec Source #

context :: String -> Spec -> Spec Source #

it :: String -> Expectation -> Spec Source #

## Setting expectations

type Expectation = IO () Source #

expect :: String -> Bool -> Expectation Source #

shouldBe :: (Show a, Eq a) => a -> a -> Expectation infix 1 Source #

shouldReturn :: (Show a, Eq a) => IO a -> a -> Expectation infix 1 Source #

# Running a spec

hspec :: Spec -> IO () Source #