Merge pull request #1502 from pythonissam/general-request-method
add performMethod
This commit is contained in:
commit
cf1073d760
@ -1,3 +1,7 @@
|
|||||||
|
## 1.6.3
|
||||||
|
Add performMethod
|
||||||
|
[#1502](https://github.com/yesodweb/yesod/pull/1502)
|
||||||
|
|
||||||
## 1.6.2
|
## 1.6.2
|
||||||
|
|
||||||
* Add byLabel-related functions like byLabelContain
|
* Add byLabel-related functions like byLabelContain
|
||||||
|
|||||||
@ -54,6 +54,7 @@ module Yesod.Test
|
|||||||
, get
|
, get
|
||||||
, post
|
, post
|
||||||
, postBody
|
, postBody
|
||||||
|
, performMethod
|
||||||
, followRedirect
|
, followRedirect
|
||||||
, getLocation
|
, getLocation
|
||||||
, request
|
, request
|
||||||
@ -894,9 +895,7 @@ getRequestCookies = do
|
|||||||
post :: (Yesod site, RedirectUrl site url)
|
post :: (Yesod site, RedirectUrl site url)
|
||||||
=> url
|
=> url
|
||||||
-> YesodExample site ()
|
-> YesodExample site ()
|
||||||
post url = request $ do
|
post = performMethod "POST"
|
||||||
setMethod "POST"
|
|
||||||
setUrl url
|
|
||||||
|
|
||||||
-- | Perform a POST request to @url@ with the given body.
|
-- | 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)
|
get :: (Yesod site, RedirectUrl site url)
|
||||||
=> url
|
=> url
|
||||||
-> YesodExample site ()
|
-> YesodExample site ()
|
||||||
get url = request $ do
|
get = performMethod "GET"
|
||||||
setMethod "GET"
|
|
||||||
setUrl url
|
-- | 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.
|
-- | Follow a redirect, if the last response was a redirect.
|
||||||
-- (We consider a request a redirect if the status is
|
-- (We consider a request a redirect if the status is
|
||||||
|
|||||||
@ -124,6 +124,9 @@ main = hspec $ do
|
|||||||
yit "tests1b" $ do
|
yit "tests1b" $ do
|
||||||
get ("/foo" :: Text)
|
get ("/foo" :: Text)
|
||||||
statusIs 404
|
statusIs 404
|
||||||
|
yit "tests1c" $ do
|
||||||
|
performMethod "DELETE" ("/" :: Text)
|
||||||
|
statusIs 200
|
||||||
ydescribe "tests2" $ do
|
ydescribe "tests2" $ do
|
||||||
yit "type-safe URLs" $ do
|
yit "type-safe URLs" $ do
|
||||||
get $ LiteAppRoute []
|
get $ LiteAppRoute []
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-test
|
name: yesod-test
|
||||||
version: 1.6.2
|
version: 1.6.3
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Nubis <nubis@woobiz.com.ar>
|
author: Nubis <nubis@woobiz.com.ar>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user