configurable middleware
This commit is contained in:
parent
b5077abdd9
commit
b92ae3093a
@ -33,6 +33,9 @@ module Yesod.Test
|
||||
, yesodSpecApp
|
||||
, YesodExample
|
||||
, YesodExampleData(..)
|
||||
, TestApp
|
||||
, YSpec
|
||||
, testApp
|
||||
, YesodSpecTree (..)
|
||||
, ydescribe
|
||||
, yit
|
||||
@ -538,7 +541,7 @@ byLabel label value = do
|
||||
--
|
||||
-- You can set this parameter like so:
|
||||
--
|
||||
-- > request $ do
|
||||
-- > request $ do
|
||||
-- > fileByLabel "Please submit an image" "static/img/picture.png" "img/png"
|
||||
--
|
||||
-- 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 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
|
||||
type Arg (ST.StateT (YesodExampleData site) IO a) = site
|
||||
type Arg (ST.StateT (YesodExampleData site) IO a) = TestApp site
|
||||
|
||||
evaluateExample example params action =
|
||||
Hspec.evaluateExample
|
||||
(action $ \site -> do
|
||||
(action $ \(site, middleware) -> do
|
||||
app <- toWaiAppPlain site
|
||||
_ <- ST.evalStateT example YesodExampleData
|
||||
{ yedApp = app
|
||||
{ yedApp = middleware app
|
||||
, yedSite = site
|
||||
, yedCookies = M.empty
|
||||
, yedResponse = Nothing
|
||||
|
||||
Loading…
Reference in New Issue
Block a user