Forward compatibility with Hspec 2.0

This commit is contained in:
Simon Hengel 2014-11-09 19:55:51 +08:00
parent 87e06494ea
commit b6c894061e
2 changed files with 11 additions and 13 deletions

View File

@ -96,7 +96,7 @@ module Yesod.Test
) where ) where
import qualified Test.Hspec as Hspec import qualified Test.Hspec as Hspec
import qualified Test.Hspec.Core as Core import qualified Test.Hspec.Core as Hspec
import qualified Data.List as DL import qualified Data.List as DL
import qualified Data.ByteString.Char8 as BS8 import qualified Data.ByteString.Char8 as BS8
import Data.ByteString (ByteString) import Data.ByteString (ByteString)
@ -202,10 +202,10 @@ yesodSpec :: YesodDispatch site
-> YesodSpec site -> YesodSpec site
-> Hspec.Spec -> Hspec.Spec
yesodSpec site yspecs = yesodSpec site yspecs =
Core.fromSpecList $ map unYesod $ execWriter yspecs Hspec.fromSpecList $ map unYesod $ execWriter yspecs
where where
unYesod (YesodSpecGroup x y) = Core.SpecGroup x $ map unYesod y unYesod (YesodSpecGroup x y) = Hspec.specGroup x $ map unYesod y
unYesod (YesodSpecItem x y) = Core.it x $ do unYesod (YesodSpecItem x y) = Hspec.specItem x $ do
app <- toWaiAppPlain site app <- toWaiAppPlain site
ST.evalStateT y YesodExampleData ST.evalStateT y YesodExampleData
{ yedApp = app { yedApp = app
@ -221,12 +221,10 @@ yesodSpecWithSiteGenerator :: YesodDispatch site
-> YesodSpec site -> YesodSpec site
-> Hspec.Spec -> Hspec.Spec
yesodSpecWithSiteGenerator getSiteAction yspecs = yesodSpecWithSiteGenerator getSiteAction yspecs =
Core.fromSpecList $ map (unYesod getSiteAction) $ execWriter yspecs Hspec.fromSpecList $ map (unYesod getSiteAction) $ execWriter yspecs
where where
unYesod :: YesodDispatch t unYesod getSiteAction' (YesodSpecGroup x y) = Hspec.specGroup x $ map (unYesod getSiteAction') y
=> IO t -> YesodSpecTree t -> Core.SpecTree unYesod getSiteAction' (YesodSpecItem x y) = Hspec.specItem x $ do
unYesod getSiteAction' (YesodSpecGroup x y) = Core.SpecGroup x $ map (unYesod getSiteAction') y
unYesod getSiteAction' (YesodSpecItem x y) = Core.it x $ do
site <- getSiteAction' site <- getSiteAction'
app <- toWaiAppPlain site app <- toWaiAppPlain site
ST.evalStateT y YesodExampleData ST.evalStateT y YesodExampleData
@ -245,10 +243,10 @@ yesodSpecApp :: YesodDispatch site
-> YesodSpec site -> YesodSpec site
-> Hspec.Spec -> Hspec.Spec
yesodSpecApp site getApp yspecs = yesodSpecApp site getApp yspecs =
Core.fromSpecList $ map unYesod $ execWriter yspecs Hspec.fromSpecList $ map unYesod $ execWriter yspecs
where where
unYesod (YesodSpecGroup x y) = Core.SpecGroup x $ map unYesod y unYesod (YesodSpecGroup x y) = Hspec.specGroup x $ map unYesod y
unYesod (YesodSpecItem x y) = Core.it x $ do unYesod (YesodSpecItem x y) = Hspec.specItem x $ do
app <- getApp app <- getApp
ST.evalStateT y YesodExampleData ST.evalStateT y YesodExampleData
{ yedApp = app { yedApp = app

View File

@ -23,7 +23,7 @@ library
, network >= 2.2 , network >= 2.2
, http-types >= 0.7 , http-types >= 0.7
, HUnit >= 1.2 , HUnit >= 1.2
, hspec >= 1.4 , hspec >= 1.12.4
, bytestring >= 0.9 , bytestring >= 0.9
, case-insensitive >= 0.2 , case-insensitive >= 0.2
, text , text