packages feed

hspec-wai-json 0.7.0 → 0.8.0

raw patch · 3 files changed

+7/−36 lines, 3 filesdep ~hspec-waiPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: hspec-wai

API changes (from Hackage documentation)

Files

hspec-wai-json.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack  name:             hspec-wai-json-version:          0.7.0+version:          0.8.0 homepage:         https://github.com/hspec/hspec-wai#readme bug-reports:      https://github.com/hspec/hspec-wai/issues license:          MIT@@ -31,7 +31,7 @@       Test.Hspec.Wai.JSON   build-depends:       base == 4.*-    , hspec-wai == 0.7.*+    , hspec-wai == 0.8.0     , bytestring     , template-haskell     , aeson
src/Test/Hspec/Wai/JSON.hs view
@@ -5,17 +5,12 @@ , FromValue(..) ) where -import           Control.Arrow (second)-import           Data.List import           Data.ByteString.Lazy (ByteString)-import qualified Data.ByteString.Lazy as BL import           Data.Aeson (Value, decode, encode) import           Data.Aeson.QQ-import qualified Data.CaseInsensitive as CI import           Language.Haskell.TH.Quote  import           Test.Hspec.Wai-import           Test.Hspec.Wai.Internal (formatHeader) import           Test.Hspec.Wai.Matcher  -- $setup@@ -57,15 +52,7 @@   fromValue :: Value -> a  instance FromValue ResponseMatcher where-  fromValue = ResponseMatcher 200 [MatchHeader p] . equalsJSON-    where-      p headers body = if any (`elem` mkCI permissibleHeaders) (mkCI headers)-        then Nothing-        else (Just . unlines) ("missing header:" : (intersperse "  OR" $ map formatHeader permissibleHeaders))-        where-          mkCI = map (second CI.mk)-          permissibleHeaders = addIfASCII ("Content-Type", "application/json") [("Content-Type", "application/json; charset=utf-8")]-          addIfASCII h = if BL.all (< 128) body then (h :) else id+  fromValue = ResponseMatcher 200 ["Content-Type" <:> "application/json"] . equalsJSON  equalsJSON :: Value -> MatchBody equalsJSON expected = MatchBody matcher
test/Test/Hspec/Wai/JSONSpec.hs view
@@ -45,29 +45,13 @@           match [("Content-Type", "application/json")] `shouldBe` Nothing          it "accepts 'application/json; charset=utf-8'" $ do-          match [("Content-Type", "application/json; charset=utf-8")] `shouldBe` Nothing--        it "ignores case" $ do-          match [("Content-Type", "application/JSON; charset=UTF-8")] `shouldBe` Nothing--        it "rejects other headers" $ do-          match [("Content-Type", "foobar")] `shouldBe` (Just . unlines) [+          match [("Content-Type", "application/json; charset=utf-8")] `shouldBe` (Just . unlines) [               "missing header:"             , "  Content-Type: application/json"-            , "  OR"-            , "  Content-Type: application/json; charset=utf-8"             ] -      context "when body is UTF-8" $ do-        let-          body = [json|{foo: #{"\955" :: String}}|]-          match = (`matcher` body)--        it "rejects 'application/json'" $ do-          match [("Content-Type", "application/json")] `shouldBe` (Just . unlines) [+        it "rejects other headers" $ do+          match [("Content-Type", "foobar")] `shouldBe` (Just . unlines) [               "missing header:"-            , "  Content-Type: application/json; charset=utf-8"+            , "  Content-Type: application/json"             ]--        it "accepts 'application/json; charset=utf-8'" $ do-          match [("Content-Type", "application/json; charset=utf-8")] `shouldBe` Nothing