module Test.Hspec.Bracket (
bracketSpecWith_,
bracketSpecWith,
) where
import Control.Exception (bracket_, bracket)
import Test.Hspec (Spec, SpecWith, runIO, hspec, before)
bracketSpecWith_ :: (Spec -> Spec)
-> IO a
-> IO b
-> c
-> SpecWith c
-> SpecWith c
bracketSpecWith_ strategy begin end item spec =
runIO $ bracket_ begin end $
hspec $ strategy $ before (return item) spec
bracketSpecWith :: (Spec -> Spec)
-> IO a
-> (a -> IO b)
-> c
-> (a -> SpecWith c)
-> SpecWith c
bracketSpecWith strategy open close item spec =
runIO $ bracket open close $
\r -> hspec $ strategy $ before (return item) $ spec r