1

私は現在のテスト フィクスチャを強化するために、(タイプのApp) ファンデーション以上のものを hspec テスト ケースに渡しています。IO (App, Text)以下の例では、直接返すのではなく、追加の Text 値をタプル内に (as として) 渡しています。IO App

beforeOp :: IO (App, Text)
beforeOp = do
  settings <- loadAppSettings
    ["config/test-settings.yml", "config/settings.yml"]
    []
    ignoreEnv
  foundation <- makeFoundation settings
  wipeDB foundation
  setUpFixtures foundation
  return (foundation, "foo")

innerSpec :: SpecWith (App, Text)
innerSpec = do
  describe "stuff" $ do
    it "should work" $ do
      post MyRouteR
      statusIs 403

spec :: Spec
spec = before beforeOp innerSpec

などのinnerSpec関数を使用して通常の Yesod テストを実行できるように正しく構造化する方法がわかりませんが、これらの仕様で値を読み取って使用できるようにすることもできません。poststatusIsText

Yesod がなくても、次のようなことができます。

innerSpec :: SpecWith (Int, Int)
innerSpec = do
  describe "stuff" $ do
    it "should work" $ \(x, y) -> do
      x `shouldBe` y

それは問題なくビルドされますが、Yesod がミックスに入るとすぐに型を正しく取得できません。アドバイス?

4

0 に答える 0