hspec-meta 1.7.1 → 1.7.2
raw patch · 2 files changed
+20/−2 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Test.Hspec.Meta: after :: IO () -> Spec -> Spec
+ Test.Hspec.Meta: around :: (IO () -> IO ()) -> Spec -> Spec
Files
- hspec-meta.cabal +1/−1
- src/Test/Hspec.hs +19/−1
hspec-meta.cabal view
@@ -1,5 +1,5 @@ name: hspec-meta-version: 1.7.1+version: 1.7.2 license: MIT license-file: LICENSE copyright: (c) 2011-2013 Simon Hengel,
src/Test/Hspec.hs view
@@ -33,6 +33,8 @@ , pending , pendingWith , before+, after+, around , parallel -- * Running a spec@@ -45,6 +47,9 @@ import Test.Hspec.Expectations import qualified Test.Hspec.Core as Core +import Data.IORef+import Control.Applicative+ -- $intro -- -- The three functions you'll use the most are 'hspec', 'describe', and 'it'.@@ -150,7 +155,20 @@ -- | Run a custom action before every spec item. before :: IO () -> Spec -> Spec-before action = mapSpecItem $ \b r e -> SpecItem b r (\params -> (action >> (e params)))+before action = mapSpecItem $ \b r e -> SpecItem b r (\params -> action *> e params)++-- | Run a custom action after every spec item.+after :: IO () -> Spec -> Spec+after action = mapSpecItem $ \b r e -> SpecItem b r (\params -> e params <* action)++-- | Run a custom action before and/or after every spec item.+around :: (IO () -> IO ()) -> Spec -> Spec+around action = mapSpecItem $ \b r e -> SpecItem b r (\params -> wrap (e params))+ where+ wrap e = do+ ref <- newIORef (Fail "")+ action (e >>= writeIORef ref)+ readIORef ref mapSpecItem :: (Bool -> String -> (Params -> IO Result) -> SpecTree) -> Spec -> Spec mapSpecItem f = fromSpecList . map go . runSpecM