Skip to content

Instantly share code, notes, and snippets.

@Gryff
Created March 12, 2019 16:26
Show Gist options
  • Save Gryff/f245279203fe56cd6175e17622b6005a to your computer and use it in GitHub Desktop.
Save Gryff/f245279203fe56cd6175e17622b6005a to your computer and use it in GitHub Desktop.
-- we'll need an instance of `Writer String` for `MonadCurrentDateTime` for our test
instance MonadCurrentDateTime (Writer String) where
currentDateTime = pure firstOfJan2019
testMyBank :: StateT [Transaction] (Writer String) ()
testMyBank = do
deposit 200
withdraw 100
deposit 3000
printStatement
-- output changed to match what the statement should look like
it "can deposit, withdraw and print a statement" $ do
execWriter (evalStateT testMyBank []) `shouldBe` "\
\date || credit || debit || balance\n\
\01/01/2019 || 200.00 || || 200.00\n\
\01/01/2019 || || 100.00 || 100.00\n\
\01/01/2019 || 3000.00 || || 3100.00\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment