Merge branch 'test-middleware'
Conflicts: yesod-test/yesod-test.cabal
This commit is contained in:
commit
95e6084634
@ -33,6 +33,9 @@ module Yesod.Test
|
|||||||
, yesodSpecApp
|
, yesodSpecApp
|
||||||
, YesodExample
|
, YesodExample
|
||||||
, YesodExampleData(..)
|
, YesodExampleData(..)
|
||||||
|
, TestApp
|
||||||
|
, YSpec
|
||||||
|
, testApp
|
||||||
, YesodSpecTree (..)
|
, YesodSpecTree (..)
|
||||||
, ydescribe
|
, ydescribe
|
||||||
, yit
|
, yit
|
||||||
@ -905,15 +908,20 @@ parseSetCookies headers = map (Cookie.parseSetCookie . snd) $ DL.filter (("Set-C
|
|||||||
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
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-test
|
name: yesod-test
|
||||||
version: 1.4.4
|
version: 1.5
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Nubis <nubis@woobiz.com.ar>
|
author: Nubis <nubis@woobiz.com.ar>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user