Created
July 7, 2017 04:53
-
-
Save sleexyz/bac73af84c5b723e24bc37616b7665de to your computer and use it in GitHub Desktop.
hspec test isolation
This file contains hidden or 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
#!/usr/bin/env stack | |
-- stack --resolver lts-8.0 --install-ghc runghc --package hspec -- -Wall -Werror | |
import Test.Hspec | |
import Data.IORef | |
-- * test should be isolated from other tests - Pass (expected: Pass) ✔ | |
main :: IO () | |
main = hspec $ do | |
describe "asdf" $ beforeWith (\() -> newIORef False) $ do | |
describe "inner" $ beforeWith (\ctx -> writeIORef ctx True >> return ctx) $ do | |
it "ctx should be true" $ \ctx -> do | |
readIORef ctx >>= shouldBe True | |
it "(setting ctx to False)" $ \ctx -> do | |
writeIORef ctx False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment