diff --git a/yesod-test/ChangeLog.md b/yesod-test/ChangeLog.md index 60c48f5f..00bc9d94 100644 --- a/yesod-test/ChangeLog.md +++ b/yesod-test/ChangeLog.md @@ -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 diff --git a/yesod-test/Yesod/Test.hs b/yesod-test/Yesod/Test.hs index 9b4d28af..6a7e1b46 100644 --- a/yesod-test/Yesod/Test.hs +++ b/yesod-test/Yesod/Test.hs @@ -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 + ($ ()) diff --git a/yesod-test/yesod-test.cabal b/yesod-test/yesod-test.cabal index 55dda076..72586eaa 100644 --- a/yesod-test/yesod-test.cabal +++ b/yesod-test/yesod-test.cabal @@ -1,5 +1,5 @@ name: yesod-test -version: 1.4.1.1 +version: 1.4.2 license: MIT license-file: LICENSE author: Nubis