hspec 1.5.0 → 1.5.1
raw patch · 6 files changed
+31/−36 lines, 6 filesdep +quickcheck-iodep ~hspec-expectationsdep ~hspec-metaPVP ok
version bump matches the API change (PVP)
Dependencies added: quickcheck-io
Dependency ranges changed: hspec-expectations, hspec-meta
API changes (from Hackage documentation)
Files
- hspec.cabal +5/−3
- src/Test/Hspec/Core/Type.hs +2/−11
- test/Test/Hspec/Core/TypeSpec.hs +5/−5
- test/Test/Hspec/HUnitSpec.hs +3/−2
- test/Test/Hspec/QuickCheckSpec.hs +2/−1
- test/Test/Hspec/RunnerSpec.hs +14/−14
hspec.cabal view
@@ -1,5 +1,5 @@ name: hspec-version: 1.5.0+version: 1.5.1 license: BSD3 license-file: LICENSE copyright: (c) 2011-2013 Simon Hengel, (c) 2011-2012 Trystan Spangler, (c) 2011 Greg Weber@@ -57,7 +57,8 @@ , transformers >= 0.2.2.0 && < 0.4.0 , HUnit >= 1.2.5 , QuickCheck >= 2.5.1- , hspec-expectations == 0.3.0.*+ , quickcheck-io+ , hspec-expectations == 0.3.2.* exposed-modules: Test.Hspec Test.Hspec.Core@@ -106,9 +107,10 @@ , transformers , HUnit , QuickCheck+ , quickcheck-io , hspec-expectations - , hspec-meta+ , hspec-meta >= 1.5.1 , process , ghc-paths
src/Test/Hspec/Core/Type.hs view
@@ -32,9 +32,11 @@ import qualified Test.QuickCheck as QC import qualified Test.QuickCheck.State as QC import qualified Test.QuickCheck.Property as QCP+import qualified Test.QuickCheck.IO () import Test.Hspec.Compat (isUserInterrupt) + type Spec = SpecM () -- | A writer monad for `SpecTree` forests.@@ -138,17 +140,6 @@ where n = length prefix prefix = "*** Failed! Exception: '"--instance QC.Testable Expectation where- property = propertyIO- exhaustive _ = True--propertyIO :: Expectation -> QC.Property-propertyIO action = QCP.morallyDubiousIOProperty $ do- (action >> return succeeded) `E.catch` \(HUnitFailure err) -> return (failed err)- where- succeeded = QC.property QCP.succeeded- failed err = QC.property QCP.failed {QCP.reason = err} -- | Specifies a pending example. --
test/Test/Hspec/Core/TypeSpec.hs view
@@ -5,8 +5,8 @@ import Test.QuickCheck import Mock import Data.List+import System.IO.Silently -import Test.QuickCheck.Property (morallyDubiousIOProperty) import Control.Exception (AsyncException(..), throwIO) import qualified Test.Hspec.Core.Type as H hiding (describe, it) import qualified Test.Hspec as H@@ -77,11 +77,11 @@ ] it "propagates UserInterrupt" $ do- let p = morallyDubiousIOProperty (throwIO UserInterrupt >> return True)+ let p = property (throwIO UserInterrupt :: Expectation) evaluateExample p `shouldThrow` (== UserInterrupt) it "propagates exceptions" $ do- pending "this probaly needs a patch to QuickCheck"+ pendingWith "this probaly needs a patch to QuickCheck" -- evaluateExample (property $ (error "foobar" :: Int -> Bool)) `shouldThrow` errorCall "foobar" context "when used with `pending`" $ do@@ -96,14 +96,14 @@ context "as a QuickCheck property" $ do it "can be quantified" $ do e <- newMock- H.hspec $ do+ silence . H.hspec $ do H.it "some behavior" $ property $ \xs -> do mockAction e (reverse . reverse) xs `shouldBe` (xs :: [Int]) mockCounter e `shouldReturn` 100 it "can be used with expecatations/HUnit assertions" $ do- H.hspecWith H.defaultConfig $ do+ silence . H.hspecWith H.defaultConfig $ do H.describe "readIO" $ do H.it "is inverse to show" $ property $ \x -> do (readIO . show) x `shouldReturn` (x :: Int)
test/Test/Hspec/HUnitSpec.hs view
@@ -3,6 +3,7 @@ import Test.Hspec.Meta import SpecHelper (captureLines) import Control.Applicative+import System.IO.Silently import qualified Test.Hspec as H import qualified Test.Hspec.Runner as H@@ -54,13 +55,13 @@ describe "HUnit TestCase as an example (deprecated!)" $ do it "is specified with the HUnit `TestCase` data constructor" $ TestCase $ do- runSpec $ do+ silence . runSpec $ do H.it "some behavior" (TestCase $ "foo" @?= "bar") H.it "some behavior" (TestCase $ "foo" @?= "foo") `shouldReturn` H.Summary 2 1 it "is the assumed example for IO() actions" $ do- runSpec $ do+ silence . runSpec $ do H.it "some behavior" ("foo" @?= "bar") H.it "some behavior" ("foo" @?= "foo") `shouldReturn` H.Summary 2 1
test/Test/Hspec/QuickCheckSpec.hs view
@@ -1,6 +1,7 @@ module Test.Hspec.QuickCheckSpec (main, spec) where import Test.Hspec.Meta+import System.IO.Silently import qualified Test.Hspec as H import qualified Test.Hspec.Runner as H@@ -13,7 +14,7 @@ spec = do describe "prop" $ do it "is a shortcut to use properties as examples" $ do- H.hspecWith H.defaultConfig $ do+ silence . H.hspecWith H.defaultConfig $ do H.describe "read" $ do H.prop "is inverse to show" $ \x -> (read . show) x == (x :: Int) `shouldReturn` H.Summary 1 0
test/Test/Hspec/RunnerSpec.hs view
@@ -12,7 +12,7 @@ import Mock import System.SetEnv import Test.Hspec.Util (getEnv)-import Test.QuickCheck.Property (morallyDubiousIOProperty)+import Test.QuickCheck import qualified Test.Hspec.Runner as H import qualified Test.Hspec as H (describe, it, pending)@@ -32,12 +32,12 @@ describe "hspec" $ do it "runs a spec" $ do- H.hspec $ do+ silence . H.hspec $ do H.it "foobar" True `shouldReturn` () it "exits with exitFailure if not all examples pass" $ do- H.hspec $ do+ silence . H.hspec $ do H.it "foobar" False `shouldThrow` (== ExitFailure 1) @@ -56,7 +56,7 @@ ] it "does not leak command-line flags to examples" $ do- withArgs ["--verbose"] $ do+ silence . withArgs ["--verbose"] $ do H.hspec $ do H.it "foobar" $ do getArgs `shouldReturn` []@@ -78,7 +78,7 @@ ] it "throws UserInterrupt" $ do- H.hspec $ do+ silence . H.hspec $ do H.it "foo" $ do E.throwIO E.UserInterrupt :: IO () `shouldThrow` (== E.UserInterrupt)@@ -88,7 +88,7 @@ it "prints help" $ do r <- (captureLines . ignoreExitCode) printHelp r `shouldStartWith` ["Usage: spec [OPTION]..."]- printHelp `shouldThrow` (== ExitSuccess)+ silence printHelp `shouldThrow` (== ExitSuccess) it "constrains lines to 80 characters" $ do r <- (captureLines . ignoreExitCode) printHelp@@ -154,7 +154,7 @@ e1 <- newMock e2 <- newMock e3 <- newMock- withArgs ["-m", "/bar/example"] . H.hspec $ do+ silence . withArgs ["-m", "/bar/example"] . H.hspec $ do H.describe "foo" $ do H.describe "bar" $ do H.it "example 1" $ mockAction e1@@ -167,7 +167,7 @@ e1 <- newMock e2 <- newMock e3 <- newMock- withArgs ["-m", "foo", "-m", "baz"] . H.hspec $ do+ silence . withArgs ["-m", "foo", "-m", "baz"] . H.hspec $ do H.describe "foo" $ do H.it "example 1" $ mockAction e1 H.describe "bar" $ do@@ -179,9 +179,9 @@ context "with --maximum-generated-tests=n" $ do it "tries QuickCheck properties n times" $ do m <- newMock- withArgs ["--maximum-generated-tests=23"] . H.hspec $ do- H.it "foo" $ do- morallyDubiousIOProperty (mockAction m >> pure True)+ silence . withArgs ["--maximum-generated-tests=23"] . H.hspec $ do+ H.it "foo" $ property $ do+ mockAction m mockCounter m `shouldReturn` 23 context "with --print-cpu-time" $ do@@ -212,7 +212,7 @@ describe "hspec (experimental features)" $ do it "stores a failure report in environment HSPEC_FAILURES" $ do- ignoreExitCode . H.hspec $ do+ silence . ignoreExitCode . H.hspec $ do H.describe "foo" $ do H.describe "bar" $ do H.it "example 1" True@@ -260,7 +260,7 @@ describe "hspecWith" $ do it "returns a summary of the test run" $ do- H.hspecWith H.defaultConfig $ do+ silence . H.hspecWith H.defaultConfig $ do H.it "foo" True H.it "foo" False H.it "foo" False@@ -269,7 +269,7 @@ `shouldReturn` H.Summary 5 2 it "treats uncaught exceptions as failure" $ do- H.hspecWith H.defaultConfig $ do+ silence . H.hspecWith H.defaultConfig $ do H.it "foobar" (E.throwIO (E.ErrorCall "foobar") >> pure ()) `shouldReturn` H.Summary 1 1