Merge pull request #1502 from pythonissam/general-request-method

add performMethod
This commit is contained in:
Michael Snoyman 2018-04-17 10:31:44 +03:00 committed by GitHub
commit cf1073d760
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 7 deletions

View File

@ -1,3 +1,7 @@
## 1.6.3
Add performMethod
[#1502](https://github.com/yesodweb/yesod/pull/1502)
## 1.6.2
* Add byLabel-related functions like byLabelContain

View File

@ -54,6 +54,7 @@ module Yesod.Test
, get
, post
, postBody
, performMethod
, followRedirect
, getLocation
, request
@ -894,9 +895,7 @@ getRequestCookies = do
post :: (Yesod site, RedirectUrl site url)
=> url
-> YesodExample site ()
post url = request $ do
setMethod "POST"
setUrl url
post = performMethod "POST"
-- | Perform a POST request to @url@ with the given body.
--
@ -925,9 +924,22 @@ postBody url body = request $ do
get :: (Yesod site, RedirectUrl site url)
=> url
-> YesodExample site ()
get url = request $ do
setMethod "GET"
setUrl url
get = performMethod "GET"
-- | Perform a request using a given method to @url@.
--
-- @since 1.6.3
--
-- ==== __Examples__
--
-- > performMethod "DELETE" HomeR
performMethod :: (Yesod site, RedirectUrl site url)
=> ByteString
-> url
-> YesodExample site ()
performMethod method url = request $ do
setMethod method
setUrl url
-- | Follow a redirect, if the last response was a redirect.
-- (We consider a request a redirect if the status is

View File

@ -124,6 +124,9 @@ main = hspec $ do
yit "tests1b" $ do
get ("/foo" :: Text)
statusIs 404
yit "tests1c" $ do
performMethod "DELETE" ("/" :: Text)
statusIs 200
ydescribe "tests2" $ do
yit "type-safe URLs" $ do
get $ LiteAppRoute []

View File

@ -1,5 +1,5 @@
name: yesod-test
version: 1.6.2
version: 1.6.3
license: MIT
license-file: LICENSE
author: Nubis <nubis@woobiz.com.ar>