yesodSpecWithSiteGenerator with an argument
This commit is contained in:
parent
b92b2a0871
commit
a8f5418b22
@ -34,6 +34,7 @@ module Yesod.Test
|
||||
yesodSpec
|
||||
, YesodSpec
|
||||
, yesodSpecWithSiteGenerator
|
||||
, yesodSpecWithSiteGenerator'
|
||||
, yesodSpecApp
|
||||
, YesodExample
|
||||
, YesodExampleData(..)
|
||||
@ -288,6 +289,24 @@ yesodSpecWithSiteGenerator getSiteAction yspecs =
|
||||
, yedResponse = Nothing
|
||||
}
|
||||
|
||||
yesodSpecWithSiteGenerator' :: YesodDispatch site
|
||||
=> (a -> IO site)
|
||||
-> YesodSpec site
|
||||
-> Hspec.SpecWith a
|
||||
yesodSpecWithSiteGenerator' getSiteAction yspecs =
|
||||
Hspec.fromSpecList $ map (unYesod getSiteAction) $ execWriter yspecs
|
||||
where
|
||||
unYesod getSiteAction' (YesodSpecGroup x y) = Hspec.specGroup x $ map (unYesod getSiteAction') y
|
||||
unYesod getSiteAction' (YesodSpecItem x y) = Hspec.specItem x $ \a -> do
|
||||
site <- getSiteAction' a
|
||||
app <- toWaiAppPlain site
|
||||
ST.evalStateT y YesodExampleData
|
||||
{ yedApp = app
|
||||
, yedSite = site
|
||||
, yedCookies = M.empty
|
||||
, 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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user