This module contains the core types, constructors, classes, instances, and utility functions common to hspec.
- data Spec
- type Specs = [Spec]
- class Example a where
- data Pending
- describe :: String -> [Spec] -> Spec
- it :: Example a => String -> a -> Spec
- pending :: String -> Pending
- hspec :: Specs -> IO [EvaluatedSpec]
- hspecB :: Specs -> IO Bool
- hspecX :: Specs -> IO a
- hHspec :: Handle -> Specs -> IO [EvaluatedSpec]
- data SpecTree a
- type EvaluatedSpec = SpecTree Result
- data Result
- quantify :: (Show a, Num a, Eq a) => a -> String -> String
- descriptions :: Specs -> Specs
- type AnyExample = IO Result
- safeEvaluateExample :: AnyExample -> IO Result
- type UnevaluatedSpec = Spec
- success :: [EvaluatedSpec] -> Bool
- failure :: [EvaluatedSpec] -> Bool
- isFailure :: Result -> Bool
- failedCount :: [EvaluatedSpec] -> Int
A type class for examples.
Defining a spec
Create a set of specifications for a specific type being described. Once you know what you want specs for, use this.
describe "abs" [ it "returns a positive number given a negative number" (abs (-1) == 1) ]
A pending example.
If you want to report on a behavior but don't have an example yet, use this.
describe "fancyFormatter" [ it "can format text in a way that everyone likes" $ pending ]
You can give an optional reason for why it's pending.
describe "fancyFormatter" [ it "can format text in a way that everyone likes" $ pending "waiting for clarification from the designers" ]
Running a spec
Create a document of the given specs and write it to stdout.
Create a document of the given specs and write it to the given handle.
writeReport filename specs = withFile filename WriteMode (\h -> hHspec h specs)
Internal representation of a spec.
This will be made abstract with the next release. If you still need access to any constructors, open an issue and describe your use case: https://github.com/hspec/hspec/issues
The result of running an example.
Create a more readable display of a quantity of something.
Deprecated types and functions
The following types and functions are deprecated and will be removed with the next release.
If you still need any of those, please open an issue and describe your use case: https://github.com/hspec/hspec/issues
DEPRECATED: This is no longer needed (it's just an alias for