add yesodSpecApp
This commit is contained in:
parent
00f8bcf59b
commit
e74709433b
@ -28,6 +28,7 @@ module Yesod.Test
|
||||
yesodSpec
|
||||
, YesodSpec
|
||||
, yesodSpecWithSiteGenerator
|
||||
, yesodSpecApp
|
||||
, YesodExample
|
||||
, YesodExampleData(..)
|
||||
, YesodSpecTree (..)
|
||||
@ -235,6 +236,27 @@ yesodSpecWithSiteGenerator getSiteAction yspecs =
|
||||
, yedResponse = Nothing
|
||||
}
|
||||
|
||||
-- | Same as yesodSpec, but instead of taking a site it
|
||||
-- takes an action which produces the 'Application' for each test.
|
||||
-- This lets you use your middleware from makeApplication
|
||||
yesodSpecApp :: YesodDispatch site
|
||||
=> site
|
||||
-> IO Application
|
||||
-> YesodSpec site
|
||||
-> Hspec.Spec
|
||||
yesodSpecApp site getApp yspecs =
|
||||
Core.fromSpecList $ map unYesod $ execWriter yspecs
|
||||
where
|
||||
unYesod (YesodSpecGroup x y) = Core.SpecGroup x $ map unYesod y
|
||||
unYesod (YesodSpecItem x y) = Core.it x $ do
|
||||
app <- getApp
|
||||
ST.evalStateT y YesodExampleData
|
||||
{ yedApp = app
|
||||
, yedSite = site
|
||||
, yedCookies = M.empty
|
||||
, yedResponse = Nothing
|
||||
}
|
||||
|
||||
-- | Describe a single test that keeps cookies, and a reference to the last response.
|
||||
yit :: String -> YesodExample site () -> YesodSpec site
|
||||
yit label example = tell [YesodSpecItem label example]
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: yesod-test
|
||||
version: 1.2.4
|
||||
version: 1.2.5
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
author: Nubis <nubis@woobiz.com.ar>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user