Merge pull request #4 from zerobuzz/test-case-for-servant-issue-3

This test case reproduces servant issue #3.
This commit is contained in:
Julian Arni 2015-01-03 00:51:18 +01:00
commit 1e6fbd111d

View File

@ -189,19 +189,26 @@ queryParamSpec = do
name = "ALICE"
}
type PostApi = ReqBody Person :> Post Integer
type PostApi =
ReqBody Person :> Post Integer
:<|> "bla" :> ReqBody Person :> Post Integer
postApi :: Proxy PostApi
postApi = Proxy
postSpec :: Spec
postSpec = do
describe "Servant.API.Post and .ReqBody" $ do
with (return (serve postApi (return . age))) $ do
with (return (serve postApi (return . age :<|> return . age))) $ do
it "allows to POST a Person" $ do
post "/" (encode alice) `shouldRespondWith` "42"{
matchStatus = 201
}
it "allows alternative routes if all have request bodies" $ do
post "/bla" (encode alice) `shouldRespondWith` "42"{
matchStatus = 201
}
it "correctly rejects invalid request bodies with status 400" $ do
post "/" "some invalid body" `shouldRespondWith` 400