git.iko.soy/typeable/servant
on master help sign in
fix build error for servant's spec
0dfd243Alp Mestanogullari
src/Servant/Utils/StaticFiles.hs−3
@@ -6,11 +6,8 @@ module Servant.Utils.StaticFiles (
6 serveDirectory,
6 serveDirectory,
7 ) where
7 ) where
8
8
9−import Data.String.Conversions
10import Filesystem.Path.CurrentOS (decodeString)
9import Filesystem.Path.CurrentOS (decodeString)
11−import Network.Wai
12import Network.Wai.Application.Static
10import Network.Wai.Application.Static
13−
14import Servant.API.Raw
11import Servant.API.Raw
15import Servant.Server
12import Servant.Server
16
13
test/Servant/Utils/StaticFilesSpec.hs−16
@@ -6,12 +6,8 @@
6module Servant.Utils.StaticFilesSpec where
6module Servant.Utils.StaticFilesSpec where
7
7
8import Control.Exception
8import Control.Exception
9−import Data.Foldable
10−import Data.List
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
25−import Servant.Docs
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
30type Api =
25type Api =
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
34
28
35−instance ToCapture (Capture "person_name" String) where
36− toCapture _proxy = DocCapture "person_name" "person_name_doc"
37
29
38api :: Proxy Api
30api :: Proxy Api
39api = Proxy
31api = Proxy
@@ -45,7 +37,6 @@ server :: Server Api
45server =
37server =
46 (\ name -> return (Person name 42))
38 (\ name -> return (Person name 42))
47 :<|> serveDirectory "static"
39 :<|> serveDirectory "static"
48− :<|> serveDocumentation api
49
40
50withStaticFiles :: IO () -> IO ()
41withStaticFiles :: IO () -> IO ()
51withStaticFiles action = withSystemTempDirectory "servant-test" $ \ tmpDir ->
42withStaticFiles action = withSystemTempDirectory "servant-test" $ \ tmpDir ->
@@ -71,10 +62,3 @@ spec = do
71
62
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"
74−
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"] $
79− \ snippet ->
80− (snippet, cs (simpleBody response)) `shouldSatisfy` uncurry isInfixOf