sydtest-yesod 0.1.0.0 → 0.2.0.1
raw patch · 6 files changed
+41/−33 lines, 6 filesdep ~sydtestPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: sydtest
API changes (from Hackage documentation)
+ Test.Syd.Yesod.Client: instance Test.Syd.Run.IsTest (Test.Syd.Yesod.Client.YesodClientM site ())
+ Test.Syd.Yesod.Client: instance Test.Syd.Run.IsTest (outerArgs -> Test.Syd.Yesod.Client.YesodClientM site ())
- Test.Syd.Yesod: yit :: forall site e. (HasCallStack, IsTest (YesodClient site -> IO e), Arg1 (YesodClient site -> IO e) ~ (), Arg2 (YesodClient site -> IO e) ~ YesodClient site) => String -> YesodClientM site e -> YesodSpec site
+ Test.Syd.Yesod: yit :: forall site. HasCallStack => String -> YesodClientM site () -> YesodSpec site
- Test.Syd.Yesod.Def: yit :: forall site e. (HasCallStack, IsTest (YesodClient site -> IO e), Arg1 (YesodClient site -> IO e) ~ (), Arg2 (YesodClient site -> IO e) ~ YesodClient site) => String -> YesodClientM site e -> YesodSpec site
+ Test.Syd.Yesod.Def: yit :: forall site. HasCallStack => String -> YesodClientM site () -> YesodSpec site
Files
- blog-example/Example/BlogSpec.hs +3/−3
- src/Test/Syd/Yesod/Client.hs +12/−0
- src/Test/Syd/Yesod/Def.hs +4/−8
- src/Test/Syd/Yesod/Request.hs +6/−6
- sydtest-yesod.cabal +2/−2
- test/Test/Syd/YesodSpec.hs +14/−14
blog-example/Example/BlogSpec.hs view
@@ -23,12 +23,12 @@ spec :: Spec spec = yesodSpecWithSiteSupplier appSupplier $ do -- A simple read-only test: We can request the home page succesfully.- yit "can GET the home page" $ do+ it "can GET the home page" $ do get HomeR statusIs 200 -- A simple test that shows a post request, and shows that empty forms will not be accepted.- yit "cannot post if the form data is missing" $ do+ it "cannot post if the form data is missing" $ do get NewThoughtR statusIs 200 request $ do@@ -40,7 +40,7 @@ -- A simple form POST request test. -- Each part of the form needs to be added using 'addPostParam' -- Don't forget the 'addToken' piece to make sure you don't run into CSRF errors.- yit "can post this example blogpost" $ do+ it "can post this example blogpost" $ do get NewThoughtR statusIs 200 request $ do
src/Test/Syd/Yesod/Client.hs view
@@ -1,10 +1,12 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-redundant-constraints -fno-warn-unused-imports #-} module Test.Syd.Yesod.Client where@@ -70,6 +72,16 @@ MonadFail, MonadThrow )++instance IsTest (YesodClientM site ()) where+ type Arg1 (YesodClientM site ()) = ()+ type Arg2 (YesodClientM site ()) = YesodClient site+ runTest func = runTest (\() -> func)++instance IsTest (outerArgs -> YesodClientM site ()) where+ type Arg1 (outerArgs -> YesodClientM site ()) = outerArgs+ type Arg2 (outerArgs -> YesodClientM site ()) = YesodClient site+ runTest func = runTest (\outerArgs yesodClient -> runYesodClientM yesodClient (func outerArgs)) -- | For backward compatibility type YesodExample site a = YesodClientM site a
src/Test/Syd/Yesod/Def.hs view
@@ -176,16 +176,12 @@ -- | Define a test in the 'YesodClientM site' monad instead of 'IO'. yit ::- forall site e.- ( HasCallStack,- IsTest (YesodClient site -> IO e),- Arg1 (YesodClient site -> IO e) ~ (),- Arg2 (YesodClient site -> IO e) ~ YesodClient site- ) =>+ forall site.+ HasCallStack => String ->- YesodClientM site e ->+ YesodClientM site () -> YesodSpec site-yit s f = it s ((\cenv -> runYesodClientM cenv f) :: YesodClient site -> IO e)+yit = it -- | For compatibility with `yesod-test` --
src/Test/Syd/Yesod/Request.hs view
@@ -44,7 +44,7 @@ -- | Make a @GET@ request for the given route ----- > yit "returns 200 on the home route" $ do+-- > it "returns 200 on the home route" $ do -- > get HomeR -- > statusIs 200 get :: (Yesod site, RedirectUrl site url) => url -> YesodClientM site ()@@ -52,7 +52,7 @@ -- | Make a @POST@ request for the given route ----- > yit "returns 200 on the start processing route" $ do+-- > it "returns 200 on the start processing route" $ do -- > post StartProcessingR -- > statusIs 200 post :: (Yesod site, RedirectUrl site url) => url -> YesodClientM site ()@@ -66,7 +66,7 @@ -- | Assert the status of the most recently received response. ----- > yit "returns 200 on the home route" $ do+-- > it "returns 200 on the home route" $ do -- > get HomeR -- > statusIs 200 statusIs :: HasCallStack => Int -> YesodClientM site ()@@ -80,7 +80,7 @@ -- | Assert the redirect location of the most recently received response. ----- > yit "redirects to the overview on the home route" $ do+-- > it "redirects to the overview on the home route" $ do -- > get HomeR -- > statusIs 301 -- > locationShouldBe OverviewR@@ -90,7 +90,7 @@ errOrLoc <- getLocation liftIO $ case errOrLoc of Left err -> expectationFailure (T.unpack err)- Right actual -> expected `shouldBe` actual+ Right actual -> actual `shouldBe` expected -- | Assert the last response has the given text. --@@ -227,7 +227,7 @@ -- | Perform the request that is built by the given 'RequestBuilder'. ----- > yit "returns 200 on this post request" $ do+-- > it "returns 200 on this post request" $ do -- > request $ do -- > setUrl StartProcessingR -- > setMethod "POST"
sydtest-yesod.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: sydtest-yesod-version: 0.1.0.0+version: 0.2.0.1 synopsis: A yesod companion library for sydtest category: Testing homepage: https://github.com/NorfairKing/sydtest#readme@@ -44,7 +44,7 @@ , mtl , network , pretty-show- , sydtest+ , sydtest >=0.3.0.0 , sydtest-wai , text , time
test/Test/Syd/YesodSpec.hs view
@@ -9,57 +9,57 @@ spec :: Spec spec = yesodSpec App $ do- yit "responds 200 OK to GET HomeR" $ do+ it "responds 200 OK to GET HomeR" $ do get HomeR statusIs 200- yit "responds 200 OK to GET HomeR using the request builder" $ do+ it "responds 200 OK to GET HomeR using the request builder" $ do request $ do setUrl HomeR setMethod "GET" statusIs 200- yit "responds 200 OK to GET /" $ do+ it "responds 200 OK to GET /" $ do get ("/" :: Text) statusIs 200- yit "responds 200 OK to POST HomeR" $ do+ it "responds 200 OK to POST HomeR" $ do post HomeR statusIs 200- yit "responds 200 OK to POST HomeR using the request builder" $ do+ it "responds 200 OK to POST HomeR using the request builder" $ do request $ do setUrl HomeR setMethod "POST" statusIs 200- yit "responds 200 OK to POST /" $ do+ it "responds 200 OK to POST /" $ do post ("/" :: Text) statusIs 200- yit "is able to add a header" $ do+ it "is able to add a header" $ do request $ do setUrl ExpectsHeaderR addRequestHeader ("TEST_HEADER", "test") statusIs 200- yit "is able to add a get param" $ do+ it "is able to add a get param" $ do request $ do setUrl ExpectsGetParamR addGetParam "TEST_PARAM" "test" statusIs 200- yit "is able to add a post param" $ do+ it "is able to add a post param" $ do request $ do setUrl ExpectsPostParamR setMethod "POST" addPostParam "TEST_PARAM" "test" statusIs 200- yit "is able to add a raw post body" $ do+ it "is able to add a raw post body" $ do request $ do setUrl ExpectsPostBodyR setMethod "POST" setRequestBody "test" statusIs 200- yit "is able to add a post file" $ do+ it "is able to add a post file" $ do request $ do setUrl ExpectsPostFileR setMethod "POST" addFileWith "TEST_PARAM" "filename" "test" (Just "text/plain") statusIs 200- yit "can check for redirects" $ do+ it "can check for redirects" $ do get RedirectHomeR locationShouldBe HomeR errOrDestination <- followRedirect@@ -67,12 +67,12 @@ Left err -> expectationFailure (show err) Right _ -> pure () statusIs 200- yit "retains cookies" $ do+ it "retains cookies" $ do get SetCookieR statusIs 200 get ExpectsCookieR statusIs 200- yit "can do forms" $ do+ it "can do forms" $ do get FormR statusIs 200 request $ do