diff --git a/scripts b/scripts index eba05a0b..bf06d8e7 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit eba05a0b5fe121883969f8fa9b7f7669592430a4 +Subproject commit bf06d8e764f3d2931c0a676dc5c6fc14491b012a diff --git a/yesod-core/test.hs b/yesod-core/test.hs index 49141594..c85d1890 100644 --- a/yesod-core/test.hs +++ b/yesod-core/test.hs @@ -2,4 +2,4 @@ import Test.Hspec import qualified YesodCoreTest main :: IO () -main = hspecX $ YesodCoreTest.specs +main = hspec YesodCoreTest.specs diff --git a/yesod-core/test/YesodCoreTest.hs b/yesod-core/test/YesodCoreTest.hs index b89d5ed2..b6384331 100644 --- a/yesod-core/test/YesodCoreTest.hs +++ b/yesod-core/test/YesodCoreTest.hs @@ -15,18 +15,17 @@ import qualified YesodCoreTest.JsLoader as JsLoader import Test.Hspec -specs :: [Spec] -specs = - [ cleanPathTest - , exceptionsTest - , widgetTest - , mediaTest - , linksTest - , noOverloadedTest - , internalRequestTest - , errorHandlingTest - , cacheTest - , WaiSubsite.specs - , Redirect.specs - , JsLoader.specs - ] +specs :: Spec +specs = do + cleanPathTest + exceptionsTest + widgetTest + mediaTest + linksTest + noOverloadedTest + internalRequestTest + errorHandlingTest + cacheTest + WaiSubsite.specs + Redirect.specs + JsLoader.specs diff --git a/yesod-core/test/YesodCoreTest/Cache.hs b/yesod-core/test/YesodCoreTest/Cache.hs index 9e96947b..3514f8f3 100644 --- a/yesod-core/test/YesodCoreTest/Cache.hs +++ b/yesod-core/test/YesodCoreTest/Cache.hs @@ -37,9 +37,8 @@ getRootR = do cacheTest :: Spec cacheTest = - describe "Test.Cache" - [ it "works" works - ] + describe "Test.Cache" $ do + it "works" works runner :: Session () -> IO () runner f = toWaiApp C >>= runSession f diff --git a/yesod-core/test/YesodCoreTest/CleanPath.hs b/yesod-core/test/YesodCoreTest/CleanPath.hs index 10d95497..99637af4 100644 --- a/yesod-core/test/YesodCoreTest/CleanPath.hs +++ b/yesod-core/test/YesodCoreTest/CleanPath.hs @@ -64,15 +64,14 @@ getPlainR = return $ RepPlain "plain" cleanPathTest :: Spec cleanPathTest = - describe "Test.CleanPath" - [ it "remove trailing slash" removeTrailingSlash - , it "noTrailingSlash" noTrailingSlash - , it "add trailing slash" addTrailingSlash - , it "has trailing slash" hasTrailingSlash - , it "/foo/something" fooSomething - , it "subsite dispatch" subsiteDispatch - , it "redirect with query string" redQueryString - ] + describe "Test.CleanPath" $ do + it "remove trailing slash" removeTrailingSlash + it "noTrailingSlash" noTrailingSlash + it "add trailing slash" addTrailingSlash + it "has trailing slash" hasTrailingSlash + it "/foo/something" fooSomething + it "subsite dispatch" subsiteDispatch + it "redirect with query string" redQueryString runner :: Session () -> IO () runner f = toWaiApp Y >>= runSession f diff --git a/yesod-core/test/YesodCoreTest/ErrorHandling.hs b/yesod-core/test/YesodCoreTest/ErrorHandling.hs index 92171c41..fdd1021f 100644 --- a/yesod-core/test/YesodCoreTest/ErrorHandling.hs +++ b/yesod-core/test/YesodCoreTest/ErrorHandling.hs @@ -67,13 +67,12 @@ getErrorInBodyNoEvalR :: Handler (DontFullyEvaluate RepHtml) getErrorInBodyNoEvalR = fmap DontFullyEvaluate getErrorInBodyR errorHandlingTest :: Spec -errorHandlingTest = describe "Test.ErrorHandling" - [ it "says not found" caseNotFound - , it "says 'There was an error' before runRequestBody" caseBefore - , it "says 'There was an error' after runRequestBody" caseAfter - , it "error in body == 500" caseErrorInBody - , it "error in body, no eval == 200" caseErrorInBodyNoEval - ] +errorHandlingTest = describe "Test.ErrorHandling" $ do + it "says not found" caseNotFound + it "says 'There was an error' before runRequestBody" caseBefore + it "says 'There was an error' after runRequestBody" caseAfter + it "error in body == 500" caseErrorInBody + it "error in body, no eval == 200" caseErrorInBodyNoEval runner :: Session () -> IO () runner f = toWaiApp App >>= runSession f diff --git a/yesod-core/test/YesodCoreTest/Exceptions.hs b/yesod-core/test/YesodCoreTest/Exceptions.hs index 81c10d07..3ea0d720 100644 --- a/yesod-core/test/YesodCoreTest/Exceptions.hs +++ b/yesod-core/test/YesodCoreTest/Exceptions.hs @@ -31,10 +31,9 @@ getRedirR = do redirectWith status301 RootR exceptionsTest :: Spec -exceptionsTest = describe "Test.Exceptions" - [ it "500" case500 - , it "redirect keeps headers" caseRedirect - ] +exceptionsTest = describe "Test.Exceptions" $ do + it "500" case500 + it "redirect keeps headers" caseRedirect runner :: Session () -> IO () runner f = toWaiApp Y >>= runSession f diff --git a/yesod-core/test/YesodCoreTest/InternalRequest.hs b/yesod-core/test/YesodCoreTest/InternalRequest.hs index b2a1e179..6fcd924d 100644 --- a/yesod-core/test/YesodCoreTest/InternalRequest.hs +++ b/yesod-core/test/YesodCoreTest/InternalRequest.hs @@ -11,10 +11,9 @@ import Yesod.Request (Request (..)) import Test.Hspec randomStringSpecs :: Spec -randomStringSpecs = describe "Yesod.Internal.Request.randomString" - [ it "looks reasonably random" looksRandom - , it "does not repeat itself" $ noRepeat 10 100 - ] +randomStringSpecs = describe "Yesod.Internal.Request.randomString" $ do + it "looks reasonably random" looksRandom + it "does not repeat itself" $ noRepeat 10 100 -- NOTE: this testcase may break on other systems/architectures if -- mkStdGen is not identical everywhere (is it?). @@ -31,12 +30,11 @@ g = error "test/YesodCoreTest/InternalRequest.g" tokenSpecs :: Spec -tokenSpecs = describe "Yesod.Internal.Request.parseWaiRequest (reqToken)" - [ it "is Nothing if sessions are disabled" noDisabledToken - , it "ignores pre-existing token if sessions are disabled" ignoreDisabledToken - , it "uses preexisting token in session" useOldToken - , it "generates a new token for sessions without token" generateToken - ] +tokenSpecs = describe "Yesod.Internal.Request.parseWaiRequest (reqToken)" $ do + it "is Nothing if sessions are disabled" noDisabledToken + it "ignores pre-existing token if sessions are disabled" ignoreDisabledToken + it "uses preexisting token in session" useOldToken + it "generates a new token for sessions without token" generateToken noDisabledToken :: Bool noDisabledToken = reqToken r == Nothing where @@ -56,13 +54,12 @@ generateToken = reqToken r /= Nothing where langSpecs :: Spec -langSpecs = describe "Yesod.Internal.Request.parseWaiRequest (reqLangs)" - [ it "respects Accept-Language" respectAcceptLangs - , it "respects sessions" respectSessionLang - , it "respects cookies" respectCookieLang - , it "respects queries" respectQueryLang - , it "prioritizes correctly" prioritizeLangs - ] +langSpecs = describe "Yesod.Internal.Request.parseWaiRequest (reqLangs)" $ do + it "respects Accept-Language" respectAcceptLangs + it "respects sessions" respectSessionLang + it "respects cookies" respectCookieLang + it "respects queries" respectQueryLang + it "prioritizes correctly" prioritizeLangs respectAcceptLangs :: Bool respectAcceptLangs = reqLangs r == ["en-US", "es", "en"] where @@ -94,8 +91,7 @@ prioritizeLangs = reqLangs r == ["en-QUERY", "en-COOKIE", "en-SESSION", "en", "e internalRequestTest :: Spec -internalRequestTest = describe "Test.InternalRequestTest" - [ randomStringSpecs - , tokenSpecs - , langSpecs - ] +internalRequestTest = describe "Test.InternalRequestTest" $ do + randomStringSpecs + tokenSpecs + langSpecs diff --git a/yesod-core/test/YesodCoreTest/JsLoader.hs b/yesod-core/test/YesodCoreTest/JsLoader.hs index c23b2229..11b1a38d 100644 --- a/yesod-core/test/YesodCoreTest/JsLoader.hs +++ b/yesod-core/test/YesodCoreTest/JsLoader.hs @@ -23,19 +23,18 @@ getHeadR :: Handler RepHtml getHeadR = defaultLayout $ addScriptRemote "load.js" specs :: Spec -specs = describe "Test.JsLoader" [ +specs = describe "Test.JsLoader" $ do it "link from head" $ runner H $ do res <- request defaultRequest assertBody "\n