| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Test.Hspec.Wai.JSON
Synopsis
- json :: QuasiQuoter
- class FromValue a where
Documentation
The examples in this module assume that you have the QuasiQuotes language
extension enabled and that Data.ByteString.Lazy.Char8 is imported
qualified as L:
>>>:set -XQuasiQuotes>>>import Data.ByteString.Lazy.Char8 as L
json :: QuasiQuoter Source #
A QuasiQuoter for constructing JSON values.
The constructed value is polymorph and unifies to instances of FromValue.
When used as a ResponseMatcher it matches a response with
- a status code of
200 - a
Content-Typeheader with valueapplication/json - the specified JSON as response body
When used as a ByteString it creates a ByteString from the specified JSON
that can be used as a request body for e.g. POST and PUT requests.
Example:
>>>L.putStrLn [json|[23, {foo: 42}]|][23,{"foo":42}]
class FromValue a where Source #
Instances
| FromValue ByteString Source # | |
Defined in Test.Hspec.Wai.JSON Methods fromValue :: Value -> ByteString Source # | |
| FromValue ResponseMatcher Source # | |
Defined in Test.Hspec.Wai.JSON Methods fromValue :: Value -> ResponseMatcher Source # | |