Added assertEq, deprecated assertEqual
use assertEq instead
This commit is contained in:
parent
9ce2770813
commit
13d9f58db7
@ -4,6 +4,7 @@
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
|
||||
{-|
|
||||
Yesod.Test is a pragmatic framework for testing web applications built
|
||||
using wai and persistent.
|
||||
@ -84,6 +85,9 @@ module Yesod.Test
|
||||
|
||||
-- * Assertions
|
||||
, assertEqual
|
||||
, assertEqualNoShow
|
||||
, assertEq
|
||||
|
||||
, assertHeader
|
||||
, assertNoHeader
|
||||
, statusIs
|
||||
@ -139,6 +143,7 @@ import qualified Web.Cookie as Cookie
|
||||
import qualified Blaze.ByteString.Builder as Builder
|
||||
import Data.Time.Clock (getCurrentTime)
|
||||
import Control.Applicative ((<$>))
|
||||
import Text.Show.Pretty (ppShow)
|
||||
|
||||
-- | 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 = 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 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.
|
||||
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
|
||||
|
||||
library
|
||||
build-depends: base >= 4.3 && < 5
|
||||
build-depends: HUnit >= 1.2
|
||||
, 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
|
||||
, pretty-show >= 1.6
|
||||
, text
|
||||
, time
|
||||
, transformers >= 0.2.2
|
||||
, wai >= 3.0
|
||||
, 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-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
|
||||
|
||||
exposed-modules: Yesod.Test
|
||||
|
||||
Loading…
Reference in New Issue
Block a user