configurable middleware
This commit is contained in:
parent
b5077abdd9
commit
b92ae3093a
@ -33,6 +33,9 @@ module Yesod.Test
|
|||||||
, yesodSpecApp
|
, yesodSpecApp
|
||||||
, YesodExample
|
, YesodExample
|
||||||
, YesodExampleData(..)
|
, YesodExampleData(..)
|
||||||
|
, TestApp
|
||||||
|
, YSpec
|
||||||
|
, testApp
|
||||||
, YesodSpecTree (..)
|
, YesodSpecTree (..)
|
||||||
, ydescribe
|
, ydescribe
|
||||||
, yit
|
, yit
|
||||||
@ -538,7 +541,7 @@ byLabel label value = do
|
|||||||
--
|
--
|
||||||
-- You can set this parameter like so:
|
-- You can set this parameter like so:
|
||||||
--
|
--
|
||||||
-- > request $ do
|
-- > request $ do
|
||||||
-- > fileByLabel "Please submit an image" "static/img/picture.png" "img/png"
|
-- > fileByLabel "Please submit an image" "static/img/picture.png" "img/png"
|
||||||
--
|
--
|
||||||
-- This function also supports the implicit label syntax, in which
|
-- This function also supports the implicit label syntax, in which
|
||||||
@ -850,15 +853,20 @@ request reqBuilder = do
|
|||||||
failure :: (MonadIO a) => T.Text -> a b
|
failure :: (MonadIO a) => T.Text -> a b
|
||||||
failure reason = (liftIO $ HUnit.assertFailure $ T.unpack reason) >> error ""
|
failure reason = (liftIO $ HUnit.assertFailure $ T.unpack reason) >> error ""
|
||||||
|
|
||||||
|
type TestApp site = (site, Middleware)
|
||||||
|
testApp :: site -> Middleware -> TestApp site
|
||||||
|
testApp site middleware = (site, middleware)
|
||||||
|
type YSpec site = Hspec.SpecWith (TestApp site)
|
||||||
|
|
||||||
instance YesodDispatch site => Hspec.Example (ST.StateT (YesodExampleData site) IO a) where
|
instance YesodDispatch site => Hspec.Example (ST.StateT (YesodExampleData site) IO a) where
|
||||||
type Arg (ST.StateT (YesodExampleData site) IO a) = site
|
type Arg (ST.StateT (YesodExampleData site) IO a) = TestApp site
|
||||||
|
|
||||||
evaluateExample example params action =
|
evaluateExample example params action =
|
||||||
Hspec.evaluateExample
|
Hspec.evaluateExample
|
||||||
(action $ \site -> do
|
(action $ \(site, middleware) -> do
|
||||||
app <- toWaiAppPlain site
|
app <- toWaiAppPlain site
|
||||||
_ <- ST.evalStateT example YesodExampleData
|
_ <- ST.evalStateT example YesodExampleData
|
||||||
{ yedApp = app
|
{ yedApp = middleware app
|
||||||
, yedSite = site
|
, yedSite = site
|
||||||
, yedCookies = M.empty
|
, yedCookies = M.empty
|
||||||
, yedResponse = Nothing
|
, yedResponse = Nothing
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user