Name: hspec-wai
Owner: Wire Swiss GmbH
Description: Helpers to test WAI application with Hspec
Created: 2018-05-12 13:32:25.0
Updated: 2018-05-12 13:32:27.0
Pushed: 2018-05-12 13:53:41.0
Size: 134
Language: Haskell
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Helpers to test WAI applications with Hspec
LANGUAGE OverloadedStrings, QuasiQuotes #-}
le Main (main) where
rt Test.Hspec
rt Test.Hspec.Wai
rt Test.Hspec.Wai.JSON
rt Network.Wai (Application)
rt qualified Web.Scotty as S
rt Data.Aeson (Value(..), object, (.=))
:: IO ()
= hspec spec
:: IO Application
= S.scottyApp $ do
get "/" $ do
S.text "hello"
get "/some-json" $ do
S.json $ object ["foo" .= Number 23, "bar" .= Number 42]
:: Spec
= with app $ do
scribe "GET /" $ do
it "responds with 200" $ do
get "/" `shouldRespondWith` 200
it "responds with 'hello'" $ do
get "/" `shouldRespondWith` "hello"
it "responds with 200 / 'hello'" $ do
get "/" `shouldRespondWith` "hello" {matchStatus = 200}
it "has 'Content-Type: text/plain; charset=utf-8'" $ do
get "/" `shouldRespondWith` 200 {matchHeaders = ["Content-Type" <:> "text/plain; charset=utf-8"]}
scribe "GET /some-json" $ do
it "responds with some JSON" $ do
get "/some-json" `shouldRespondWith` [json|{foo: 23, bar: 42}|]
See hspec-wai on hackage: https://hackage.haskell.org/package/hspec-wai
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)