Merge pull request #1271 from amitaibu/bodyNotContains
Add bodyNotContains function
This commit is contained in:
commit
33fd9de0b1
@ -1,3 +1,7 @@
|
|||||||
|
## 1.5.3
|
||||||
|
|
||||||
|
* Added bodyNotContains [#1271](https://github.com/yesodweb/yesod/pull/1271)
|
||||||
|
|
||||||
## 1.5.2
|
## 1.5.2
|
||||||
|
|
||||||
* Added assertEq, deprecated assertEqual [#1259](https://github.com/yesodweb/yesod/pull/1259)
|
* Added assertEq, deprecated assertEqual [#1259](https://github.com/yesodweb/yesod/pull/1259)
|
||||||
@ -5,7 +9,7 @@
|
|||||||
## 1.5.1.1
|
## 1.5.1.1
|
||||||
|
|
||||||
* Fix `addToken_` needing a trailing space and allows multiples spaces in css selector.
|
* Fix `addToken_` needing a trailing space and allows multiples spaces in css selector.
|
||||||
|
|
||||||
## 1.5.1.0
|
## 1.5.1.0
|
||||||
|
|
||||||
* Better error provenance for stuff invoking withResponse' [#1191](https://github.com/yesodweb/yesod/pull/1191)
|
* Better error provenance for stuff invoking withResponse' [#1191](https://github.com/yesodweb/yesod/pull/1191)
|
||||||
|
|||||||
@ -93,6 +93,7 @@ module Yesod.Test
|
|||||||
, statusIs
|
, statusIs
|
||||||
, bodyEquals
|
, bodyEquals
|
||||||
, bodyContains
|
, bodyContains
|
||||||
|
, bodyNotContains
|
||||||
, htmlAllContain
|
, htmlAllContain
|
||||||
, htmlAnyContain
|
, htmlAnyContain
|
||||||
, htmlNoneContain
|
, htmlNoneContain
|
||||||
@ -395,6 +396,14 @@ bodyContains text = withResponse $ \ res ->
|
|||||||
liftIO $ HUnit.assertBool ("Expected body to contain " ++ text) $
|
liftIO $ HUnit.assertBool ("Expected body to contain " ++ text) $
|
||||||
(simpleBody res) `contains` 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.
|
||||||
|
-- @since 1.5.3
|
||||||
|
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 :: BSL8.ByteString -> String -> Bool
|
||||||
contains a b = DL.isInfixOf b (TL.unpack $ decodeUtf8 a)
|
contains a b = DL.isInfixOf b (TL.unpack $ decodeUtf8 a)
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-test
|
name: yesod-test
|
||||||
version: 1.5.2
|
version: 1.5.3
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Nubis <nubis@woobiz.com.ar>
|
author: Nubis <nubis@woobiz.com.ar>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user