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
|
||||
|
||||
* Add byLabel-related functions like byLabelContain
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 []
|
||||
|
||||
@ -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>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user