Skip to content

Commit

Permalink
Add responseBodyShouldNotContain function
Browse files Browse the repository at this point in the history
  • Loading branch information
amitaibu committed Jun 27, 2023
1 parent 4167600 commit ced2fd6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion IHP/Test/Mocking.hs
Expand Up @@ -173,12 +173,19 @@ responseBody res =
f (\chunk -> modifyIORef' content (<> chunk)) (return ())
toLazyByteString <$> readIORef content


-- | Asserts that the response body contains the given text.
responseBodyShouldContain :: Response -> Text -> IO ()
responseBodyShouldContain response includedText = do
body :: Text <- cs <$> responseBody response
body `shouldSatisfy` (includedText `Text.isInfixOf`)

-- | Asserts that the response body does not contain the given text.
responseBodyShouldNotContain :: Response -> Text -> IO ()
responseBodyShouldNotContain response includedText = do
body :: Text <- cs <$> responseBody response
body `shouldNotSatisfy` (includedText `Text.isInfixOf`)

-- | Asserts that the response status is equal to the given status.
responseStatusShouldBe :: Response -> HTTP.Status -> IO ()
responseStatusShouldBe response status = responseStatus response `shouldBe` status

Expand Down

0 comments on commit ced2fd6

Please sign in to comment.