Merge pull request #1485 from NorfairKing/with-generator

yesodSpecWithSiteGenerator with an argument
This commit is contained in:
Michael Snoyman 2018-04-30 17:03:13 +03:00 committed by GitHub
commit 4cd29ae298
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 4 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,6 +34,7 @@ module Yesod.Test
yesodSpec
, YesodSpec
, yesodSpecWithSiteGenerator
, yesodSpecWithSiteGeneratorAndArgument
, yesodSpecApp
, YesodExample
, YesodExampleData(..)
@ -274,12 +275,23 @@ yesodSpecWithSiteGenerator :: YesodDispatch site
=> IO site
-> YesodSpec site
-> Hspec.Spec
yesodSpecWithSiteGenerator getSiteAction yspecs =
yesodSpecWithSiteGenerator getSiteAction =
yesodSpecWithSiteGeneratorAndArgument (const getSiteAction)
-- | 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
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 $ do
site <- getSiteAction'
unYesod getSiteAction' (YesodSpecItem x y) = Hspec.specItem x $ \a -> do
site <- getSiteAction' a
app <- toWaiAppPlain site
evalSIO y YesodExampleData
{ yedApp = app

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>