From 6fb96650cd2e254c92e19212fa0058b477214250 Mon Sep 17 00:00:00 2001 From: Nickolay Kudasov Date: Sat, 12 Dec 2015 14:04:12 +0300 Subject: [PATCH] Use only strict JSON check in tests --- test/Data/Swagger/SchemaSpec.hs | 2 +- test/Data/SwaggerSpec.hs | 20 ++++++++++---------- test/SpecCommon.hs | 7 ------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/test/Data/Swagger/SchemaSpec.hs b/test/Data/Swagger/SchemaSpec.hs index d4d3110..e74b2df 100644 --- a/test/Data/Swagger/SchemaSpec.hs +++ b/test/Data/Swagger/SchemaSpec.hs @@ -23,7 +23,7 @@ import SpecCommon import Test.Hspec checkToSchema :: ToSchema a => Proxy a -> Value -> Spec -checkToSchema proxy js = toSchema proxy <~> js +checkToSchema proxy js = toSchema proxy <=> js checkSchemaName :: ToSchema a => Maybe String -> Proxy a -> Spec checkSchemaName sname proxy = diff --git a/test/Data/SwaggerSpec.hs b/test/Data/SwaggerSpec.hs index 0501e0f..8681bee 100644 --- a/test/Data/SwaggerSpec.hs +++ b/test/Data/SwaggerSpec.hs @@ -21,18 +21,18 @@ spec = do describe "License Object" $ licenseExample <=> licenseExampleJSON describe "Contact Object" $ contactExample <=> contactExampleJSON describe "Info Object" $ infoExample <=> infoExampleJSON - describe "Operation Object" $ operationExample <~> operationExampleJSON + describe "Operation Object" $ operationExample <=> operationExampleJSON describe "Schema Object" $ do - context "Primitive Sample" $ schemaPrimitiveExample <~> schemaPrimitiveExampleJSON - context "Simple Model" $ schemaSimpleModelExample <~> schemaSimpleModelExampleJSON - context "Model with Map/Dictionary Properties" $ schemaModelDictExample <~> schemaModelDictExampleJSON - context "Model with Example" $ schemaWithExampleExample <~> schemaWithExampleExampleJSON - describe "Definitions Object" $ definitionsExample <~> definitionsExampleJSON - describe "Parameters Definition Object" $ paramsDefinitionExample <~> paramsDefinitionExampleJSON - describe "Responses Definition Object" $ responsesDefinitionExample <~> responsesDefinitionExampleJSON - describe "Security Definitions Object" $ securityDefinitionsExample <~> securityDefinitionsExampleJSON + context "Primitive Sample" $ schemaPrimitiveExample <=> schemaPrimitiveExampleJSON + context "Simple Model" $ schemaSimpleModelExample <=> schemaSimpleModelExampleJSON + context "Model with Map/Dictionary Properties" $ schemaModelDictExample <=> schemaModelDictExampleJSON + context "Model with Example" $ schemaWithExampleExample <=> schemaWithExampleExampleJSON + describe "Definitions Object" $ definitionsExample <=> definitionsExampleJSON + describe "Parameters Definition Object" $ paramsDefinitionExample <=> paramsDefinitionExampleJSON + describe "Responses Definition Object" $ responsesDefinitionExample <=> responsesDefinitionExampleJSON + describe "Security Definitions Object" $ securityDefinitionsExample <=> securityDefinitionsExampleJSON describe "Swagger Object" $ do - context "Todo Example" $ swaggerExample <~> swaggerExampleJSON + context "Todo Example" $ swaggerExample <=> swaggerExampleJSON context "PetStore Example" $ it "decodes successfully" $ do fromJSON petstoreExampleJSON `shouldSatisfy` (\x -> case x of Success (_ :: Swagger) -> True; _ -> False) diff --git a/test/SpecCommon.hs b/test/SpecCommon.hs index 3aa6494..368285c 100644 --- a/test/SpecCommon.hs +++ b/test/SpecCommon.hs @@ -15,13 +15,6 @@ isSubJSON (Object x) (Object y) = HashMap.keys x == HashMap.keys i && F.and i isSubJSON (Array xs) (Array ys) = Vector.length xs == Vector.length ys && F.and (Vector.zipWith isSubJSON xs ys) isSubJSON x y = x == y -(<~>) :: (Eq a, Show a, ToJSON a, FromJSON a) => a -> Value -> Spec -x <~> js = do - it "encodes correctly (probably with extra properties)" $ do - toJSON x `shouldSatisfy` (js `isSubJSON`) - it "decodes correctly" $ do - fromJSON js `shouldBe` Success x - (<=>) :: (Eq a, Show a, ToJSON a, FromJSON a) => a -> Value -> Spec x <=> js = do it "encodes correctly" $ do