on master help sign in
Use the assertBodyContains for better failure messages
commitf07c3773ec39697b8f661b8611263259a5dc371c authorpatrick brisbin <pbrisbin@gmail.com> dateMon 17 Oct 2011, 15:50 (15 years ago) parent8e58a42
1 file changed+4−9
wai-app-static/tests/runtests.hs+4−9
wai-app-static/tests/runtests.hs+4−9
@@ -4,7 +4,7 @@ import Network.Wai.Application.Static
44import Test.Hspec.Monadic
55import Test.Hspec.QuickCheck
66import Test.Hspec.HUnit ()
7−import Test.HUnit ((@?=), assert)
7+import Test.HUnit ((@?=))
88import Distribution.Simple.Utils (isInfixOf)
99import qualified Data.ByteString.Char8 as S8
1010import qualified Data.ByteString.Lazy.Char8 as L8
@@ -46,8 +46,6 @@ setRawPathInfo r rawPinfo =
4646
4747main :: IO a
4848main = hspecX $ do
49− let must = liftIO . assert
50−
5149 let webApp = flip runSession $ staticApp defaultWebAppSettings {ssFolder = fileSystemLookup "tests"}
5250 let fileServerApp = flip runSession $ staticApp defaultFileServerSettings {ssFolder = fileSystemLookup "tests"}
5351
@@ -55,7 +53,6 @@ main = hspecX $ do
5553 let file = "a/b"
5654 let statFile = setRawPathInfo defRequest file
5755
58−
5956 describe "Pieces: pathFromPieces" $ do
6057 it "converts to a file path" $
6158 (pathFromPieces "prefix" ["a", "bc"]) @?= "prefix/a/bc"
@@ -136,11 +133,9 @@ main = hspecX $ do
136133 it "directory listing for index" $ fileServerApp $ do
137134 resp <- request (setRawPathInfo defRequest "a/")
138135 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\" />"
142− must $ body `contains` "<img src=\"../.hidden/folder.png\" alt=\"Folder\" />"
143− must $ body `contains` "<a href=\"b\">b</a>"
136+ assertBodyContains "<img src=\"../.hidden/haskell.png\" />" resp
137+ assertBodyContains "<img src=\"../.hidden/folder.png\" alt=\"Folder\" />" resp
138+ assertBodyContains "<a href=\"b\">b</a>" resp
144139
145140 it "200 when invalid if-modified-since header" $ fileServerApp $ do
146141 flip mapM_ ["123", ""] $ \badDate -> do