packages feed

yesod-test 0.3.4 → 0.3.5

raw patch · 2 files changed

+14/−2 lines, 2 files

Files

Yesod/Test.hs view
@@ -52,7 +52,7 @@    -- * Assertions   assertEqual, assertHeader, assertNoHeader, statusIs, bodyEquals, bodyContains,-  htmlAllContain, htmlCount,+  htmlAllContain, htmlAnyContain, htmlCount,    -- * Utils for debugging tests   printBody, printMatches,@@ -252,6 +252,18 @@     [] -> failure $ "Nothing matched css query: " <> query     _ -> liftIO $ HUnit.assertBool ("Not all "++T.unpack query++" contain "++search) $           DL.all (DL.isInfixOf search) (map (TL.unpack . decodeUtf8) matches)++-- | Queries the html using a css selector, and passes if any matched+-- element contains the given string.+--+-- Since 0.3.5+htmlAnyContain :: HoldsResponse a => Query -> String -> ST.StateT a IO ()+htmlAnyContain query search = do+  matches <- htmlQuery query+  case matches of+    [] -> failure $ "Nothing matched css query: " <> query+    _ -> liftIO $ HUnit.assertBool ("None of "++T.unpack query++" contain "++search) $+          DL.any (DL.isInfixOf search) (map (TL.unpack . decodeUtf8) matches)  -- | Performs a css query on the last response and asserts the matched elements -- are as many as expected.
yesod-test.cabal view
@@ -1,5 +1,5 @@ name:               yesod-test-version:            0.3.4+version:            0.3.5 license:            MIT license-file:       LICENSE author:             Nubis <nubis@woobiz.com.ar>