From 21e0ef11bac768fd491822316921e5e731049665 Mon Sep 17 00:00:00 2001 From: Amitaibu Date: Thu, 1 Sep 2016 14:09:10 +0300 Subject: [PATCH] Add bodyNotContains function --- yesod-test/Yesod/Test.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/yesod-test/Yesod/Test.hs b/yesod-test/Yesod/Test.hs index 984d8eb0..fc1c3770 100644 --- a/yesod-test/Yesod/Test.hs +++ b/yesod-test/Yesod/Test.hs @@ -395,6 +395,13 @@ bodyContains text = withResponse $ \ res -> liftIO $ HUnit.assertBool ("Expected body to contain " ++ text) $ (simpleBody res) `contains` text +-- | Assert the last response doesn't have the given text. The check is performed using the response +-- body in full text form. +bodyNotContains :: String -> YesodExample site () +bodyNotContains text = withResponse $ \ res -> + liftIO $ HUnit.assertBool ("Expected body not to contain " ++ text) $ + not . contains (simpleBody res) text + contains :: BSL8.ByteString -> String -> Bool contains a b = DL.isInfixOf b (TL.unpack $ decodeUtf8 a)