hspec-dirstream 0.1.0.2 → 0.2.0.0
raw patch · 3 files changed
+18/−5 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Test.Hspec.Dirstream: testFilesIO :: FilePath -> (FilePath -> Bool) -> (String -> IO String) -> SpecWith ()
Files
- hspec-dirstream.cabal +1/−1
- src/Test/Hspec/Dirstream.hs +13/−1
- test/Spec.hs +4/−3
hspec-dirstream.cabal view
@@ -1,5 +1,5 @@ name: hspec-dirstream-version: 0.1.0.2+version: 0.2.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
@@ -5,7 +5,10 @@ {-# LANGUAGE StandaloneDeriving #-} module Test.Hspec.Dirstream- ( testFiles+ ( -- Functions to generate a `Spec`+ testFiles+ , testFilesIO+ -- * Helper functions for dealing with file extensions , F.extension , Test.Hspec.Dirstream.hasExtension ) where@@ -57,6 +60,15 @@ -> (String -> Either a String) -- ^ Function to process a file -> SpecWith () testFiles dir p f = runSafeT $ runEffect $ paths dir p >-> mapS (testFile f)++testFilesIO :: FilePath -> (F.FilePath -> Bool) -> (String -> IO String) -> SpecWith ()+testFilesIO dir p f = runSafeT $ runEffect $ paths dir p >-> mapS (testFileIO f)++testFileIO :: (String -> IO String) -> String -> SpecWith ()+testFileIO fun f = it f $ do+ sample <- readFile f+ expected <- readFile (replaceExtension f ".out")+ fun sample >>= (`shouldBe` expected) testFile :: (Eq a, Show a) => (String -> Either a String) -> String -> SpecWith () testFile fun f = it f $ do
test/Spec.hs view
@@ -8,7 +8,8 @@ import Test.Hspec.Dirstream main :: IO ()-main = hspec $- describe "tail" $- parallel $+main = hspec $ parallel $ do+ describe "testFiles" $ testFiles "test/data" (hasExtension "hs") ((pure :: a -> Either String a) . tail)+ describe "testFilesIO" $+ testFilesIO "test/data" (hasExtension "hs") (pure . tail)