Updated according to review

This commit is contained in:
Tom Sydney Kerckhove 2018-04-26 11:00:48 +02:00
parent a8f5418b22
commit 0aa1765b6c
3 changed files with 15 additions and 18 deletions

View File

@ -1,3 +1,7 @@
## 1.6.4
Add yesodSpecWithSiteGeneratorAndArgument
[#1485](https://github.com/yesodweb/yesod/pull/1485)
## 1.6.3
Add performMethod
[#1502](https://github.com/yesodweb/yesod/pull/1502)

View File

@ -34,7 +34,7 @@ module Yesod.Test
yesodSpec
, YesodSpec
, yesodSpecWithSiteGenerator
, yesodSpecWithSiteGenerator'
, yesodSpecWithSiteGeneratorAndArgument
, yesodSpecApp
, YesodExample
, YesodExampleData(..)
@ -275,32 +275,25 @@ yesodSpecWithSiteGenerator :: YesodDispatch site
=> IO site
-> YesodSpec site
-> Hspec.Spec
yesodSpecWithSiteGenerator getSiteAction yspecs =
Hspec.fromSpecList $ map (unYesod getSiteAction) $ execWriter yspecs
where
unYesod getSiteAction' (YesodSpecGroup x y) = Hspec.specGroup x $ map (unYesod getSiteAction') y
unYesod getSiteAction' (YesodSpecItem x y) = Hspec.specItem x $ do
site <- getSiteAction'
app <- toWaiAppPlain site
evalSIO y YesodExampleData
{ yedApp = app
, yedSite = site
, yedCookies = M.empty
, yedResponse = Nothing
}
yesodSpecWithSiteGenerator getSiteAction =
yesodSpecWithSiteGeneratorAndArgument (const getSiteAction)
yesodSpecWithSiteGenerator' :: YesodDispatch site
-- | Same as yesodSpecWithSiteGenerator, but also takes an argument to build the site
-- and makes that argument available to the tests.
--
-- @since 1.6.4
yesodSpecWithSiteGeneratorAndArgument :: YesodDispatch site
=> (a -> IO site)
-> YesodSpec site
-> Hspec.SpecWith a
yesodSpecWithSiteGenerator' getSiteAction yspecs =
yesodSpecWithSiteGeneratorAndArgument getSiteAction yspecs =
Hspec.fromSpecList $ map (unYesod getSiteAction) $ execWriter yspecs
where
unYesod getSiteAction' (YesodSpecGroup x y) = Hspec.specGroup x $ map (unYesod getSiteAction') y
unYesod getSiteAction' (YesodSpecItem x y) = Hspec.specItem x $ \a -> do
site <- getSiteAction' a
app <- toWaiAppPlain site
ST.evalStateT y YesodExampleData
evalSIO y YesodExampleData
{ yedApp = app
, yedSite = site
, yedCookies = M.empty

View File

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