stackbuilders / hspec-golden

Golden tests with Hspec
MIT License
23 stars 8 forks source link

Add IO instance #37

Closed dbalseiro closed 1 year ago

dbalseiro commented 1 year ago

We may want to do some actions that return a Golden test. There are some workarounds at the moment, but it will be convenient to have an IO instance for Golden. For instance we could do something like:

    goldenTest :: String -> IO (Golden String)
    goldenTest str = do
      lookupEnv str >>= \case
        Nothing -> throwIO $ AssertionFailed (str ++ " Not found")
        Just s -> defaultGolden s <$> someIOAction

For that we need to add an Example Instance to IO Golden

dbalseiro commented 1 year ago

Hey @CristhianMotoche! when you have a moment, could you take a look at this PR? thanks!

CristhianMotoche commented 1 year ago

Hey @dbalseiro The last version 2.1.0 has this change. Thanks for the contribution!