{"action":"created","comment":{"url":"https://api.github.com/repos/thoughtbot/json_matchers/pulls/comments/75246838","id":75246838,"diff_hunk":"@@ -0,0 +1,116 @@\n+RSpec.shared_examples 'schema_matcher' do\n+  it \"fails with an invalid JSON body\" do\n+    create_schema(\"foo\", \"\")\n+\n+    expect {\n+      expect(send(file_helper, \"\")).to send(described_matcher, \"foo\")\n+    }.to raise_error(JsonMatchers::InvalidSchemaError)\n+  end\n+\n+  it \"does not fail with an empty JSON body\" do\n+    create_schema(\"foo\", {})\n+\n+    expect(send(file_helper, {})).to send(described_matcher, \"foo\")\n+  end\n+\n+  it \"fails when the body is missing a required property\" do\n+    create_schema(\"foo_schema\", {\n+      \"type\" => \"object\",\n+      \"required\" => [\"foo\"],\n+    })\n+\n+    expect(send(file_helper, {})).not_to send(described_matcher, \"foo_schema\")\n+  end\n+\n+  it \"accepts options for the validator\" do\n+    create_schema(\"foo_schema\", {\n+      \"type\" => \"object\",\n+      \"required\" => [\n+        \"id\",\n+      ],\n+      \"properties\" => {\n+        \"id\" => { \"type\" => \"number\" },\n+        \"title\" => {\"type\" => \"string\"},\n+      },\n+      \"additionalProperties\" => false,\n+    })\n+\n+    expect(send(file_helper, { \"id\" => 1, \"title\" => \"bar\" })).\n+      to send(described_matcher, \"foo_schema\", strict: false)\n+  end\n+\n+  it \"fails when the body contains a property with the wrong type\" do\n+    create_schema(\"foo_schema\", {\n+      \"type\" => \"object\",\n+      \"properties\" => {\n+        \"foo\" => { \"type\" => \"string\" },\n+      }\n+    })\n+\n+    expect(send(file_helper, \"foo\" => 1)).\n+      not_to send(described_matcher, \"foo_schema\")\n+  end\n+\n+  it \"contains the body in the failure message\" do\n+    create_schema(\"foo\", { \"type\" => \"array\" })\n+\n+    expect {\n+      expect(send(file_helper, \"bar\" => 5)).to send(described_matcher, \"foo\")\n+    }.to raise_error(/{\"bar\":5}/)\n+  end\n+\n+  it \"contains the body in the failure message when negated\" do\n+    create_schema(\"foo\", { \"type\" => \"array\" })\n+\n+    expect {\n+      expect(send(file_helper, [])).not_to send(described_matcher, \"foo\")\n+    }.to raise_error(/\\[\\]/)\n+  end\n+\n+  it \"contains the schema in the failure message\" do\n+    schema = { \"type\" => \"array\" }\n+    create_schema(\"foo\", schema)\n+\n+    expect {\n+      expect(send(file_helper, \"bar\" => 5)).to send(described_matcher, \"foo\")\n+    }.to raise_error(/#{schema.to_json}/)\n+  end\n+\n+  it \"contains the schema in the failure message when negated\" do\n+    schema = { \"type\" => \"array\" }\n+    create_schema(\"foo\", schema)\n+\n+    expect {\n+      expect(send(file_helper, [])).not_to send(described_matcher, \"foo\")\n+    }.to raise_error(/#{schema.to_json}/)\n+  end\n+\n+  it \"does not fail when the schema matches\" do\n+    create_schema(\"array_schema\", {\n+      \"type\" => \"array\",\n+      \"items\" => { \"type\" => \"string\" },\n+    })\n+\n+    expect(send(file_helper, [\"valid\"])).to send(described_matcher, \"array_schema\")\n+  end\n+\n+  it \"supports $ref\" do\n+    create_schema(\"single\", {\n+      \"type\" => \"object\",","path":"spec/support/schema_matcher_shared_example.rb","position":99,"original_position":99,"commit_id":"7a99ca98ffbbc493bcd864c772efd7322656e80a","original_commit_id":"7a99ca98ffbbc493bcd864c772efd7322656e80a","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis.","created_at":"2016-08-18T04:17:24Z","updated_at":"2016-08-18T04:17:24Z","html_url":"https://github.com/thoughtbot/json_matchers/pull/41#discussion_r75246838","pull_request_url":"https://api.github.com/repos/thoughtbot/json_matchers/pulls/41","_links":{"self":{"href":"https://api.github.com/repos/thoughtbot/json_matchers/pulls/comments/75246838"},"html":{"href":"https://github.com/thoughtbot/json_matchers/pull/41#discussion_r75246838"},"pull_request":{"href":"https://api.github.com/repos/thoughtbot/json_matchers/pulls/41"}}},"pull_request":{"url":"https://api.github.com/repos/thoughtbot/json_matchers/pulls/41","id":81754819,"html_url":"https://github.com/thoughtbot/json_matchers/pull/41","diff_url":"https://github.com/thoughtbot/json_matchers/pull/41.diff","patch_url":"https://github.com/thoughtbot/json_matchers/pull/41.patch","issue_url":"https://api.github.com/repos/thoughtbot/json_matchers/issues/41","number":41,"state":"open","locked":false,"title":"Feature Request - match_json_schema matcher","user":{"login":"wayne5540","id":1673631,"avatar_url":"https://avatars.githubusercontent.com/u/1673631?v=3","gravatar_id":"","url":"https://api.github.com/users/wayne5540","html_url":"https://github.com/wayne5540","followers_url":"https://api.github.com/users/wayne5540/followers","following_url":"https://api.github.com/users/wayne5540/following{/other_user}","gists_url":"https://api.github.com/users/wayne5540/gists{/gist_id}","starred_url":"https://api.github.com/users/wayne5540/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wayne5540/subscriptions","organizations_url":"https://api.github.com/users/wayne5540/orgs","repos_url":"https://api.github.com/users/wayne5540/repos","events_url":"https://api.github.com/users/wayne5540/events{/privacy}","received_events_url":"https://api.github.com/users/wayne5540/received_events","type":"User","site_admin":false},"body":"Hi, thanks for all hard works to make this gem, it's really helpful. I have a feature request and want to discuss, created a PR to describe the feature to see if this make sense :) \r\n\r\n## Requested feature and reason\r\nSometimes I only want to test nested object like `JSON(response.body)['nested_object']`, I think it's more flexible to not using `response.body` but just JSON-string at `JsonMatchers::Matcher#matches?`.\r\n\r\nAnyone thinks it's a good idea to support this? Or having a better idea how to approach this? Willing to have discussion, thanks 😸 \r\n\r\n## Usage\r\n```ruby\r\n# spec/requests/posts_spec.rb\r\n\r\ndescribe \"GET /posts\" do\r\n  it \"returns Posts\" do\r\n    get posts_path, format: :json\r\n\r\n    expect(response.status).to eq 200\r\n    expect(response.body).to match_json_schema(\"posts\")\r\n  end\r\nend\r\n```","created_at":"2016-08-18T04:17:19Z","updated_at":"2016-08-18T04:17:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5bdca24783be86d2c28ae430fecc6e2431f93a52","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/thoughtbot/json_matchers/pulls/41/commits","review_comments_url":"https://api.github.com/repos/thoughtbot/json_matchers/pulls/41/comments","review_comment_url":"https://api.github.com/repos/thoughtbot/json_matchers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/thoughtbot/json_matchers/issues/41/comments","statuses_url":"https://api.github.com/repos/thoughtbot/json_matchers/statuses/7a99ca98ffbbc493bcd864c772efd7322656e80a","head":{"label":"wayne5540:match_json_schema","ref":"match_json_schema","sha":"7a99ca98ffbbc493bcd864c772efd7322656e80a","user":{"login":"wayne5540","id":1673631,"avatar_url":"https://avatars.githubusercontent.com/u/1673631?v=3","gravatar_id":"","url":"https://api.github.com/users/wayne5540","html_url":"https://github.com/wayne5540","followers_url":"https://api.github.com/users/wayne5540/followers","following_url":"https://api.github.com/users/wayne5540/following{/other_user}","gists_url":"https://api.github.com/users/wayne5540/gists{/gist_id}","starred_url":"https://api.github.com/users/wayne5540/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wayne5540/subscriptions","organizations_url":"https://api.github.com/users/wayne5540/orgs","repos_url":"https://api.github.com/users/wayne5540/repos","events_url":"https://api.github.com/users/wayne5540/events{/privacy}","received_events_url":"https://api.github.com/users/wayne5540/received_events","type":"User","site_admin":false},"repo":{"id":65953456,"name":"json_matchers","full_name":"wayne5540/json_matchers","owner":{"login":"wayne5540","id":1673631,"avatar_url":"https://avatars.githubusercontent.com/u/1673631?v=3","gravatar_id":"","url":"https://api.github.com/users/wayne5540","html_url":"https://github.com/wayne5540","followers_url":"https://api.github.com/users/wayne5540/followers","following_url":"https://api.github.com/users/wayne5540/following{/other_user}","gists_url":"https://api.github.com/users/wayne5540/gists{/gist_id}","starred_url":"https://api.github.com/users/wayne5540/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wayne5540/subscriptions","organizations_url":"https://api.github.com/users/wayne5540/orgs","repos_url":"https://api.github.com/users/wayne5540/repos","events_url":"https://api.github.com/users/wayne5540/events{/privacy}","received_events_url":"https://api.github.com/users/wayne5540/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wayne5540/json_matchers","description":"Validate your JSON APIs","fork":true,"url":"https://api.github.com/repos/wayne5540/json_matchers","forks_url":"https://api.github.com/repos/wayne5540/json_matchers/forks","keys_url":"https://api.github.com/repos/wayne5540/json_matchers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wayne5540/json_matchers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wayne5540/json_matchers/teams","hooks_url":"https://api.github.com/repos/wayne5540/json_matchers/hooks","issue_events_url":"https://api.github.com/repos/wayne5540/json_matchers/issues/events{/number}","events_url":"https://api.github.com/repos/wayne5540/json_matchers/events","assignees_url":"https://api.github.com/repos/wayne5540/json_matchers/assignees{/user}","branches_url":"https://api.github.com/repos/wayne5540/json_matchers/branches{/branch}","tags_url":"https://api.github.com/repos/wayne5540/json_matchers/tags","blobs_url":"https://api.github.com/repos/wayne5540/json_matchers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wayne5540/json_matchers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wayne5540/json_matchers/git/refs{/sha}","trees_url":"https://api.github.com/repos/wayne5540/json_matchers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wayne5540/json_matchers/statuses/{sha}","languages_url":"https://api.github.com/repos/wayne5540/json_matchers/languages","stargazers_url":"https://api.github.com/repos/wayne5540/json_matchers/stargazers","contributors_url":"https://api.github.com/repos/wayne5540/json_matchers/contributors","subscribers_url":"https://api.github.com/repos/wayne5540/json_matchers/subscribers","subscription_url":"https://api.github.com/repos/wayne5540/json_matchers/subscription","commits_url":"https://api.github.com/repos/wayne5540/json_matchers/commits{/sha}","git_commits_url":"https://api.github.com/repos/wayne5540/json_matchers/git/commits{/sha}","comments_url":"https://api.github.com/repos/wayne5540/json_matchers/comments{/number}","issue_comment_url":"https://api.github.com/repos/wayne5540/json_matchers/issues/comments{/number}","contents_url":"https://api.github.com/repos/wayne5540/json_matchers/contents/{+path}","compare_url":"https://api.github.com/repos/wayne5540/json_matchers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wayne5540/json_matchers/merges","archive_url":"https://api.github.com/repos/wayne5540/json_matchers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wayne5540/json_matchers/downloads","issues_url":"https://api.github.com/repos/wayne5540/json_matchers/issues{/number}","pulls_url":"https://api.github.com/repos/wayne5540/json_matchers/pulls{/number}","milestones_url":"https://api.github.com/repos/wayne5540/json_matchers/milestones{/number}","notifications_url":"https://api.github.com/repos/wayne5540/json_matchers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wayne5540/json_matchers/labels{/name}","releases_url":"https://api.github.com/repos/wayne5540/json_matchers/releases{/id}","deployments_url":"https://api.github.com/repos/wayne5540/json_matchers/deployments","created_at":"2016-08-18T01:07:12Z","updated_at":"2016-08-18T01:07:12Z","pushed_at":"2016-08-18T04:12:15Z","git_url":"git://github.com/wayne5540/json_matchers.git","ssh_url":"git@github.com:wayne5540/json_matchers.git","clone_url":"https://github.com/wayne5540/json_matchers.git","svn_url":"https://github.com/wayne5540/json_matchers","homepage":"","size":70,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"thoughtbot:master","ref":"master","sha":"757832e4549a8fde6c13c6d0f6e0d23a358c592d","user":{"login":"thoughtbot","id":6183,"avatar_url":"https://avatars.githubusercontent.com/u/6183?v=3","gravatar_id":"","url":"https://api.github.com/users/thoughtbot","html_url":"https://github.com/thoughtbot","followers_url":"https://api.github.com/users/thoughtbot/followers","following_url":"https://api.github.com/users/thoughtbot/following{/other_user}","gists_url":"https://api.github.com/users/thoughtbot/gists{/gist_id}","starred_url":"https://api.github.com/users/thoughtbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thoughtbot/subscriptions","organizations_url":"https://api.github.com/users/thoughtbot/orgs","repos_url":"https://api.github.com/users/thoughtbot/repos","events_url":"https://api.github.com/users/thoughtbot/events{/privacy}","received_events_url":"https://api.github.com/users/thoughtbot/received_events","type":"Organization","site_admin":false},"repo":{"id":25044521,"name":"json_matchers","full_name":"thoughtbot/json_matchers","owner":{"login":"thoughtbot","id":6183,"avatar_url":"https://avatars.githubusercontent.com/u/6183?v=3","gravatar_id":"","url":"https://api.github.com/users/thoughtbot","html_url":"https://github.com/thoughtbot","followers_url":"https://api.github.com/users/thoughtbot/followers","following_url":"https://api.github.com/users/thoughtbot/following{/other_user}","gists_url":"https://api.github.com/users/thoughtbot/gists{/gist_id}","starred_url":"https://api.github.com/users/thoughtbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thoughtbot/subscriptions","organizations_url":"https://api.github.com/users/thoughtbot/orgs","repos_url":"https://api.github.com/users/thoughtbot/repos","events_url":"https://api.github.com/users/thoughtbot/events{/privacy}","received_events_url":"https://api.github.com/users/thoughtbot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thoughtbot/json_matchers","description":"Validate your JSON APIs","fork":false,"url":"https://api.github.com/repos/thoughtbot/json_matchers","forks_url":"https://api.github.com/repos/thoughtbot/json_matchers/forks","keys_url":"https://api.github.com/repos/thoughtbot/json_matchers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thoughtbot/json_matchers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thoughtbot/json_matchers/teams","hooks_url":"https://api.github.com/repos/thoughtbot/json_matchers/hooks","issue_events_url":"https://api.github.com/repos/thoughtbot/json_matchers/issues/events{/number}","events_url":"https://api.github.com/repos/thoughtbot/json_matchers/events","assignees_url":"https://api.github.com/repos/thoughtbot/json_matchers/assignees{/user}","branches_url":"https://api.github.com/repos/thoughtbot/json_matchers/branches{/branch}","tags_url":"https://api.github.com/repos/thoughtbot/json_matchers/tags","blobs_url":"https://api.github.com/repos/thoughtbot/json_matchers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thoughtbot/json_matchers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thoughtbot/json_matchers/git/refs{/sha}","trees_url":"https://api.github.com/repos/thoughtbot/json_matchers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thoughtbot/json_matchers/statuses/{sha}","languages_url":"https://api.github.com/repos/thoughtbot/json_matchers/languages","stargazers_url":"https://api.github.com/repos/thoughtbot/json_matchers/stargazers","contributors_url":"https://api.github.com/repos/thoughtbot/json_matchers/contributors","subscribers_url":"https://api.github.com/repos/thoughtbot/json_matchers/subscribers","subscription_url":"https://api.github.com/repos/thoughtbot/json_matchers/subscription","commits_url":"https://api.github.com/repos/thoughtbot/json_matchers/commits{/sha}","git_commits_url":"https://api.github.com/repos/thoughtbot/json_matchers/git/commits{/sha}","comments_url":"https://api.github.com/repos/thoughtbot/json_matchers/comments{/number}","issue_comment_url":"https://api.github.com/repos/thoughtbot/json_matchers/issues/comments{/number}","contents_url":"https://api.github.com/repos/thoughtbot/json_matchers/contents/{+path}","compare_url":"https://api.github.com/repos/thoughtbot/json_matchers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thoughtbot/json_matchers/merges","archive_url":"https://api.github.com/repos/thoughtbot/json_matchers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thoughtbot/json_matchers/downloads","issues_url":"https://api.github.com/repos/thoughtbot/json_matchers/issues{/number}","pulls_url":"https://api.github.com/repos/thoughtbot/json_matchers/pulls{/number}","milestones_url":"https://api.github.com/repos/thoughtbot/json_matchers/milestones{/number}","notifications_url":"https://api.github.com/repos/thoughtbot/json_matchers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thoughtbot/json_matchers/labels{/name}","releases_url":"https://api.github.com/repos/thoughtbot/json_matchers/releases{/id}","deployments_url":"https://api.github.com/repos/thoughtbot/json_matchers/deployments","created_at":"2014-10-10T16:51:29Z","updated_at":"2016-08-12T01:01:38Z","pushed_at":"2016-08-18T04:17:21Z","git_url":"git://github.com/thoughtbot/json_matchers.git","ssh_url":"git@github.com:thoughtbot/json_matchers.git","clone_url":"https://github.com/thoughtbot/json_matchers.git","svn_url":"https://github.com/thoughtbot/json_matchers","homepage":"","size":70,"stargazers_count":88,"watchers_count":88,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":12,"forks":14,"open_issues":12,"watchers":88,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/thoughtbot/json_matchers/pulls/41"},"html":{"href":"https://github.com/thoughtbot/json_matchers/pull/41"},"issue":{"href":"https://api.github.com/repos/thoughtbot/json_matchers/issues/41"},"comments":{"href":"https://api.github.com/repos/thoughtbot/json_matchers/issues/41/comments"},"review_comments":{"href":"https://api.github.com/repos/thoughtbot/json_matchers/pulls/41/comments"},"review_comment":{"href":"https://api.github.com/repos/thoughtbot/json_matchers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/thoughtbot/json_matchers/pulls/41/commits"},"statuses":{"href":"https://api.github.com/repos/thoughtbot/json_matchers/statuses/7a99ca98ffbbc493bcd864c772efd7322656e80a"}}}}
{"actor":{"display_login":"houndci-bot"}}