packages feed

hspec-meta 1.11.1 → 1.11.2

raw patch · 2 files changed

+19/−1 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Test.Hspec.Meta: beforeAll :: IO () -> Spec -> Spec

Files

hspec-meta.cabal view
@@ -1,5 +1,5 @@ name:             hspec-meta-version:          1.11.1+version:          1.11.2 license:          MIT license-file:     LICENSE copyright:        (c) 2011-2014 Simon Hengel,
src/Test/Hspec.hs view
@@ -23,6 +23,7 @@ , pending , pendingWith , before+, beforeAll , after , around , parallel@@ -33,6 +34,7 @@ ) where  import           Control.Exception (finally)+import           Control.Concurrent.MVar  import           Test.Hspec.Core.Type hiding (describe, it) import           Test.Hspec.Runner@@ -88,6 +90,22 @@ -- | Run a custom action before every spec item. before :: IO () -> Spec -> Spec before action = around (action >>)++-- | Run a custom action before all spec items.+beforeAll :: IO () -> Spec -> Spec+beforeAll action = fromSpecList . return . BuildSpecs . go+  where+    go spec = do+      mvar <- newMVar Nothing+      let action_ = memoize mvar action+      runSpecM $ before action_ spec++memoize :: MVar (Maybe a) -> IO a -> IO a+memoize mvar action = modifyMVar mvar $ \ma -> case ma of+  Just a -> return (ma, a)+  Nothing -> do+    a <- action+    return (Just a, a)  -- | Run a custom action after every spec item. after :: IO () -> Spec -> Spec