You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry that I am pretty new to hspec-wai and couldn't find the answer to this problem. Therefore I posted a question here.
I have a POST test case as follows:
it "post /users sample user responds with success msg" $
post "/users" postBody `shouldRespondWith` "wai"
where postBody = [json|{"name":"wai"}|]
It returns status_code 415, media-type not supported. I tried other ways such as: post "/users" "" `shouldRespondWith` "wai" although this will fail, I expect it will return error message like 400, not enough input. But still, it return 415
Alternatively
But still returns 415.
In hspec-wai/Wai.hs, I found the post function is post path = request methodPost path [], the headers is an empty list.
Therefore I changed the test case by using request directly
Sorry that I am pretty new to hspec-wai and couldn't find the answer to this problem. Therefore I posted a question here.
I have a POST test case as follows:
It returns status_code
415
, media-type not supported. I tried other ways such as:post "/users" "" `shouldRespondWith` "wai"
although this will fail, I expect it will return error message like400
, not enough input. But still, it return415
Alternatively
But still returns
415
.In
hspec-wai/Wai.hs
, I found thepost
function ispost path = request methodPost path []
, the headers is an empty list.Therefore I changed the test case by using
request
directlyIt works. It seems the
post
func that passes empty headers doesn't work. I need to specify the content-type in the headers. Did I do something wrong?The text was updated successfully, but these errors were encountered: