packages feed

hspec-dirstream 0.4.0.0 → 0.5.0.0

raw patch · 4 files changed

+91/−65 lines, 4 filesdep +bytestringPVP ok

version bump matches the API change (PVP)

Dependencies added: bytestring

API changes (from Hackage documentation)

+ Test.Hspec.Dirstream: testFilesPredicateBS :: (Show a, Eq a) => FilePath -> (FilePath -> Bool) -> (ByteString -> a) -> (a -> Bool) -> SpecWith ()

Files

cabal.project.local view
@@ -1,6 +1,2 @@ constraints: hspec-dirstream +development-with-compiler: ghc-8.2.2-tests: True documentation: True-haddock-hoogle: True-haddock-internal: True
hspec-dirstream.cabal view
@@ -1,62 +1,77 @@-name:                hspec-dirstream-version:             0.4.0.0-synopsis:            Helper functions to simplify adding integration tests.-description:         This package uses [hspec](http://hackage.haskell.org/package/hspec) and [dirstream](http://hackage.haskell.org/package/dirstream) to provide easy-to-use functions for integration tests.-homepage:            https://hub.darcs.net/vmchale/hspec-dirstream-license:             BSD3-license-file:        LICENSE-author:              Vanessa McHale-maintainer:          vamchale@gmail.com-copyright:           Copyright: (c) 2018 Vanessa McHale-category:            Testing, Development-build-type:          Simple-extra-doc-files:     README.md-data-files:          test/data/*.hs-                   , test/data/*.out-extra-source-files:  stack.yaml-                   , cabal.project.local-cabal-version:       >=1.18+cabal-version: 1.18+name: hspec-dirstream+version: 0.5.0.0+license: BSD3+license-file: LICENSE+copyright: Copyright: (c) 2018 Vanessa McHale+maintainer: vamchale@gmail.com+author: Vanessa McHale+homepage: https://hub.darcs.net/vmchale/hspec-dirstream+synopsis: Helper functions to simplify adding integration tests.+description:+    This package uses [hspec](http://hackage.haskell.org/package/hspec) and [dirstream](http://hackage.haskell.org/package/dirstream) to provide easy-to-use functions for integration tests.+category: Testing, Development+build-type: Simple+data-files:+    test/data/*.hs+    test/data/*.out+extra-source-files:+    stack.yaml+    cabal.project.local+extra-doc-files: README.md -Flag development {-  Description: Enable `-Werror`-  manual: True-  default: False-}+source-repository head+    type: darcs+    location: https://hub.darcs.net/vmchale/hspec-dirstream +flag development+    description:+        Enable `-Werror`+    default: False+    manual: True+ library-  hs-source-dirs:      src-  exposed-modules:     Test.Hspec.Dirstream-  build-depends:       base >= 4.7 && < 5-                     , hspec-                     , dirstream-                     , pipes-                     , pipes-safe-                     , filepath-                     , hspec-core-                     , system-filepath-                     , text-  default-language:    Haskell2010-  if flag(development)-    ghc-options:       -Werror-  if impl(ghc >= 8.0)-    ghc-options:       -Wincomplete-uni-patterns -Wincomplete-record-updates -Wcompat-  ghc-options:         -Wall+    exposed-modules:+        Test.Hspec.Dirstream+    hs-source-dirs: src+    default-language: Haskell2010+    ghc-options: -Wall+    build-depends:+        base >=4.7 && <5,+        hspec -any,+        dirstream -any,+        pipes -any,+        pipes-safe -any,+        filepath -any,+        hspec-core -any,+        system-filepath -any,+        text -any,+        bytestring -any+    +    if flag(development)+        ghc-options: -Werror+    +    if impl(ghc >=8.0)+        ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates+                     -Wcompat  test-suite hspec-dirstream-test-  type:                exitcode-stdio-1.0-  hs-source-dirs:      test-  main-is:             Spec.hs-  build-depends:       base-                     , hspec-dirstream-                     , hspec-  if flag(development)-    if impl(ghc >= 8.0)-      ghc-options:     -Werror-  if impl(ghc >= 8.0)-    ghc-options:       -Wincomplete-uni-patterns -Wincomplete-record-updates -Wcompat-  ghc-options:         -threaded -rtsopts -with-rtsopts=-N -Wall-  default-language:    Haskell2010--source-repository head-  type:     darcs-  location: https://hub.darcs.net/vmchale/hspec-dirstream+    type: exitcode-stdio-1.0+    main-is: Spec.hs+    hs-source-dirs: test+    default-language: Haskell2010+    ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall+    build-depends:+        base -any,+        hspec-dirstream -any,+        hspec -any,+        bytestring -any+    +    if flag(development)+        +        if impl(ghc >=8.0)+            ghc-options: -Werror+    +    if impl(ghc >=8.0)+        ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates+                     -Wcompat
src/Test/Hspec/Dirstream.hs view
@@ -10,12 +10,14 @@     , testFilesIO     , testFilesErr     , testFilesPredicate+    , testFilesPredicateBS     , testPaths     -- * Helper functions for dealing with file extensions     , F.extension     , Test.Hspec.Dirstream.hasExtension     ) where +import qualified Data.ByteString.Lazy      as BSL import           Data.DirStream import           Data.Text                 (Text) import qualified Filesystem.Path.CurrentOS as F@@ -81,6 +83,15 @@                    -> SpecWith () testFilesPredicate dir p f pr = runSafeT $ runEffect $ paths dir p >-> mapS (testFilePredicate f pr) +-- | Same as @testFilesPredicate@, but reads the file as a 'ByteString'.+testFilesPredicateBS :: (Show a, Eq a)+                    => FilePath+                    -> (F.FilePath -> Bool)+                    -> (BSL.ByteString -> a)+                    -> (a -> Bool)+                    -> SpecWith ()+testFilesPredicateBS dir p f pr = runSafeT $ runEffect $ paths dir p >-> mapS (testFilePredicateBS f pr)+ -- | Run an action on a file path. testPathWorks :: (FilePath -> IO ()) -> FilePath -> SpecWith () testPathWorks fun path = it path $@@ -97,6 +108,11 @@ -- file. testFilesErr :: (Show b, Eq b) => FilePath -> (F.FilePath -> Bool) -> (String -> Either String b) -> SpecWith () testFilesErr dir p f = runSafeT $ runEffect $ paths dir p >-> mapS (testFileErr f)++testFilePredicateBS :: (Eq a, Show a) => (BSL.ByteString -> a) -> (a -> Bool) -> String -> SpecWith ()+testFilePredicateBS fun p f = it f $ do+    sample <- BSL.readFile f+    fun sample `shouldSatisfy` p  testFilePredicate :: (Eq a, Show a) => (String -> a) -> (a -> Bool) -> String -> SpecWith () testFilePredicate fun p f = it f $ do
test/Spec.hs view
@@ -1,10 +1,7 @@-{-# LANGUAGE CPP               #-} {-# LANGUAGE OverloadedStrings #-} -#if __GLASGOW_HASKELL__ <= 708-import           Control.Applicative-#endif import           Control.Monad+import qualified Data.ByteString.Lazy as BSL import           Test.Hspec import           Test.Hspec.Dirstream @@ -16,5 +13,7 @@             testFilesIO "test/data" (hasExtension "hs") (pure . tail)     describe "testFilesPredicate" $             testFilesPredicate "test/data" (hasExtension "hs") tail ((>= 0) . length)+    describe "testFilesPredicateBS" $+            testFilesPredicateBS "test/data" (hasExtension "hs") id ((>= 0) . BSL.length)     describe "testPaths" $             testPaths "test/data" (hasExtension "hs") (void . readFile)