我正在尝试编写一个测试登录的测试,然后以下测试使用第一个登录测试中的 cookie 集。
据我所知,这是完成的ydescribe
开始描述一个保存 cookie 的测试套件以及对测试的 Application 和 ConnectionPool 的引用
我试图通过查看 github repos 中的一些示例在我的应用程序中使用它,但没有运气。
这是我的代码:
module Handler.PostSpec ( spec ) where
import TestImport hiding (postBody)
import Data.Aeson
import Yesod.Test
spec :: Spec
spec =
ydescribe "Auth" $ do
yit "logs in to dummy auth" $ do
request $ do
addPostParam "ident" "0"
setMethod "POST"
setUrl ("http://localhost:3000/auth/page/dummy" :: Text)
statusIs 303
编译时会出现错误:
test/Handler/PostSpec.hs:9:5: error:
• Couldn't match type ‘transformers-0.5.2.0:Control.Monad.Trans.Writer.Lazy.WriterT
[YesodSpecTree site0] Identity ()’
with ‘hspec-core-2.4.4:Test.Hspec.Core.Spec.Monad.SpecM () ()’
Expected type: Spec
Actual type: YesodSpec site0
• In the expression:
ydescribe "Auth"
$ do { yit "logs in to dummy auth"
$ do { request $ do { ... };
statusIs 303 } }
In an equation for ‘spec’:
spec
= ydescribe "Auth"
$ do { yit "logs in to dummy auth"
$ do { request $ ...;
.... } }
使用 ydescribe 的正确方法是什么?