Provide Example instance for YesodExample

This commit is contained in:
Michael Snoyman 2014-11-20 02:14:06 +02:00
parent 79db398a54
commit 7fcddb6ee3
3 changed files with 27 additions and 2 deletions

View File

@ -1 +1,7 @@
__1.4.1.1__ Upgrade to hspec 2
## 1.4.2
Provide `Example` instance for `YesodExample`.
## 1.4.1.1
Upgrade to hspec 2

View File

@ -2,6 +2,8 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-|
Yesod.Test is a pragmatic framework for testing web applications built
using wai and persistent.
@ -695,3 +697,20 @@ request reqBuilder = do
-- Yes, just a shortcut
failure :: (MonadIO a) => T.Text -> a b
failure reason = (liftIO $ HUnit.assertFailure $ T.unpack reason) >> error ""
instance YesodDispatch site => Hspec.Example (ST.StateT (YesodExampleData site) IO a) where
type Arg (ST.StateT (YesodExampleData site) IO a) = site
evaluateExample example params action =
Hspec.evaluateExample
(action $ \site -> do
app <- toWaiAppPlain site
_ <- ST.evalStateT example YesodExampleData
{ yedApp = app
, yedSite = site
, yedCookies = M.empty
, yedResponse = Nothing
}
return ())
params
($ ())

View File

@ -1,5 +1,5 @@
name: yesod-test
version: 1.4.1.1
version: 1.4.2
license: MIT
license-file: LICENSE
author: Nubis <nubis@woobiz.com.ar>