Skip to content

How is this used with yesod-test? #42

Open
@jezen

Description

Given I have some typical yesod-test scaffolding like this

withApp :: SpecWith (TestApp App) -> Spec
withApp = around (bracket beforeEach afterEach) . aroundWith (. fst)
  where
  beforeEach :: IO (TestApp App, ())
  beforeEach = do
    app <- makeFoundation ":memory:"
    pure ((app, defaultMiddlewaresNoLogging), ())

  afterEach :: (TestApp App, ()) -> IO ()
  afterEach ((app, _), _) = shutdownApp app

…how do I run yesod tests with hspec-hedgehog?

I'd like to write something like this (which, of course, doesn't work).

spec :: Spec
spec = withApp $ do

  it "Displays the param" $ hedgehog $ do
    -- for any given number…
    xs <- forAll $ Gen.int (Range.linear 0 1000)
    -- navigate to some page with that number
    get $ SomeRouteR xs
    -- assert that the page renders the number
    htmlAnyContain "p" xs

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions