add performMethod
This commit is contained in:
parent
06e0ffb48b
commit
a7d42846b5
@ -54,6 +54,7 @@ module Yesod.Test
|
|||||||
, get
|
, get
|
||||||
, post
|
, post
|
||||||
, postBody
|
, postBody
|
||||||
|
, performMethod
|
||||||
, followRedirect
|
, followRedirect
|
||||||
, getLocation
|
, getLocation
|
||||||
, request
|
, request
|
||||||
@ -929,6 +930,21 @@ get url = request $ do
|
|||||||
setMethod "GET"
|
setMethod "GET"
|
||||||
setUrl url
|
setUrl url
|
||||||
|
|
||||||
|
-- | Perform a request using a given method to @url@.
|
||||||
|
--
|
||||||
|
-- @since 1.6.3
|
||||||
|
--
|
||||||
|
-- ==== __Examples__
|
||||||
|
--
|
||||||
|
-- > performMethod "GET" 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
|
||||||
-- 301, 302, 303, 307 or 308, and the Location header is set.)
|
-- 301, 302, 303, 307 or 308, and the Location header is set.)
|
||||||
|
|||||||
@ -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