module Test.Hspec (
Spec
, Example
, module Test.Hspec.Expectations
, describe
, context
, it
, example
, pending
, pendingWith
, before
, after
, around
, parallel
, hspec
) where
import Control.Exception (finally)
import Test.Hspec.Core.Type hiding (describe, it)
import Test.Hspec.Runner
import Test.Hspec.HUnit ()
import Test.Hspec.Expectations
import Test.Hspec.Core (mapSpecItem)
import qualified Test.Hspec.Core as Core
describe :: String -> Spec -> Spec
describe label action = fromSpecList [Core.describe label (runSpecM action)]
context :: String -> Spec -> Spec
context = describe
it :: Example a => String -> a -> Spec
it label action = fromSpecList [Core.it label action]
example :: Expectation -> Expectation
example = id
parallel :: Spec -> Spec
parallel = mapSpecItem $ \item -> item {itemIsParallelizable = True}
before :: IO () -> Spec -> Spec
before action = around (action >>)
after :: IO () -> Spec -> Spec
after action = around (`finally` action)
around :: (IO () -> IO ()) -> Spec -> Spec
around a2 = mapSpecItem $ \item -> item {itemExample = \params a1 -> itemExample item params (a1 . a2)}