@@ -6,12 +6,8 @@
6module Servant.Utils.StaticFilesSpec where
6module Servant.Utils.StaticFilesSpec where
8import Control.Exception
8import Control.Exception
11import Data.Proxy
9import Data.Proxy
12−import Data.String.Conversions
13import Network.Wai
10import Network.Wai
14−import Network.Wai.Test
15import System.Directory
11import System.Directory
16import System.IO.Temp
12import System.IO.Temp
17import Test.Hspec hiding (pending)
13import Test.Hspec hiding (pending)
@@ -22,7 +18,6 @@ import Servant.API.Capture
22import Servant.API.Get
18import Servant.API.Get
23import Servant.API.Raw
19import Servant.API.Raw
24import Servant.API.Sub
20import Servant.API.Sub
26import Servant.Server
21import Servant.Server
27import Servant.ServerSpec
22import Servant.ServerSpec
28import Servant.Utils.StaticFiles
23import Servant.Utils.StaticFiles
@@ -30,10 +25,7 @@ import Servant.Utils.StaticFiles
31 "dummy_api" :> Capture "person_name" String :> Get Person
26 "dummy_api" :> Capture "person_name" String :> Get Person
32 :<|> "static" :> Raw
27 :<|> "static" :> Raw
33− :<|> "documentation" :> Raw
35−instance ToCapture (Capture "person_name" String) where
36− toCapture _proxy = DocCapture "person_name" "person_name_doc"
38api :: Proxy Api
30api :: Proxy Api
39api = Proxy
31api = Proxy
@@ -45,7 +37,6 @@ server :: Server Api
46 (\ name -> return (Person name 42))
38 (\ name -> return (Person name 42))
47 :<|> serveDirectory "static"
39 :<|> serveDirectory "static"
48− :<|> serveDocumentation api
50withStaticFiles :: IO () -> IO ()
41withStaticFiles :: IO () -> IO ()
51withStaticFiles action = withSystemTempDirectory "servant-test" $ \ tmpDir ->
42withStaticFiles action = withSystemTempDirectory "servant-test" $ \ tmpDir ->
@@ -71,10 +62,3 @@ spec = do
72 it "serves the contents of index.html when requesting the root of a directory" $ do
63 it "serves the contents of index.html when requesting the root of a directory" $ do
73 get "/static" `shouldRespondWith` "index"
64 get "/static" `shouldRespondWith` "index"
75− describe "serveDocumentation" $ do
76− it "serves documentation about the expose API" $ do
77− response <- get "/documentation"
78− liftIO $ forM_ ["person_name" :: String, "static", "dummy_api", "person_name_doc"] $
80− (snippet, cs (simpleBody response)) `shouldSatisfy` uncurry isInfixOf