Skip to content

Commit

Permalink
Use only strict JSON check in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fizruk committed Dec 12, 2015
1 parent 29199e5 commit 6fb9665
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion test/Data/Swagger/SchemaSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
20 changes: 10 additions & 10 deletions test/Data/SwaggerSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions test/SpecCommon.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6fb9665

Please sign in to comment.