packages feed

hspec-core 2.1.6 → 2.1.7

raw patch · 3 files changed

+24/−1 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Test.Hspec.Core.Hooks: beforeAll_ :: IO () -> SpecWith a -> SpecWith a

Files

hspec-core.cabal view
@@ -1,5 +1,5 @@ name:             hspec-core-version:          2.1.6+version:          2.1.7 license:          MIT license-file:     LICENSE copyright:        (c) 2011-2015 Simon Hengel,
src/Test/Hspec/Core/Hooks.hs view
@@ -4,6 +4,7 @@ , before_ , beforeWith , beforeAll+, beforeAll_ , after , after_ , afterAll@@ -36,6 +37,13 @@   mvar <- runIO (newMVar Nothing)   let action_ = memoize mvar action   before action_ spec++-- | Run a custom action before the first spec item.+beforeAll_ :: IO () -> SpecWith a -> SpecWith a+beforeAll_ action spec = do+  mvar <- runIO (newMVar Nothing)+  let action_ = memoize mvar action+  before_ action_ spec  memoize :: MVar (Maybe a) -> IO a -> IO a memoize mvar action = modifyMVar mvar $ \ma -> case ma of
test/Test/Hspec/Core/HooksSpec.hs view
@@ -80,6 +80,21 @@         , "bar"         ] +  describe "beforeAll_" $ do+    it "runs an action before the first spec item" $ do+      ref <- newIORef []+      let append n = modifyIORef ref (++ return n)+      silence $ H.hspec $ H.beforeAll (append "beforeAll_") $ do+        H.it "foo" $ do+          append "foo"+        H.it "bar" $ do+          append "bar"+      readIORef ref `shouldReturn` [+          "beforeAll_"+        , "foo"+        , "bar"+        ]+     context "when used with an empty list of examples" $ do       it "does not run specified action" $ do         ref <- newIORef []