From 3047721447eb61490c68c7788771dbf45a81eaa6 Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Fri, 29 Sep 2017 11:45:13 -0400 Subject: [PATCH] Add Test coverage for Hash arguments Closes [#58]. The `match_response_schema` can be chained off `expect({ ... })` calls, so add test coverage to ensure that. [#58]: https://github.com/thoughtbot/json_matchers/pull/58 --- .../match_response_schema_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/json_matchers/match_response_schema_spec.rb b/spec/json_matchers/match_response_schema_spec.rb index a634d83..0fb35c0 100644 --- a/spec/json_matchers/match_response_schema_spec.rb +++ b/spec/json_matchers/match_response_schema_spec.rb @@ -22,6 +22,25 @@ expect(response_for({})).not_to match_response_schema("foo_schema") end + context "when passed a Hash" do + before(:each) do + create_schema("foo_schema", { + "type" => "object", + "required" => [ + "id", + ], + "properties" => { + "id" => { "type" => "number" }, + }, + "additionalProperties" => false, + }) + end + + it "validates when the schema matches" do + expect({ "id" => 1 }).to match_response_schema("foo_schema") + end + end + context "when JSON is a string" do before(:each) do create_schema("foo_schema", {