Merge branch 'add-pretty-assert' of https://github.com/bitemyapp/yesod
This commit is contained in:
commit
f4b4602500
@ -4,6 +4,7 @@
|
|||||||
{-# LANGUAGE RecordWildCards #-}
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
{-# LANGUAGE TypeFamilies #-}
|
{-# LANGUAGE TypeFamilies #-}
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
Yesod.Test is a pragmatic framework for testing web applications built
|
Yesod.Test is a pragmatic framework for testing web applications built
|
||||||
using wai and persistent.
|
using wai and persistent.
|
||||||
@ -84,6 +85,9 @@ module Yesod.Test
|
|||||||
|
|
||||||
-- * Assertions
|
-- * Assertions
|
||||||
, assertEqual
|
, assertEqual
|
||||||
|
, assertEqualNoShow
|
||||||
|
, assertEq
|
||||||
|
|
||||||
, assertHeader
|
, assertHeader
|
||||||
, assertNoHeader
|
, assertNoHeader
|
||||||
, statusIs
|
, statusIs
|
||||||
@ -139,6 +143,7 @@ import qualified Web.Cookie as Cookie
|
|||||||
import qualified Blaze.ByteString.Builder as Builder
|
import qualified Blaze.ByteString.Builder as Builder
|
||||||
import Data.Time.Clock (getCurrentTime)
|
import Data.Time.Clock (getCurrentTime)
|
||||||
import Control.Applicative ((<$>))
|
import Control.Applicative ((<$>))
|
||||||
|
import Text.Show.Pretty (ppShow)
|
||||||
|
|
||||||
-- | The state used in a single test case defined using 'yit'
|
-- | The state used in a single test case defined using 'yit'
|
||||||
--
|
--
|
||||||
@ -314,9 +319,20 @@ htmlQuery' getter errTrace query = withResponse' getter ("Tried to invoke htmlQu
|
|||||||
htmlQuery :: Query -> YesodExample site [HtmlLBS]
|
htmlQuery :: Query -> YesodExample site [HtmlLBS]
|
||||||
htmlQuery = htmlQuery' yedResponse []
|
htmlQuery = htmlQuery' yedResponse []
|
||||||
|
|
||||||
-- | Asserts that the two given values are equal.
|
assertEq :: (Eq a, Show a) => String -> a -> a -> YesodExample site ()
|
||||||
|
assertEq m a b =
|
||||||
|
liftIO $ HUnit.assertBool msg (a == b)
|
||||||
|
where msg = "Assertion: " ++ m ++ "\n" ++
|
||||||
|
"First argument: " ++ ppShow a ++ "\n" ++
|
||||||
|
"Second argument: " ++ ppShow b ++ "\n"
|
||||||
|
|
||||||
|
{-# DEPRECATED assertEqual "Use assertEq instead" #-}
|
||||||
assertEqual :: (Eq a) => String -> a -> a -> YesodExample site ()
|
assertEqual :: (Eq a) => String -> a -> a -> YesodExample site ()
|
||||||
assertEqual msg a b = liftIO $ HUnit.assertBool msg (a == b)
|
assertEqual = assertEqualNoShow
|
||||||
|
|
||||||
|
-- | Asserts that the two given values are equal.
|
||||||
|
assertEqualNoShow :: (Eq a) => String -> a -> a -> YesodExample site ()
|
||||||
|
assertEqualNoShow msg a b = liftIO $ HUnit.assertBool msg (a == b)
|
||||||
|
|
||||||
-- | Assert the last response status is as expected.
|
-- | Assert the last response status is as expected.
|
||||||
statusIs :: Int -> YesodExample site ()
|
statusIs :: Int -> YesodExample site ()
|
||||||
|
|||||||
@ -14,29 +14,30 @@ description: API docs and the README are available at <http://www.stackage.o
|
|||||||
extra-source-files: README.md, LICENSE, test/main.hs, ChangeLog.md
|
extra-source-files: README.md, LICENSE, test/main.hs, ChangeLog.md
|
||||||
|
|
||||||
library
|
library
|
||||||
build-depends: base >= 4.3 && < 5
|
build-depends: HUnit >= 1.2
|
||||||
, attoparsec >= 0.10
|
, attoparsec >= 0.10
|
||||||
|
, base >= 4.3 && < 5
|
||||||
|
, blaze-builder
|
||||||
|
, blaze-html >= 0.5
|
||||||
|
, blaze-markup >= 0.5.1
|
||||||
|
, bytestring >= 0.9
|
||||||
|
, case-insensitive >= 0.2
|
||||||
|
, containers
|
||||||
|
, cookie
|
||||||
|
, hspec-core == 2.*
|
||||||
|
, html-conduit >= 0.1
|
||||||
|
, http-types >= 0.7
|
||||||
|
, monad-control
|
||||||
|
, network >= 2.2
|
||||||
, persistent >= 1.0
|
, persistent >= 1.0
|
||||||
|
, pretty-show >= 1.6
|
||||||
|
, text
|
||||||
|
, time
|
||||||
, transformers >= 0.2.2
|
, transformers >= 0.2.2
|
||||||
, wai >= 3.0
|
, wai >= 3.0
|
||||||
, wai-extra
|
, wai-extra
|
||||||
, network >= 2.2
|
|
||||||
, http-types >= 0.7
|
|
||||||
, HUnit >= 1.2
|
|
||||||
, hspec-core == 2.*
|
|
||||||
, bytestring >= 0.9
|
|
||||||
, case-insensitive >= 0.2
|
|
||||||
, text
|
|
||||||
, xml-conduit >= 1.0
|
, xml-conduit >= 1.0
|
||||||
, xml-types >= 0.3
|
, xml-types >= 0.3
|
||||||
, containers
|
|
||||||
, html-conduit >= 0.1
|
|
||||||
, blaze-html >= 0.5
|
|
||||||
, blaze-markup >= 0.5.1
|
|
||||||
, monad-control
|
|
||||||
, time
|
|
||||||
, blaze-builder
|
|
||||||
, cookie
|
|
||||||
, yesod-core >= 1.4.14
|
, yesod-core >= 1.4.14
|
||||||
|
|
||||||
exposed-modules: Yesod.Test
|
exposed-modules: Yesod.Test
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user