我正在尝试通过将基础(类型App
)传递给hspec测试用例来增强我当前的测试装置。在下面的示例中,我在元组内部传递了一个额外的Text值(如IO (App, Text)
),而不是直接返回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
,我可以使用post
,statusIs
等功能进行正常的Yesod测试,但也有Text
值可供这些规格用于阅读。
如果没有Yesod,我可以按照以下方式做点什么:
innerSpec :: SpecWith (Int, Int)
innerSpec = do
describe "stuff" $ do
it "should work" $ \(x, y) -> do
x `shouldBe` y
它会很好地构建,但是只要Yesod进入组合,我就无法完全确定类型。建议?