packages feed

mockery 0.0.0 → 0.1.0

raw patch · 3 files changed

+34/−6 lines, 3 filesnew-uploader

Files

mockery.cabal view
@@ -1,13 +1,13 @@--- This file has been generated from package.yaml by hpack.+-- This file has been generated from package.yaml by hpack version 0.1.2. -- -- see: https://github.com/sol/hpack  name:           mockery-version:        0.0.0+version:        0.1.0 synopsis:       Support functions for automated testing description:    Support functions for automated testing category:       Testing-bug-reports:    https://github.com/sol/mockery/issues+bug-reports:    https://github.com/hspec/mockery/issues author:         Simon Hengel <sol@typeful.net> maintainer:     Simon Hengel <sol@typeful.net> copyright:      (c) 2015 Simon Hengel@@ -18,7 +18,7 @@  source-repository head   type: git-  location: https://github.com/sol/mockery+  location: https://github.com/hspec/mockery  library   hs-source-dirs: src@@ -35,6 +35,8 @@   type: exitcode-stdio-1.0   hs-source-dirs: test   main-is: Spec.hs+  other-modules:+      Test.Mockery.DirectorySpec   build-depends:       base == 4.*     , temporary
src/Test/Mockery/Directory.hs view
@@ -1,11 +1,13 @@ module Test.Mockery.Directory (   inTempDirectory , inTempDirectoryNamed+, withFile ) where  import           Control.Exception import           System.Directory-import           System.IO.Temp (withSystemTempDirectory)+import           System.IO hiding (withFile)+import           System.IO.Temp (withSystemTempDirectory, withSystemTempFile)  -- | -- Run given action with the current working directory set to a temporary@@ -15,7 +17,7 @@ -- completed the directory is removed and the current working directory is -- restored to its original value. inTempDirectory :: IO a -> IO a-inTempDirectory action = withSystemTempDirectory "hspec" $ \path -> do+inTempDirectory action = withSystemTempDirectory "mockery" $ \path -> do   bracket getCurrentDirectory setCurrentDirectory $ \_ -> do     setCurrentDirectory path     action@@ -28,3 +30,14 @@   createDirectory name   setCurrentDirectory name   action++-- |+-- Create a temporary file with the given contents and execute the given+-- action.+--+-- The file is removed after the action has completed.+withFile :: String -> (FilePath -> IO a) -> IO a+withFile input action = withSystemTempFile "mockery" $ \file h -> do+  hPutStr h input+  hClose h+  action file
+ test/Test/Mockery/DirectorySpec.hs view
@@ -0,0 +1,13 @@++module Test.Mockery.DirectorySpec where++import           Test.Hspec++import           Test.Mockery.Directory++spec :: Spec+spec = do+  describe "withFile" $ do+    it "creates a temporary file with the given contents" $ do+      withFile "foo" $ \file ->+        readFile file `shouldReturn` "foo"