| Stability | provisional |
|---|---|
| Safe Haskell | None |
| Language | Haskell2010 |
Test.Hspec.Core.Hooks
Description
Synopsis
- type Spec = SpecWith ()
- type SpecWith a = SpecM a ()
- type ActionWith a = a -> IO ()
- before :: IO a -> SpecWith a -> Spec
- before_ :: IO () -> SpecWith a -> SpecWith a
- beforeWith :: (b -> IO a) -> SpecWith a -> SpecWith b
- beforeAll :: HasCallStack => IO a -> SpecWith a -> Spec
- beforeAll_ :: HasCallStack => IO () -> SpecWith a -> SpecWith a
- beforeAllWith :: HasCallStack => (b -> IO a) -> SpecWith a -> SpecWith b
- after :: ActionWith a -> SpecWith a -> SpecWith a
- after_ :: IO () -> SpecWith a -> SpecWith a
- afterAll :: HasCallStack => ActionWith a -> SpecWith a -> SpecWith a
- afterAll_ :: HasCallStack => IO () -> SpecWith a -> SpecWith a
- around :: (ActionWith a -> IO ()) -> SpecWith a -> Spec
- around_ :: (IO () -> IO ()) -> SpecWith a -> SpecWith a
- aroundWith :: (ActionWith a -> ActionWith b) -> SpecWith a -> SpecWith b
- aroundAll :: HasCallStack => (ActionWith a -> IO ()) -> SpecWith a -> Spec
- aroundAll_ :: HasCallStack => (IO () -> IO ()) -> SpecWith a -> SpecWith a
- aroundAllWith :: HasCallStack => (ActionWith a -> ActionWith b) -> SpecWith a -> SpecWith b
- mapSubject :: (b -> a) -> SpecWith a -> SpecWith b
- ignoreSubject :: SpecWith () -> SpecWith a
Types
type SpecWith a = SpecM a () Source #
A represents a test or group of tests that require an SpecWith aa
value to run.
In the common case, a Spec is a which requires SpecWith ()() and
can thus be executed with hspec.
To supply an argument to SpecWith tests to turn them into Spec, use
functions from Test.Hspec.Core.Hooks such as
around, before,
mapSubject and similar.
Values of this type are created by it,
describe and similar.
type ActionWith a = a -> IO () Source #
Hooks
beforeWith :: (b -> IO a) -> SpecWith a -> SpecWith b Source #
Run a custom action before every spec item.
beforeAll :: HasCallStack => IO a -> SpecWith a -> Spec Source #
Run a custom action before the first spec item.
beforeAll_ :: HasCallStack => IO () -> SpecWith a -> SpecWith a Source #
Run a custom action before the first spec item.
beforeAllWith :: HasCallStack => (b -> IO a) -> SpecWith a -> SpecWith b Source #
Run a custom action with an argument before the first spec item.
after :: ActionWith a -> SpecWith a -> SpecWith a Source #
Run a custom action after every spec item.
afterAll :: HasCallStack => ActionWith a -> SpecWith a -> SpecWith a Source #
Run a custom action after the last spec item.
afterAll_ :: HasCallStack => IO () -> SpecWith a -> SpecWith a Source #
Run a custom action after the last spec item.
Arguments
| :: (ActionWith a -> IO ()) | Function provided with an action to run the spec item as argument. It should return the action to actually execute the item. |
| -> SpecWith a | Spec to modify |
| -> Spec |
Run a custom action before and/or after every spec item, supplying it with an argument obtained via IO.
This is useful for tasks like creating a file handle or similar resource before a test and destroying it after the test.
around_ :: (IO () -> IO ()) -> SpecWith a -> SpecWith a Source #
Run a custom action before and/or after every spec item.
aroundWith :: (ActionWith a -> ActionWith b) -> SpecWith a -> SpecWith b Source #
Run a custom action before and/or after every spec item.
aroundAll :: HasCallStack => (ActionWith a -> IO ()) -> SpecWith a -> Spec Source #
Wrap an action around the given spec.
aroundAll_ :: HasCallStack => (IO () -> IO ()) -> SpecWith a -> SpecWith a Source #
Wrap an action around the given spec.
aroundAllWith :: HasCallStack => (ActionWith a -> ActionWith b) -> SpecWith a -> SpecWith b Source #
Wrap an action around the given spec. Changes the arg type inside.
mapSubject :: (b -> a) -> SpecWith a -> SpecWith b Source #
Modify the subject under test.
Note that this resembles a contravariant functor on the first type parameter
of SpecM. This is because the subject is passed inwards, as an argument
to the spec item.
ignoreSubject :: SpecWith () -> SpecWith a Source #
Ignore the subject under test for a given spec.