Hello community,

here is the log from the commit of package ghc-hspec-wai for openSUSE:Factory 
checked in at 2017-04-11 09:37:42
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-hspec-wai (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-hspec-wai.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-hspec-wai"

Tue Apr 11 09:37:42 2017 rev:2 rq:483924 version:0.8.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-hspec-wai/ghc-hspec-wai.changes      
2017-03-24 01:55:13.272537420 +0100
+++ /work/SRC/openSUSE:Factory/.ghc-hspec-wai.new/ghc-hspec-wai.changes 
2017-04-11 09:37:43.356145823 +0200
@@ -1,0 +2,5 @@
+Sun Feb 12 14:20:35 UTC 2017 - [email protected]
+
+- Update to version 0.8.0 with cabal2obs.
+
+-------------------------------------------------------------------

Old:
----
  hspec-wai-0.6.6.tar.gz

New:
----
  hspec-wai-0.8.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-hspec-wai.spec ++++++
--- /var/tmp/diff_new_pack.paNGp2/_old  2017-04-11 09:37:43.900068987 +0200
+++ /var/tmp/diff_new_pack.paNGp2/_new  2017-04-11 09:37:43.900068987 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package ghc-hspec-wai
 #
-# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -19,15 +19,14 @@
 %global pkg_name hspec-wai
 %bcond_with tests
 Name:           ghc-%{pkg_name}
-Version:        0.6.6
+Version:        0.8.0
 Release:        0
 Summary:        Experimental Hspec support for testing WAI applications
 License:        MIT
-Group:          System/Libraries
+Group:          Development/Languages/Other
 Url:            https://hackage.haskell.org/package/%{pkg_name}
 Source0:        
https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
 BuildRequires:  ghc-Cabal-devel
-# Begin cabal-rpm deps:
 BuildRequires:  ghc-QuickCheck-devel
 BuildRequires:  ghc-base-compat-devel
 BuildRequires:  ghc-bytestring-devel
@@ -40,12 +39,10 @@
 BuildRequires:  ghc-transformers-devel
 BuildRequires:  ghc-wai-devel
 BuildRequires:  ghc-wai-extra-devel
-BuildRequires:  ghc-with-location-devel
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 %if %{with tests}
 BuildRequires:  ghc-hspec-devel
 %endif
-# End cabal-rpm deps
 
 %description
 Experimental Hspec support for testing WAI applications.
@@ -64,20 +61,14 @@
 %prep
 %setup -q -n %{pkg_name}-%{version}
 
-
 %build
 %ghc_lib_build
 
-
 %install
 %ghc_lib_install
 
-
 %check
-%if %{with tests}
-%{cabal} test
-%endif
-
+%cabal_test
 
 %post devel
 %ghc_pkg_recache

++++++ hspec-wai-0.6.6.tar.gz -> hspec-wai-0.8.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hspec-wai-0.6.6/hspec-wai.cabal 
new/hspec-wai-0.8.0/hspec-wai.cabal
--- old/hspec-wai-0.6.6/hspec-wai.cabal 2016-03-16 11:10:57.000000000 +0100
+++ new/hspec-wai-0.8.0/hspec-wai.cabal 2016-10-08 08:21:00.000000000 +0200
@@ -1,9 +1,9 @@
--- This file has been generated from package.yaml by hpack version 0.11.0.
+-- This file has been generated from package.yaml by hpack version 0.15.0.
 --
 -- see: https://github.com/sol/hpack
 
 name:             hspec-wai
-version:          0.6.6
+version:          0.8.0
 homepage:         https://github.com/hspec/hspec-wai#readme
 bug-reports:      https://github.com/hspec/hspec-wai/issues
 license:          MIT
@@ -42,15 +42,14 @@
     , wai >= 3
     , wai-extra >= 3
     , hspec-core == 2.*
-    , hspec-expectations
+    , hspec-expectations >= 0.8.0
     , QuickCheck
-    , with-location >= 0.1.0
   exposed-modules:
       Test.Hspec.Wai
       Test.Hspec.Wai.QuickCheck
       Test.Hspec.Wai.Internal
-  other-modules:
       Test.Hspec.Wai.Matcher
+  other-modules:
       Test.Hspec.Wai.Util
       Paths_hspec_wai
   default-language: Haskell2010
@@ -60,7 +59,7 @@
   main-is: Spec.hs
   hs-source-dirs:
       src
-    , test
+      test
   ghc-options: -Wall
   build-depends:
       base == 4.*
@@ -73,9 +72,8 @@
     , wai >= 3
     , wai-extra >= 3
     , hspec-core == 2.*
-    , hspec-expectations
+    , hspec-expectations >= 0.8.0
     , QuickCheck
-    , with-location >= 0.1.0
     , hspec
     , QuickCheck
   other-modules:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hspec-wai-0.6.6/src/Test/Hspec/Wai/Internal.hs 
new/hspec-wai-0.8.0/src/Test/Hspec/Wai/Internal.hs
--- old/hspec-wai-0.6.6/src/Test/Hspec/Wai/Internal.hs  2016-03-16 
11:10:57.000000000 +0100
+++ new/hspec-wai-0.8.0/src/Test/Hspec/Wai/Internal.hs  2016-10-08 
08:21:00.000000000 +0200
@@ -22,12 +22,12 @@
 import           Test.Hspec.Wai.Util (formatHeader)
 
 -- | An expectation in the `WaiSession` monad.  Failing expectations are
--- communicated through exceptions (similar to `Expectation` and
+-- communicated through exceptions (similar to 
`Test.Hspec.Expectations.Expectation` and
 -- `Test.HUnit.Base.Assertion`).
 type WaiExpectation = WaiSession ()
 
 -- | A <http://www.yesodweb.com/book/web-application-interface WAI> test
--- session that carries the `Application` under test an some client state.
+-- session that carries the `Application` under test and some client state.
 newtype WaiSession a = WaiSession {unWaiSession :: Session a}
   deriving (Functor, Applicative, Monad, MonadIO)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hspec-wai-0.6.6/src/Test/Hspec/Wai/Matcher.hs 
new/hspec-wai-0.8.0/src/Test/Hspec/Wai/Matcher.hs
--- old/hspec-wai-0.6.6/src/Test/Hspec/Wai/Matcher.hs   2016-03-16 
11:10:57.000000000 +0100
+++ new/hspec-wai-0.8.0/src/Test/Hspec/Wai/Matcher.hs   2016-10-08 
08:21:00.000000000 +0200
@@ -2,7 +2,10 @@
 module Test.Hspec.Wai.Matcher (
   ResponseMatcher(..)
 , MatchHeader(..)
+, MatchBody(..)
+, Body
 , (<:>)
+, bodyEquals
 , match
 ) where
 
@@ -13,6 +16,7 @@
 import           Data.Maybe
 import           Data.String
 import           Data.Text.Lazy.Encoding (encodeUtf8)
+import qualified Data.Text.Lazy as T
 import           Data.ByteString (ByteString)
 import qualified Data.ByteString.Lazy as LB
 import           Network.HTTP.Types
@@ -20,19 +24,39 @@
 
 import           Test.Hspec.Wai.Util
 
+type Body = LB.ByteString
+
 data ResponseMatcher = ResponseMatcher {
   matchStatus :: Int
 , matchHeaders :: [MatchHeader]
-, matchBody :: Maybe LB.ByteString
+, matchBody :: MatchBody
 }
 
-data MatchHeader = MatchHeader ([Header] -> Maybe String)
+data MatchHeader = MatchHeader ([Header] -> Body -> Maybe String)
+
+data MatchBody = MatchBody ([Header] -> Body -> Maybe String)
+
+bodyEquals :: Body -> MatchBody
+bodyEquals body = MatchBody (\_ actual -> bodyMatcher actual body)
+  where
+    bodyMatcher :: Body -> Body -> Maybe String
+    bodyMatcher (toStrict -> actual) (toStrict -> expected) = actualExpected 
"body mismatch:" actual_ expected_ <$ guard (actual /= expected)
+      where
+        (actual_, expected_) = case (safeToString actual, safeToString 
expected) of
+          (Just x, Just y) -> (x, y)
+          _ -> (show actual, show expected)
+
+matchAny :: MatchBody
+matchAny = MatchBody (\_ _ -> Nothing)
+
+instance IsString MatchBody where
+  fromString = bodyEquals . encodeUtf8 . T.pack
 
 instance IsString ResponseMatcher where
-  fromString s = ResponseMatcher 200 [] (Just . encodeUtf8 . fromString $ s)
+  fromString = ResponseMatcher 200 [] . fromString
 
 instance Num ResponseMatcher where
-  fromInteger n = ResponseMatcher (fromInteger n) [] Nothing
+  fromInteger n = ResponseMatcher (fromInteger n) [] matchAny
   (+) =    error "ResponseMatcher does not support (+)"
   (-) =    error "ResponseMatcher does not support (-)"
   (*) =    error "ResponseMatcher does not support (*)"
@@ -40,34 +64,28 @@
   signum = error "ResponseMatcher does not support `signum`"
 
 match :: SResponse -> ResponseMatcher -> Maybe String
-match (SResponse (Status status _) headers body) (ResponseMatcher 
expectedStatus expectedHeaders expectedBody) = mconcat [
+match (SResponse (Status status _) headers body) (ResponseMatcher 
expectedStatus expectedHeaders (MatchBody bodyMatcher)) = mconcat [
     actualExpected "status mismatch:" (show status) (show expectedStatus) <$ 
guard (status /= expectedStatus)
-  , checkHeaders headers expectedHeaders
-  , expectedBody >>= matchBody_ body
+  , checkHeaders headers body expectedHeaders
+  , bodyMatcher headers body
   ]
-  where
-    matchBody_ (toStrict -> actual) (toStrict -> expected) = actualExpected 
"body mismatch:" actual_ expected_ <$ guard (actual /= expected)
-      where
-        (actual_, expected_) = case (safeToString actual, safeToString 
expected) of
-          (Just x, Just y) -> (x, y)
-          _ -> (show actual, show expected)
 
-    actualExpected :: String -> String -> String -> String
-    actualExpected message actual expected = unlines [
-        message
-      , "  expected: " ++ expected
-      , "  but got:  " ++ actual
-      ]
+actualExpected :: String -> String -> String -> String
+actualExpected message actual expected = unlines [
+    message
+  , "  expected: " ++ expected
+  , "  but got:  " ++ actual
+  ]
 
-checkHeaders :: [Header] -> [MatchHeader] -> Maybe String
-checkHeaders headers m = case go m of
+checkHeaders :: [Header] -> Body -> [MatchHeader] -> Maybe String
+checkHeaders headers body m = case go m of
     [] -> Nothing
     xs -> Just (mconcat xs ++ "the actual headers were:\n" ++ unlines (map 
formatHeader headers))
   where
-    go = catMaybes . map (\(MatchHeader p) -> p headers)
+    go = catMaybes . map (\(MatchHeader p) -> p headers body)
 
 (<:>) :: HeaderName -> ByteString -> MatchHeader
-name <:> value = MatchHeader $ \headers -> guard (header `notElem` headers) >> 
(Just . unlines) [
+name <:> value = MatchHeader $ \headers _body -> guard (header `notElem` 
headers) >> (Just . unlines) [
     "missing header:"
   , formatHeader header
   ]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hspec-wai-0.6.6/src/Test/Hspec/Wai.hs 
new/hspec-wai-0.8.0/src/Test/Hspec/Wai.hs
--- old/hspec-wai-0.6.6/src/Test/Hspec/Wai.hs   2016-03-16 11:10:57.000000000 
+0100
+++ new/hspec-wai-0.8.0/src/Test/Hspec/Wai.hs   2016-10-08 08:21:00.000000000 
+0200
@@ -1,5 +1,6 @@
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE ConstraintKinds #-}
 -- | Have a look at the <https://github.com/hspec/hspec-wai#readme README> for
 -- an example of how to use this library.
 module Test.Hspec.Wai (
@@ -21,8 +22,11 @@
 
 -- * Matching on the response
 , shouldRespondWith
+
 , ResponseMatcher(..)
 , MatchHeader(..)
+, MatchBody(..)
+, Body
 , (<:>)
 
 -- * Helpers and re-exports
@@ -40,12 +44,11 @@
 import           Network.HTTP.Types
 import           Network.Wai.Test hiding (request)
 import qualified Network.Wai.Test as Wai
-import           Data.WithLocation
+import           Test.Hspec.Expectations
 
 import           Test.Hspec.Core.Spec hiding (pending, pendingWith)
 import qualified Test.Hspec.Core.Spec as Core
 import           Test.Hspec.Core.Hooks
-import           Test.Hspec.Expectations (expectationFailure)
 
 import           Test.Hspec.Wai.Util
 import           Test.Hspec.Wai.Internal
@@ -97,7 +100,7 @@
 --
 -- > get "/" `shouldRespondWith` "foo" {matchHeaders = ["Content-Type" <:> 
"text/plain"]}
 -- > -- matches if body is "foo", status is 200 and ther is a header field 
"Content-Type: text/plain"
-shouldRespondWith :: WithLocation (WaiSession SResponse -> ResponseMatcher -> 
WaiExpectation)
+shouldRespondWith :: HasCallStack => WaiSession SResponse -> ResponseMatcher 
-> WaiExpectation
 shouldRespondWith action matcher = do
   r <- action
   forM_ (match r matcher) (liftIO . expectationFailure)


Reply via email to