packages feed

snap-testing 0.4.1.0 → 0.4.1.1

raw patch · 3 files changed

+36/−8 lines, 3 files

Files

+ CHANGELOG view
@@ -0,0 +1,28 @@+0.4.1.1 - 2014-3-20 - Add this changelog to hackage, grammar in comments.++0.4.1.0 - 2014-3-20 - Add form tests, assert.+  * Add form test utility that runs digestive forms against values and checks that they+	either produce a given value (one form of test) or produce a set of errors+	specified by the paths to the form.+  * Add assert that lifts a Bool into a TestPass or TestFail.++0.4.0.0 - 2014-3-20 - Change interface to a conf, and add TestError variant,+	for when tests don't fail, but have an unexpected error. This breaks+	the API.++0.3.0.0 - 2014-3-5 - Switch to streaming interface for report generators.+ * Streams uses io-streams (a soon-to-be dependency of snap), and allow+	test results to be reported immediately, not only at the end of the test run.++0.2.1.0 - 2014-2-11 - Add support for get requests with parameters.++0.2.0.1 - 2014-2-3 - Fix bug in redirectsto.+  * redirectsto would try to get the location header using a partial function+	regardless of whether it was a redirect, causing the whole test suite+	to fail.+++0.2.0.0 - 2014-1-13 - Renaming root.+  * Snap.Testing becomes Snap.Test.BDD, as per comment by @gregorycollins.++0.1.0.0 - 2014-1-13 - Initial release
snap-testing.cabal view
@@ -1,12 +1,12 @@ name:                snap-testing-version:             0.4.1.0+version:             0.4.1.1 synopsis:            A library for BDD-style testing with the Snap Web Framework homepage:            https://github.com/dbp/snap-testing license:             BSD3 license-file:        LICENSE author:              Daniel Patterson maintainer:          dbp@dbpmail.net--- copyright:+extra-source-files: CHANGELOG category:            Web, Snap build-type:          Simple cabal-version:       >=1.8
src/Snap/Test/BDD.hs view
@@ -229,16 +229,16 @@ assert :: Bool -> SnapTesting b () assert b = equals b (return True) --- | A data type for tests against forms-data FormExpectations a = Value a           -- ^ the value the form should take (and should be valid)-                        | ErrorPaths [Text] -- ^ the error paths that should be populated+-- | A data type for tests against forms.+data FormExpectations a = Value a           -- ^ The value the form should take (and should be valid)+                        | ErrorPaths [Text] -- ^ The error paths that should be populated --- | Test against digestive-functors forms+-- | Test against digestive-functors forms. form :: (Eq a, Show a)      => FormExpectations a           -- ^ If the form should succeed, Value a is what it should produce.                                      --   If failing, ErrorPaths should be all the errors that are triggered.      -> DF.Form Text (Handler b b) a -- ^ The form to run-     -> (Map Text Text)              -- ^ The parameters to pass+     -> Map Text Text                -- ^ The parameters to pass      -> SnapTesting b () form expected theForm theParams =   do r <- eval $ DF.postForm "form" theForm (const $ return lookupParam)@@ -247,7 +247,7 @@        ErrorPaths expectedPaths ->          do let viewErrorPaths = map (DF.fromPath . fst) $ DF.viewErrors $ fst r             assert (all (`elem` viewErrorPaths) expectedPaths-                    && ((length viewErrorPaths) == (length expectedPaths)))+                    && (length viewErrorPaths == length expectedPaths))   where lookupParam pth = case M.lookup (DF.fromPath pth) fixedParams of                             Nothing -> return []                             Just v -> return [DF.TextInput v]