packages feed

hspec-test-sandbox (empty) → 0.1.0

raw patch · 5 files changed

+108/−0 lines, 5 filesdep +basedep +hspecdep +hspec-coresetup-changed

Dependencies added: base, hspec, hspec-core, hspec-test-sandbox, test-sandbox

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2014, Junji Hashimoto++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Junji Hashimoto nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ hspec-test-sandbox.cabal view
@@ -0,0 +1,41 @@+-- Initial hspec-test-sandbox.cabal generated by cabal init.  For further +-- documentation, see http://haskell.org/cabal/users-guide/++name:                hspec-test-sandbox+version:             0.1.0+synopsis:            Hspec convenience functions for use with test-sandbox+description:         This package provides useful functions to write around the Test.Hspec unit-test functions,+                     allowing them to be used easily in the Test.Sandbox monad provided by the test-sandbox package.+license:             BSD3+license-file:        LICENSE+author:              Junji Hashimoto+maintainer:          junji.hashimoto@gmail.com+-- copyright:           +category:            Testing+build-type:          Simple+-- extra-source-files:  +cabal-version:       >=1.10++library+  exposed-modules:     Test.Hspec.Sandbox+  -- other-modules:       +  -- other-extensions:    +  build-depends:       base >=4.6 && <5+                     , test-sandbox+                     , hspec-core >= 2+                     , hspec >= 2+  hs-source-dirs:      src+  default-language:    Haskell2010+  ghc-options:         -Wall++test-suite test+    type:              exitcode-stdio-1.0+    main-is:           test.hs+    hs-source-dirs:    test,dist/build/autogen+    ghc-options:       -Wall++    build-depends: base+                 , test-sandbox+                 , hspec >= 2+                 , hspec-test-sandbox+    Default-Language:   Haskell2010
+ src/Test/Hspec/Sandbox.hs view
@@ -0,0 +1,23 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}++module Test.Hspec.Sandbox (+  with+) where++import Test.Sandbox.Internals+import qualified Test.Hspec.Core.Spec as Hspec+import qualified Test.Hspec as Hspec+++with :: SandboxStateRef -> Hspec.SpecWith SandboxStateRef -> Hspec.Spec+with ref = Hspec.before (return ref)++instance Hspec.Example (Sandbox ()) where+  type Arg (Sandbox ()) = SandboxStateRef+  evaluateExample example params action =+    Hspec.evaluateExample+      (action $ flip runSandbox' example)+      params+      ($ ())
+ test/test.hs view
@@ -0,0 +1,12 @@+import Test.Hspec+import Test.Hspec.Sandbox+import Test.Sandbox++main :: IO ()+main = withSandbox $ \ref -> do+  hspec $ do+    describe "Basic Test" $ with ref $ do+      it "interactive Test" $ do+        start =<< register "sed_regex" "sed" [ "-u", "s/a/b/" ] def { psCapture = Just CaptureStdout }+        v <- interactWith "sed_regex" "a\n" 1+        liftIO $ v `shouldBe` "b\n"