add a testcase to very that we reject invalid json bodies with HTTP status 400

This commit is contained in:
Alp Mestanogullari 2014-10-28 16:58:46 +01:00
parent 7ca6b26b78
commit 90ea56534b
2 changed files with 4 additions and 1 deletions

View file

@ -36,7 +36,7 @@ toApplication ra request respond = do
data RouteMismatch = data RouteMismatch =
NotFound -- ^ the usual "not found" error NotFound -- ^ the usual "not found" error
| WrongMethod -- ^ a more informative "you just got the HTTP method wrong" error | WrongMethod -- ^ a more informative "you just got the HTTP method wrong" error
| InvalidBody -- ^ an even more informative "you json request body wasn't valid" error | InvalidBody -- ^ an even more informative "your json request body wasn't valid" error
deriving (Eq, Show) deriving (Eq, Show)
-- | -- |

View file

@ -154,6 +154,9 @@ postSpec = do
matchStatus = 201 matchStatus = 201
} }
it "correctly rejects invalid request bodies with status 400" $ do
post "/" "some invalid body" `shouldRespondWith` 400
type RawApi = "foo" :> Raw type RawApi = "foo" :> Raw
rawApi :: Proxy RawApi rawApi :: Proxy RawApi