Created
July 12, 2013 00:14
-
-
Save k-bx/5980396 to your computer and use it in GitHub Desktop.
HSpec add set-up method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Test.Hspec (Spec, hspec) | |
import Test.Hspec.Core (SpecTree (..), fromSpecList, runSpecM) | |
addSetUp :: IO () -> Spec -> Spec | |
addSetUp action spec = fromSpecList $ (map addActionToSpecItem (runSpecM spec)) | |
where addActionToSpecItem :: SpecTree -> SpecTree | |
addActionToSpecItem (SpecGroup s l) = SpecGroup s (map addActionToSpecItem l) | |
addActionToSpecItem (SpecItem s f) = SpecItem s (\params -> (action >> (f params))) | |
printStuff :: IO () | |
printStuff = do | |
putStrLn ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" | |
main :: IO () | |
main = do | |
conf <- Yesod.Default.Config.loadConfig $ (configSettings Testing) | |
{ csParseExtra = parseExtra | |
} | |
foundation <- makeFoundation conf | |
hspec $ (addSetUp printStuff) $ do | |
yesodSpec foundation $ do | |
homeSpecs | |
entriesSpecs | |
modelSpecs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment