packages feed

yesod-test 1.6.4 → 1.6.5

raw patch · 3 files changed

+16/−8 lines, 3 filesdep −blaze-markupdep −persistent

Dependencies removed: blaze-markup, persistent

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 1.6.5+bodyEquals prints out actual body in addition to expected body in failure msg+[#1525](https://github.com/yesodweb/yesod/pull/1525)+ ## 1.6.4 Add yesodSpecWithSiteGeneratorAndArgument [#1485](https://github.com/yesodweb/yesod/pull/1485)
Yesod/Test.hs view
@@ -138,6 +138,7 @@ import Data.ByteString (ByteString) import qualified Data.Text as T import qualified Data.Text.Encoding as TE+import qualified Data.Text.Encoding.Error as TErr import qualified Data.ByteString.Lazy.Char8 as BSL8 import qualified Test.HUnit as HUnit import qualified Network.HTTP.Types as H@@ -153,7 +154,7 @@ import Yesod.Test.TransversingCSS import Yesod.Core import qualified Data.Text.Lazy as TL-import Data.Text.Lazy.Encoding (encodeUtf8, decodeUtf8)+import Data.Text.Lazy.Encoding (encodeUtf8, decodeUtf8, decodeUtf8With) import Text.XML.Cursor hiding (element) import qualified Text.XML.Cursor as C import qualified Text.HTML.DOM as HD@@ -439,9 +440,14 @@ -- | Assert the last response is exactly equal to the given text. This is -- useful for testing API responses. bodyEquals :: HasCallStack => String -> YesodExample site ()-bodyEquals text = withResponse $ \ res ->-  liftIO $ HUnit.assertBool ("Expected body to equal " ++ text) $-    (simpleBody res) == encodeUtf8 (TL.pack text)+bodyEquals text = withResponse $ \ res -> do+  let actual = simpleBody res+      msg    = concat [ "Expected body to equal:\n\t"+                      , text ++ "\n"+                      , "Actual is:\n\t"+                      , TL.unpack $ decodeUtf8With TErr.lenientDecode actual+                      ]+  liftIO $ HUnit.assertBool msg $ actual == encodeUtf8 (TL.pack text)  -- | Assert the last response has the given text. The check is performed using the response -- body in full text form.
yesod-test.cabal view
@@ -1,5 +1,5 @@ name:               yesod-test-version:            1.6.4+version:            1.6.5 license:            MIT license-file:       LICENSE author:             Nubis <nubis@woobiz.com.ar>@@ -19,16 +19,15 @@                    , base                      >= 4.3      && < 5                    , blaze-builder                    , blaze-html                >= 0.5-                   , blaze-markup              >= 0.5.1                    , bytestring                >= 0.9                    , case-insensitive          >= 0.2+                   , conduit                    , containers                    , cookie                    , hspec-core                == 2.*                    , html-conduit              >= 0.1                    , http-types                >= 0.7                    , network                   >= 2.2-                   , persistent                >= 1.0                    , pretty-show               >= 1.6                    , semigroups                    , text@@ -39,7 +38,6 @@                    , xml-conduit               >= 1.0                    , xml-types                 >= 0.3                    , yesod-core                >= 1.6-                   , conduit      exposed-modules: Yesod.Test                      Yesod.Test.CssQuery