* Add test API with multiple Path elements * Add basic test using this API, generating an endpoint to validate that query path delimiting is happening correctly (that fails on `master`) * Fix (re)creation of path to prepend `/` to each new path section, but only if it's non-empty (this fixes the trailing slashes, but still allows users to use a `:> "foo/" :>...` if their API demands trailing slashes) * Update / fix the existing test that now fails slightly differently (i.e. the trailing slash in `failplz/` is gone) Fixes #22. |
||
|---|---|---|
| doc | ||
| src/Servant | ||
| test | ||
| .gitignore | ||
| .travis.yml | ||
| CHANGELOG.yaml | ||
| LICENSE | ||
| README.md | ||
| servant-quickcheck.cabal | ||
| Setup.hs | ||
| stack-lts-6.yaml | ||
| stack-lts-7.yaml | ||
| stack.yaml | ||
servant-quickcheck
servant-quickcheck provides tools to test properties across entire APIs.
Rather than writing the same tests for each endpoint, with servant-quickcheck
you can simply specify properties every endpoint must meet once and for all.
For example:
followsBestPractices :: Spec
followsBestPractices = describe "my API" $ do
it "follows best practices" $ do
withServantServer myAPI myServer $ \burl ->
serverSatisfies api burl stdArgs
( not500
<%> onlyJsonObjects
<%> getsHaveCacheControlHeader
<%> headsHaveCacheControlHeader
<%> mempty)
Additionally, servant-quickcheck provides a serversEqual function that
generates arbitrary requests (that conform to the description of an API) and
tests that two servers respond identically to them. This can be useful when
refactoring or rewriting an API that should not change.