@@ -4,7 +4,7 @@ import Network.Wai.Application.Static
4import Test.Hspec.Monadic
4import Test.Hspec.Monadic
5import Test.Hspec.QuickCheck
5import Test.Hspec.QuickCheck
6import Test.Hspec.HUnit ()
6import Test.Hspec.HUnit ()
7−import Test.HUnit ((@?=), assert)
7+import Test.HUnit ((@?=))
8import Distribution.Simple.Utils (isInfixOf)
8import Distribution.Simple.Utils (isInfixOf)
9import qualified Data.ByteString.Char8 as S8
9import qualified Data.ByteString.Char8 as S8
10import qualified Data.ByteString.Lazy.Char8 as L8
10import qualified Data.ByteString.Lazy.Char8 as L8
@@ -46,8 +46,6 @@ setRawPathInfo r rawPinfo =
47main :: IO a
47main :: IO a
48main = hspecX $ do
48main = hspecX $ do
49− let must = liftIO . assert
51 let webApp = flip runSession $ staticApp defaultWebAppSettings {ssFolder = fileSystemLookup "tests"}
49 let webApp = flip runSession $ staticApp defaultWebAppSettings {ssFolder = fileSystemLookup "tests"}
52 let fileServerApp = flip runSession $ staticApp defaultFileServerSettings {ssFolder = fileSystemLookup "tests"}
50 let fileServerApp = flip runSession $ staticApp defaultFileServerSettings {ssFolder = fileSystemLookup "tests"}
@@ -55,7 +53,6 @@ main = hspecX $ do
55 let file = "a/b"
53 let file = "a/b"
56 let statFile = setRawPathInfo defRequest file
54 let statFile = setRawPathInfo defRequest file
59 describe "Pieces: pathFromPieces" $ do
56 describe "Pieces: pathFromPieces" $ do
60 it "converts to a file path" $
57 it "converts to a file path" $
61 (pathFromPieces "prefix" ["a", "bc"]) @?= "prefix/a/bc"
58 (pathFromPieces "prefix" ["a", "bc"]) @?= "prefix/a/bc"
@@ -136,11 +133,9 @@ main = hspecX $ do
136 it "directory listing for index" $ fileServerApp $ do
133 it "directory listing for index" $ fileServerApp $ do
137 resp <- request (setRawPathInfo defRequest "a/")
134 resp <- request (setRawPathInfo defRequest "a/")
138 assertStatus 200 resp
135 assertStatus 200 resp
139− let body = simpleBody resp
140− let contains a b = isInfixOf b (L8.unpack a)
141− must $ body `contains` "<img src=\"../.hidden/haskell.png\" />"
136+ assertBodyContains "<img src=\"../.hidden/haskell.png\" />" resp
142− must $ body `contains` "<img src=\"../.hidden/folder.png\" alt=\"Folder\" />"
137+ assertBodyContains "<img src=\"../.hidden/folder.png\" alt=\"Folder\" />" resp
143− must $ body `contains` "<a href=\"b\">b</a>"
138+ assertBodyContains "<a href=\"b\">b</a>" resp
145 it "200 when invalid if-modified-since header" $ fileServerApp $ do
140 it "200 when invalid if-modified-since header" $ fileServerApp $ do
146 flip mapM_ ["123", ""] $ \badDate -> do
141 flip mapM_ ["123", ""] $ \badDate -> do