1
私は1つのテストがサインインして、次のテストで最初のサインインテストからのクッキーセットを使用するテストを作成しようとしています。Yesod.Testのydescribeはどのように使用されていますか?
私が見ることができるものから、これはydescribe
Start describing a Tests suite keeping cookies and a reference to the tested Application and ConnectionPool
で行われ、私はgithubのレポからいくつかの例を見て、私のアプリでこれを使用しようとしましたが、運がなかったです。
はここに私のコードです:コンパイルされたとき
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を使用する正しい方法でしょうか?
私は、あなたが 'spec'値に対して間違った署名をしていると思います。動作例については、yesod scaffolding( 'new foo yesod-simple'をスタック)をチェックしてください。 –