yesod-test refactor/split into yesod-hspec with hooks!#1763
Draft
parsonsmatt wants to merge 12 commits intoyesodweb:masterfrom
Draft
yesod-test refactor/split into yesod-hspec with hooks!#1763parsonsmatt wants to merge 12 commits intoyesodweb:masterfrom
yesod-test refactor/split into yesod-hspec with hooks!#1763parsonsmatt wants to merge 12 commits intoyesodweb:masterfrom
Conversation
yesod-test refactor/split into yesod-hspec with hooks!
parsonsmatt
commented
Apr 13, 2022
yesod-hspec/test/main.hs
Outdated
Comment on lines
358
to
364
| describe "hooks" $ yesodSpec app $ do | ||
| ybefore_ (get ("/" :: Text)) $ do | ||
| yit "works" $ do | ||
| statusIs 200 | ||
| ybefore_ (post ("/cookie/foo" :: Text)) $ do | ||
| yit "works again" $ do | ||
| statusIs 303 |
Contributor
Author
There was a problem hiding this comment.
This is the exciting thing. Now if you want a bunch of tests that share some setup, you can get it. This makes it much easier to write small tests that make small assertions and reduce code duplication.
Contributor
Author
|
hmm now that i have figured this out, i am going to try and get it into a more minimal change so it will hopefully break fewer things |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So #1749 had me try an d implement hooks, which didn't work, because we go from
TestApp site -> YesodExampleData sitein the various example-runners and immediately throw that info away. So there is not a way to get hook behavior with the current implementation of theyesod-test.I refactored it and made
yesod-hspecin this repository, which follows thehspecpattern a bit more closely and allows hooks.Not sure if this should be a huge breaking change to
yesod-testor an alternative.Before submitting your PR, check that you've:
@sincedeclarations to the Haddocks for new, public APIsAfter submitting your PR: