Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using arbitrary values to generate the golden files #14

Open
CristhianMotoche opened this issue Dec 13, 2019 · 0 comments
Open

Using arbitrary values to generate the golden files #14

CristhianMotoche opened this issue Dec 13, 2019 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@CristhianMotoche
Copy link
Collaborator

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.

@CristhianMotoche CristhianMotoche changed the title Using arbitrary instances to generate the golden files Using arbitrary values to generate the golden files Dec 13, 2019
@CristhianMotoche CristhianMotoche added the enhancement New feature or request label Dec 13, 2019
@CristhianMotoche CristhianMotoche added this to the 0.2.0.0 milestone Dec 13, 2019
@CristhianMotoche CristhianMotoche added the question Further information is requested label Oct 6, 2020
@CristhianMotoche CristhianMotoche removed the question Further information is requested label Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant