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

yesod-test refactor/split into yesod-hspec with hooks! #1763

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

parsonsmatt
Copy link
Contributor

So #1749 had me try an d implement hooks, which didn't work, because we go from TestApp site -> YesodExampleData site in 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 the yesod-test.

I refactored it and made yesod-hspec in this repository, which follows the hspec pattern a bit more closely and allows hooks.

Not sure if this should be a huge breaking change to yesod-test or an alternative.

Before submitting your PR, check that you've:

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

@parsonsmatt parsonsmatt changed the title more of a comment than a question... yesod-test refactor/split into yesod-hspec with hooks! Apr 13, 2022
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@parsonsmatt parsonsmatt marked this pull request as draft April 13, 2022 23:05
@parsonsmatt
Copy link
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant