bdd 0.1.0.0 → 0.2.0.0
raw patch · 4 files changed
+36/−27 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- bdd.cabal +7/−3
- changelog.md +6/−0
- src/Test/Bdd.hs +2/−2
- tests/system/BddTest.hs +21/−22
bdd.cabal view
@@ -1,5 +1,5 @@ Name: bdd-Version: 0.1.0.0+Version: 0.2.0.0 Synopsis: Behavior-Driven Development DSL Homepage: http://github.com/humane-software/haskell-bdd License: MIT@@ -7,10 +7,14 @@ Author: Irek Jozwiak, Pavlo Kerestey Maintainer: irek@humane.software Category: Testing-Stability: experimental+Stability: provisional Build-Type: Simple Cabal-Version: >=1.10-Description: A domain-specific language for testing programs using Behavior-Driven Development (BDD) process.+Description: + .+ An internal domain-specific language for testing programs using Behavior-Driven Development (BDD) process. It helps arranging your tests in "given" \/ "when" \/ "then" parts.+ .+ For a more detailed description please refer to <https://github.com/humane-software/haskell-bdd/> extra-source-files: changelog.md
changelog.md view
@@ -1,3 +1,9 @@+0.2.0.0++* bugfix: "teardown" expressions now run after "then" block (changed precedence of `then_`)++* added a description of the library to the cabal file+ 0.1.0.0 * Initial version
src/Test/Bdd.hs view
@@ -26,8 +26,8 @@ testThat :: GivenWithTeardown m testThat = [] -infixl 1 `given_`, `when_`, `then_`-infixl 2 `andAfter_`+infixl 1 `given_`, `when_`+infixl 2 `andAfter_`, `then_` given_ :: (StorableAsGivenWithTeardown m g,Monad m) => GivenWithTeardown m -> g -> GivenWithTeardown m given_ gs g = gs ++ mkGiven g
tests/system/BddTest.hs view
@@ -31,11 +31,11 @@ ,"multiple thens are possible" ~: do testThat- `when_` writeFile "/tmp/BddTestFile" "xxx"- `then_` readFile "/tmp/BddTestFile" ^?= "xxx"- `then_` (elem "BddTestFile" <$> getDirectoryContents "/tmp/") ^?= True+ `when_` writeFile "/tmp/BddTestFile2" "xxx"+ `then_` readFile "/tmp/BddTestFile2" ^?= "xxx"+ `then_` (elem "BddTestFile2" <$> getDirectoryContents "/tmp/") ^?= True -- we'll explain how to teardown later- void (runCommand "rm -f /tmp/BddTestFile")+ void (runCommand "rm -f /tmp/BddTestFile2") ,"preconditions are possible as givens" ~: let noFile :: FilePath -> Given IO ()@@ -48,25 +48,24 @@ -- we'll explain how to teardown later void (runCommand "rm -f /tmp/BddTestFile") - -- TODO: to be implemented- -- ,"given can have a teardown, it takes given's return value" ~:- -- let directory :: FilePath -> Given IO FilePath- -- directory f = removeDir f >> createDirectory f >> return f- -- removeDir :: FilePath -> IO ()- -- removeDir f = doesDirectoryExist f >>= \exists->- -- when exists (removeDirectoryRecursive f)- -- in testThat- -- `given_` directory "/tmp/BddTestDir" `andAfter_` removeDir- -- `when_` writeFile "/tmp/BddTestDir/test" "xxx"- -- `then_` readFile "/tmp/BddTestDir/test" ^?= "xxx"+ ,"given can have a teardown, it takes given's return value" ~:+ let directory :: FilePath -> Given IO FilePath+ directory f = removeDir f >> createDirectory f >> return f+ removeDir :: FilePath -> IO ()+ removeDir f = doesDirectoryExist f >>= \exists->+ when exists (removeDirectoryRecursive f)+ in testThat+ `given_` directory "/tmp/BddTestDir" `andAfter_` removeDir+ `when_` writeFile "/tmp/BddTestDir/test" "xxx"+ `then_` readFile "/tmp/BddTestDir/test" ^?= "xxx" - -- ,"order of execution" ~:- -- execWriter (- -- (testThat::GivenWithTeardown (Writer [String]))- -- `given_` (tell ["given"]::Writer [String] ()) `andAfter_` const (tell ["teardown"])- -- `when_` tell ["when"]- -- `then_` const (tell ["then"])- -- ) @?= ["given","when","then","teardown"]+ ,"order of execution" ~:+ execWriter (+ (testThat::GivenWithTeardown (Writer [String]))+ `given_` (tell ["given"]::Writer [String] ()) `andAfter_` const (tell ["teardown"])+ `when_` tell ["when"]+ `then_` const (tell ["then"])+ ) @?= ["given","when","then","teardown"] ,"can expect an error" ~: testThat