packages feed

hspec-dirstream 0.3.0.0 → 0.4.0.0

raw patch · 3 files changed

+14/−2 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Test.Hspec.Dirstream: testPaths :: FilePath -> (FilePath -> Bool) -> (FilePath -> IO ()) -> SpecWith ()

Files

hspec-dirstream.cabal view
@@ -1,5 +1,5 @@ name:                hspec-dirstream-version:             0.3.0.0+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
src/Test/Hspec/Dirstream.hs view
@@ -10,6 +10,7 @@     , testFilesIO     , testFilesErr     , testFilesPredicate+    , testPaths     -- * Helper functions for dealing with file extensions     , F.extension     , Test.Hspec.Dirstream.hasExtension@@ -67,6 +68,9 @@ testFilesIO :: FilePath -> (F.FilePath -> Bool) -> (String -> IO String) -> SpecWith () testFilesIO dir p f = runSafeT $ runEffect $ paths dir p >-> mapS (testFileIO f) +testPaths :: FilePath -> (F.FilePath -> Bool) -> (FilePath -> IO ()) -> SpecWith ()+testPaths dir p f = runSafeT $ runEffect $ paths dir p >-> mapS (testPathWorks f)+ -- | This function checks that each file returns a value satisfying the -- predicate. testFilesPredicate :: (Show a, Eq a)@@ -76,6 +80,11 @@                    -> (a -> Bool) -- ^ Predicate to check the result                    -> SpecWith () testFilesPredicate dir p f pr = runSafeT $ runEffect $ paths dir p >-> mapS (testFilePredicate f pr)++-- | Run an action on a file path.+testPathWorks :: (FilePath -> IO ()) -> FilePath -> SpecWith ()+testPathWorks fun path = it path $+    fun path >>= (`shouldBe` ())  testFileIO :: (String -> IO String) -> String -> SpecWith () testFileIO fun f = it f $ do
test/Spec.hs view
@@ -1,9 +1,10 @@ {-# LANGUAGE CPP               #-} {-# LANGUAGE OverloadedStrings #-} -#if __GLASGOW_HASKELL__ <= 784+#if __GLASGOW_HASKELL__ <= 708 import           Control.Applicative #endif+import           Control.Monad import           Test.Hspec import           Test.Hspec.Dirstream @@ -15,3 +16,5 @@             testFilesIO "test/data" (hasExtension "hs") (pure . tail)     describe "testFilesPredicate" $             testFilesPredicate "test/data" (hasExtension "hs") tail ((>= 0) . length)+    describe "testPaths" $+            testPaths "test/data" (hasExtension "hs") (void . readFile)