Skip to content

Instantly share code, notes, and snippets.

@k-bx
Created July 12, 2013 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k-bx/5980396 to your computer and use it in GitHub Desktop.
Save k-bx/5980396 to your computer and use it in GitHub Desktop.
HSpec add set-up method
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