hspec-wai-0.0.0: Experimental Hspec support for testing WAI applications (depends on hspec2!)

Safe HaskellNone

Test.Hspec.Wai

Synopsis

Documentation

with :: IO a -> SpecWith a -> SpecSource

get :: ByteString -> WaiSession SResponseSource

| Performs GET request to running app.

post :: ByteString -> ByteString -> WaiSession SResponseSource

| Performs POST request to running app.

put :: ByteString -> ByteString -> WaiSession SResponseSource

| Performs PUT request to running app.

request :: Method -> ByteString -> ByteString -> WaiSession SResponseSource

| Performs request to running app, with HTTP Method, path and body.

shouldHaveHeader :: WaiSession SResponse -> Header -> WaiExpectationSource

Passes if the given Header exists in the response.

shouldRespondWith :: WaiSession SResponse -> ResponseMatcher -> WaiExpectationSource

Passs if

  • the given number matches with the HTTP Status code of the response. * the given string matches with the body of the response. * the given ResponseMatcher matches with the response.

Example:

 get "/foo" `shouldRespondWith` 200                         -- Pass
 get "/foo" `shouldRespondWith` "bar"                       -- Pass if the body is "bar"
 get "/foo" `shouldRespondWith` "bar" { matchStatus = 200 } -- Pass if the body is "bar" and status is 200