packages feed

hspec-core 2.1.0 → 2.1.1

raw patch · 5 files changed

+30/−2 lines, 5 files

Files

hspec-core.cabal view
@@ -1,5 +1,5 @@ name:             hspec-core-version:          2.1.0+version:          2.1.1 license:          MIT license-file:     LICENSE copyright:        (c) 2011-2014 Simon Hengel,
src/Test/Hspec/Core/Hooks.hs view
@@ -1,6 +1,7 @@ -- | Stability: provisional module Test.Hspec.Core.Hooks (   before+, before_ , beforeWith , beforeAll , after@@ -20,6 +21,10 @@ -- | Run a custom action before every spec item. before :: IO a -> SpecWith a -> Spec before action = around (action >>=)++-- | Run a custom action before every spec item.+before_ :: IO () -> SpecWith a -> SpecWith a+before_ action = around_ (action >>)  -- | Run a custom action before every spec item. beforeWith :: (b -> IO a) -> SpecWith a -> SpecWith b
src/Test/Hspec/Core/Runner.hs view
@@ -47,7 +47,8 @@ filterSpecs c = go []   where     p :: Path -> Bool-    p = fromMaybe (const True) (configFilterPredicate c)+    p path = (fromMaybe (const True) (configFilterPredicate c) path) &&+               not (fromMaybe (const False) (configSkipPredicate c) path)      go :: [String] -> [SpecTree a] -> [SpecTree a]     go groups = mapMaybe (goSpec groups)
src/Test/Hspec/Options.hs view
@@ -27,6 +27,7 @@ -- that satisfy the predicate are run. , configRerun :: Bool , configFilterPredicate :: Maybe (Path -> Bool)+, configSkipPredicate :: Maybe (Path -> Bool) , configQuickCheckSeed :: Maybe Integer , configQuickCheckMaxSuccess :: Maybe Int , configQuickCheckMaxDiscardRatio :: Maybe Int@@ -45,6 +46,7 @@ , configFastFail = False , configRerun = False , configFilterPredicate = Nothing+, configSkipPredicate = Nothing , configQuickCheckSeed = Nothing , configQuickCheckMaxSuccess = Nothing , configQuickCheckMaxDiscardRatio = Nothing@@ -64,6 +66,9 @@ addMatch :: String -> Config -> Config addMatch s c = c {configFilterPredicate = Just (filterPredicate s) `filterOr` configFilterPredicate c} +addSkip :: String -> Config -> Config+addSkip s c = c {configSkipPredicate = Just (filterPredicate s) `filterOr` configSkipPredicate c}+ setDepth :: Int -> Config -> Config setDepth n c = c {configSmallCheckDepth = n} @@ -118,6 +123,7 @@ options = [     Option   []  ["help"]             (NoArg (const $ Left Help))         (h "display this help and exit")   , mkOption "m"  "match"             (Arg "PATTERN" return addMatch)     (h "only run examples that match given PATTERN")+  , mkOption []   "skip"              (Arg "PATTERN" return addSkip)      (h "skip examples that match given PATTERN")   , Option   []  ["color"]            (NoArg setColor)                    (h "colorize the output")   , Option   []  ["no-color"]         (NoArg setNoColor)                  (h "do not colorize the output")   , mkOption "f"  "format"            (Arg "FORMATTER" readFormatter setFormatter) formatHelp
test/Test/Hspec/Core/RunnerSpec.hs view
@@ -268,6 +268,22 @@               H.it "example 3" $ mockAction e3         (,,) <$> mockCounter e1 <*> mockCounter e2 <*> mockCounter e3 `shouldReturn` (1, 1, 0) +      it "only runs examples that match a given pattern (-m and --skip combined)" $ do+        e1 <- newMock+        e2 <- newMock+        e3 <- newMock+        e4 <- newMock+        silence . withArgs ["-m", "/bar/example", "--skip", "example 3"] . H.hspec $ do+          H.describe "foo" $ do+            H.describe "bar" $ do+              H.it "example 1" $ mockAction e1+              H.it "example 2" $ mockAction e2+              H.it "example 3" $ mockAction e3+            H.describe "baz" $ do+              H.it "example 4" $ mockAction e4+        (,,,) <$> mockCounter e1 <*> mockCounter e2 <*> mockCounter e3 <*> mockCounter e4+          `shouldReturn` (1, 1, 0, 0)+       it "can be given multiple times" $ do         e1 <- newMock         e2 <- newMock