hspec 1.5.3 → 1.5.4
raw patch · 6 files changed
+25/−20 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- hspec.cabal +6/−2
- src/Test/Hspec/Config.hs +1/−1
- src/Test/Hspec/Core/Type.hs +2/−2
- src/Test/Hspec/Formatters.hs +4/−3
- src/Test/Hspec/Util.hs +7/−7
- test/Test/Hspec/UtilSpec.hs +5/−5
hspec.cabal view
@@ -1,8 +1,10 @@ name: hspec-version: 1.5.3+version: 1.5.4 license: BSD3 license-file: LICENSE-copyright: (c) 2011-2013 Simon Hengel, (c) 2011-2012 Trystan Spangler, (c) 2011 Greg Weber+copyright: (c) 2011-2013 Simon Hengel,+ (c) 2011-2012 Trystan Spangler,+ (c) 2011 Greg Weber maintainer: Simon Hengel <sol@typeful.net> build-type: Simple cabal-version: >= 1.8@@ -179,6 +181,7 @@ , hspec-meta test-suite hspec-discover-example+ buildable: False type: exitcode-stdio-1.0 ghc-options:@@ -193,6 +196,7 @@ , QuickCheck test-suite hspec-discover-integration-test-empty+ buildable: False type: exitcode-stdio-1.0 ghc-options:
src/Test/Hspec/Config.hs view
@@ -47,7 +47,7 @@ data ColorMode = ColorAuto | ColorNever | ColorAlway defaultConfig :: Config-defaultConfig = Config False False False False False Nothing QC.stdArgs {QC.chatty = False} ColorAuto specdoc False stdout+defaultConfig = Config False False False False False Nothing QC.stdArgs ColorAuto specdoc False stdout formatters :: [(String, Formatter)] formatters = [
src/Test/Hspec/Core/Type.hs view
@@ -110,7 +110,7 @@ instance Example QC.Property where evaluateExample c p = do- r <- QC.quickCheckWithResult (paramsQuickCheckArgs c) (QCP.callback progressCallback p)+ r <- QC.quickCheckWithResult (paramsQuickCheckArgs c) {QC.chatty = False} (QCP.callback progressCallback p) when (isUserInterrupt r) $ do E.throwIO E.UserInterrupt @@ -118,7 +118,7 @@ case r of QC.Success {} -> Success QC.Failure {QC.output = m} -> fromMaybe (Fail $ sanitizeFailureMessage m) (parsePending m)- QC.GaveUp {QC.numTests = n} -> Fail ("Gave up after " ++ quantify n "test" )+ QC.GaveUp {QC.numTests = n} -> Fail ("Gave up after " ++ pluralize n "test" ) QC.NoExpectedFailure {} -> Fail ("No expected failure") where progressCallback = QCP.PostTest QCP.NotCounterexample $
src/Test/Hspec/Formatters.hs view
@@ -55,7 +55,7 @@ import Control.Monad (unless, forM_) import Control.Applicative import qualified Control.Exception as E-import System.IO (hPutStr)+import System.IO (hPutStr, hFlush) -- We use an explicit import list for "Test.Hspec.Formatters.Internal", to make -- sure, that we only use the public API to implement formatters.@@ -121,6 +121,7 @@ , exampleProgress = \h _ (current, total) -> do hPutStr h $ "(" ++ show current ++ "/" ++ show total ++ ")\r"+ hFlush h , exampleSucceeded = \(nesting, requirement) -> withSuccessColor $ do writeLine $ indentationFor nesting ++ "- " ++ requirement@@ -207,8 +208,8 @@ | pending /= 0 = withPendingColor | otherwise = withSuccessColor c $ do- write $ quantify total "example"- write (", " ++ quantify fails "failure")+ write $ pluralize total "example"+ write (", " ++ pluralize fails "failure") unless (pending == 0) $ write (", " ++ show pending ++ " pending") writeLine ""
src/Test/Hspec/Util.hs view
@@ -1,5 +1,5 @@ module Test.Hspec.Util (- quantify+ pluralize , lineBreaksAt , safeTry , Path@@ -25,17 +25,17 @@ -- -- Examples: ----- >>> quantify 0 "example"+-- >>> pluralize 0 "example" -- "0 examples" ----- >>> quantify 1 "example"+-- >>> pluralize 1 "example" -- "1 example" ----- >>> quantify 2 "example"+-- >>> pluralize 2 "example" -- "2 examples"-quantify :: Int -> String -> String-quantify 1 s = "1 " ++ s-quantify n s = show n ++ " " ++ s ++ "s"+pluralize :: Int -> String -> String+pluralize 1 s = "1 " ++ s+pluralize n s = show n ++ " " ++ s ++ "s" safeTry :: IO a -> IO (Either E.SomeException a) safeTry action = (Right <$> (action >>= E.evaluate)) `E.catches` [
test/Test/Hspec/UtilSpec.hs view
@@ -16,18 +16,18 @@ spec :: Spec spec = do- describe "quantify" $ do+ describe "pluralize" $ do it "returns an amount and a word given an amount and word" $ do- quantify 1 "thing" `shouldBe` "1 thing"+ pluralize 1 "thing" `shouldBe` "1 thing" it "returns a singular word given the number 1" $ do- quantify 1 "thing" `shouldBe` "1 thing"+ pluralize 1 "thing" `shouldBe` "1 thing" it "returns a plural word given a number greater than 1" $ do- quantify 2 "thing" `shouldBe` "2 things"+ pluralize 2 "thing" `shouldBe` "2 things" it "returns a plural word given the number 0" $ do- quantify 0 "thing" `shouldBe` "0 things"+ pluralize 0 "thing" `shouldBe` "0 things" describe "lineBreaksAt" $ do it "inserts line breaks at word boundaries" $ do