on master help sign in
catching up to modern hspec.
commit8b1a462777eae8bf7b565200dee7221138d5f02a authorKazu Yamamoto <kazu@iij.ad.jp> dateWed 15 Aug 2012, 11:41 (14 years ago) parent0914347
1 file changed+18−23
warp/test/RunSpec.hs+18−23
warp/test/RunSpec.hs+18−23
@@ -2,27 +2,22 @@
22
33module RunSpec where
44
5−import Network.Wai
6−import Network.Wai.Handler.Warp
7−import qualified Data.IORef as I
8−import Control.Monad.IO.Class (MonadIO, liftIO)
9−import Network.HTTP.Types
105import Control.Concurrent (forkIO, killThread, threadDelay)
116import Control.Monad (forM_)
12−
13−import System.IO (hFlush, hClose)
14−import System.IO.Unsafe (unsafePerformIO)
7+import Control.Monad.IO.Class (MonadIO, liftIO)
158import Data.ByteString (ByteString, hPutStr, hGetSome)
169import qualified Data.ByteString as S
1710import qualified Data.ByteString.Lazy as L
18−import Network (connectTo, PortID (PortNumber))
19−
20−import Test.Hspec.Monadic
21−import Test.Hspec.HUnit ()
22−import Test.HUnit
23−
2411import Data.Conduit (($$))
2512import qualified Data.Conduit.List
13+import qualified Data.IORef as I
14+import Network (connectTo, PortID (PortNumber))
15+import Network.HTTP.Types
16+import Network.Wai
17+import Network.Wai.Handler.Warp
18+import System.IO (hFlush, hClose)
19+import System.IO.Unsafe (unsafePerformIO)
20+import Test.Hspec
2621
2722type Counter = I.IORef (Either String Int)
2823type CounterApplication = Counter -> Application
@@ -87,7 +82,7 @@ runTest expected app chunks = do
8782 res <- I.readIORef ref
8883 case res of
8984 Left s -> error s
90− Right i -> i @?= expected
85+ Right i -> i `shouldBe` expected
9186
9287dummyApp :: Application
9388dummyApp _ = return $ responseLBS status200 [] "foo"
@@ -110,7 +105,7 @@ runTerminateTest expected input = do
110105 threadDelay 1000
111106 killThread tid
112107 res <- I.readIORef ref
113− show res @?= show (Just expected)
108+ show res `shouldBe` show (Just expected)
114109
115110singleGet :: ByteString
116111singleGet = "GET / HTTP/1.1\r\nHost: localhost\r\n\r\n"
@@ -168,7 +163,7 @@ spec = do
168163 threadDelay 1000
169164 killThread tid
170165 headers <- I.readIORef iheaders
171− headers @?=
166+ headers `shouldBe`
172167 [ ("foo", "bar baz\tbin")
173168 ]
174169 it "no space between colon and value" $ do
@@ -188,7 +183,7 @@ spec = do
188183 threadDelay 1000
189184 killThread tid
190185 headers <- I.readIORef iheaders
191− headers @?=
186+ headers `shouldBe`
192187 [ ("foo", "bar")
193188 ]
194189 it "extra spaces in first line" $ do
@@ -208,7 +203,7 @@ spec = do
208203 threadDelay 1000
209204 killThread tid
210205 headers <- I.readIORef iheaders
211− headers @?=
206+ headers `shouldBe`
212207 [ ("foo", "bar")
213208 ]
214209 it "spaces in http version" $ do
@@ -228,7 +223,7 @@ spec = do
228223 threadDelay 1000
229224 killThread tid
230225 version <- I.readIORef iversion
231− version @?= http11
226+ version `shouldBe` http11
232227
233228 describe "chunked bodies" $ do
234229 it "works" $ do
@@ -252,7 +247,7 @@ spec = do
252247 threadDelay 1000
253248 killThread tid
254249 front <- I.readIORef ifront
255− front [] @?=
250+ front [] `shouldBe`
256251 [ "Hello World\nBye"
257252 , "Hello World"
258253 ]
@@ -274,7 +269,7 @@ spec = do
274269 threadDelay 1000
275270 killThread tid
276271 front <- I.readIORef ifront
277− front [] @?= replicate 2 (S.concat $ replicate 50 "12345")
272+ front [] `shouldBe` replicate 2 (S.concat $ replicate 50 "12345")
278273 it "in chunks" $ do
279274 ifront <- I.newIORef id
280275 port <- getPort
@@ -295,7 +290,7 @@ spec = do
295290 threadDelay 1000
296291 killThread tid
297292 front <- I.readIORef ifront
298− front [] @?=
293+ front [] `shouldBe`
299294 [ "Hello World\nBye"
300295 , "Hello World"
301296 ]