hspec-expectations-lens-0.2.0.0: Hspec expectations for the lens stuff

Safe HaskellNone

Test.Hspec.Lens

Contents

Description

Module is designed to be conveniently imported instead of Test.Hspec

It reexports Test.Hspec without expectations (except for shouldBe) and Test.Hspec.Expectations.Lens expectations

Synopsis

Types

type Spec = SpecM ()

class Example a

A type class for examples.

Instances

Example Bool 
Example Test

This instance is deprecated, use fromHUnitTest instead!

Example Property 
Example Expectation 
Example Result 

Setting expectations

shouldBe :: (Show a, Eq a) => a -> a -> Expectation

actual `shouldBe` expected sets the expectation that actual is equal to expected (this is just an alias for @?=).

Defining a spec

describe :: String -> Spec -> Spec

Combine a list of specs into a larger spec.

context :: String -> Spec -> Spec

An alias for describe.

it :: Example a => String -> a -> Spec

Create a spec item.

A spec item consists of:

  • a textual description of a desired behavior
  • an example for that behavior
 describe "absolute" $ do
   it "returns a positive number when given a negative number" $
     absolute (-1) == 1

example :: Expectation -> Expectation

This is a type restricted version of id. It can be used to get better error messages on type mismatches.

Compare e.g.

 it "exposes some behavior" $ example $ do
   putStrLn

with

 it "exposes some behavior" $ do
   putStrLn

pending :: Expectation

Specifies a pending example.

If you want to textually specify a behavior but do not have an example yet, use this:

 describe "fancyFormatter" $ do
   it "can format text in a way that everyone likes" $
     pending

pendingWith :: String -> Expectation

Specifies a pending example with a reason for why it's pending.

 describe "fancyFormatter" $ do
   it "can format text in a way that everyone likes" $
     pendingWith "waiting for clarification from the designers"

before :: IO () -> Spec -> Spec

Run a custom action before every spec item.

after :: IO () -> Spec -> Spec

Run a custom action after every spec item.

around :: (IO () -> IO ()) -> Spec -> Spec

Run a custom action before and/or after every spec item.

parallel :: Spec -> Spec

Run examples of given spec in parallel.

Running a spec

hspec :: Spec -> IO ()

Run given spec and write a report to stdout. Exit with exitFailure if at least one spec item fails.