on master help sign in
test suite: Capture strips path snippets
d9eaf76Sönke Hahn
test/Servant/ServerSpec.hs+8
@@ -11,6 +11,7 @@ module Servant.ServerSpec where
11import Control.Monad.Trans.Either
11import Control.Monad.Trans.Either
12import Data.Aeson
12import Data.Aeson
13import Data.Proxy
13import Data.Proxy
14+import Data.String
14import Data.String.Conversions
15import Data.String.Conversions
15import GHC.Generics
16import GHC.Generics
16import Network.HTTP.Types
17import Network.HTTP.Types
@@ -90,6 +91,13 @@ captureSpec = do
90 liftIO $ do
91 liftIO $ do
91 decode' (simpleBody response) `shouldBe` Just tweety
92 decode' (simpleBody response) `shouldBe` Just tweety
92
93
94+ with (return (serve
95+ (Proxy :: Proxy (Capture "captured" String :> Raw))
96+ (\ "captured" request respond ->
97+ respond $ responseLBS ok200 [] (cs $ show $ pathInfo request)))) $ do
98+ it "strips the captured path snippet from pathInfo" $ do
99+ get "/captured/foo" `shouldRespondWith` (fromString (show ["foo" :: String]))
100+
93
101
94type GetApi = Get Person
102type GetApi = Get Person
95getApi :: Proxy GetApi
103getApi :: Proxy GetApi