hspec-golden-aeson uses arbitrary instances to generate the golden files for the aeson instances. I think the main reason is to ensure the property (encode . decode) x == x. However, I think it can be helpful to use some arbitrary value instead setting one manually. For instance:
-- Module.hs
toHTML :: User -> Html
toHTML User{..} = ...
-- ModuleSpec.hs
describe "toHTML" $
it "generates a golden file for a User" $
let user = User {..}
in defaultGolden "toHTML.User" (renderHTML $ toHTML user)
It would be great to get the user automatically from a random example:
describe "toHTML" $
it "generates a golden file for a User" $
defaultGolden "toHTML.User" (renderHTML . toHTML)
I don't think arbitrary is required for this. faker could be a nice option.
hspec-golden-aeson uses arbitrary instances to generate the golden files for the aeson instances. I think the main reason is to ensure the property
(encode . decode) x == x
. However, I think it can be helpful to use some arbitrary value instead setting one manually. For instance:It would be great to get the user automatically from a random example:
I don't think arbitrary is required for this. faker could be a nice option.