{"action":"opened","number":544,"pull_request":{"url":"https://api.github.com/repos/bblimke/webmock/pulls/544","id":49895127,"html_url":"https://github.com/bblimke/webmock/pull/544","diff_url":"https://github.com/bblimke/webmock/pull/544.diff","patch_url":"https://github.com/bblimke/webmock/pull/544.patch","issue_url":"https://api.github.com/repos/bblimke/webmock/issues/544","number":544,"state":"open","locked":false,"title":"Add RequestStub helper methods for accessing request signatures","user":{"login":"brettlangdon","id":1320353,"avatar_url":"https://avatars.githubusercontent.com/u/1320353?v=3","gravatar_id":"","url":"https://api.github.com/users/brettlangdon","html_url":"https://github.com/brettlangdon","followers_url":"https://api.github.com/users/brettlangdon/followers","following_url":"https://api.github.com/users/brettlangdon/following{/other_user}","gists_url":"https://api.github.com/users/brettlangdon/gists{/gist_id}","starred_url":"https://api.github.com/users/brettlangdon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brettlangdon/subscriptions","organizations_url":"https://api.github.com/users/brettlangdon/orgs","repos_url":"https://api.github.com/users/brettlangdon/repos","events_url":"https://api.github.com/users/brettlangdon/events{/privacy}","received_events_url":"https://api.github.com/users/brettlangdon/received_events","type":"User","site_admin":false},"body":"While working with `WebMock` we have found that we would like to be able to easily access the `WebMock::RequestSignature`s that correspond to a given `WebMock::RequestStub`.\r\n\r\nThe reason for this is so that we can have more generic stubs and then write our assertions in the tests against the requests that were made rather than building very specific stubs.\r\n\r\nThis PR adds in the following methods to `WebMock::RequestStub`:\r\n\r\n- `requests` - filter the requests in `WebMock::RequestRegistry` which match `@request_pattern`\r\n- `last_request` - the last request from `requests` (`requests[-1]`)\r\n- `first_request` - the first request from `requests` (`requests[0]`)\r\n\r\n\r\nThis allows us to write tests similar to the following:\r\n\r\n```ruby\r\nlet!(:stub) { WebMock::API.stub_request(:post, \"elasticsearch.url/people/person/_search\")\r\n                          .to_return(File.new(\"response.raw\")) }\r\n\r\nbefore(:example) do\r\n    visit(\"/endpoint\")\r\nend\r\n\r\nit \"properly queried elasticsearch\" do\r\n    request = stub.last_request\r\n    data = JSON.load(request.body)\r\n    expect(body[\"query\"]).to(eq(\"match_all\" => {}))\r\nend\r\n```\r\n\r\n\r\nAs we are still somewhat new to `WebMock` we are also open to suggestions on how we should be doing this.\r\n","created_at":"2015-11-05T23:14:49Z","updated_at":"2015-11-05T23:14:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bblimke/webmock/pulls/544/commits","review_comments_url":"https://api.github.com/repos/bblimke/webmock/pulls/544/comments","review_comment_url":"https://api.github.com/repos/bblimke/webmock/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bblimke/webmock/issues/544/comments","statuses_url":"https://api.github.com/repos/bblimke/webmock/statuses/4d9e6b5d7fc93a77748e45e1475e8dff2b0548b4","head":{"label":"underdogio:dev/access.requests.sqwished","ref":"dev/access.requests.sqwished","sha":"4d9e6b5d7fc93a77748e45e1475e8dff2b0548b4","user":{"login":"underdogio","id":7798128,"avatar_url":"https://avatars.githubusercontent.com/u/7798128?v=3","gravatar_id":"","url":"https://api.github.com/users/underdogio","html_url":"https://github.com/underdogio","followers_url":"https://api.github.com/users/underdogio/followers","following_url":"https://api.github.com/users/underdogio/following{/other_user}","gists_url":"https://api.github.com/users/underdogio/gists{/gist_id}","starred_url":"https://api.github.com/users/underdogio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/underdogio/subscriptions","organizations_url":"https://api.github.com/users/underdogio/orgs","repos_url":"https://api.github.com/users/underdogio/repos","events_url":"https://api.github.com/users/underdogio/events{/privacy}","received_events_url":"https://api.github.com/users/underdogio/received_events","type":"Organization","site_admin":false},"repo":{"id":45642106,"name":"webmock","full_name":"underdogio/webmock","owner":{"login":"underdogio","id":7798128,"avatar_url":"https://avatars.githubusercontent.com/u/7798128?v=3","gravatar_id":"","url":"https://api.github.com/users/underdogio","html_url":"https://github.com/underdogio","followers_url":"https://api.github.com/users/underdogio/followers","following_url":"https://api.github.com/users/underdogio/following{/other_user}","gists_url":"https://api.github.com/users/underdogio/gists{/gist_id}","starred_url":"https://api.github.com/users/underdogio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/underdogio/subscriptions","organizations_url":"https://api.github.com/users/underdogio/orgs","repos_url":"https://api.github.com/users/underdogio/repos","events_url":"https://api.github.com/users/underdogio/events{/privacy}","received_events_url":"https://api.github.com/users/underdogio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/underdogio/webmock","description":"Library for stubbing and setting expectations on HTTP requests in Ruby.","fork":true,"url":"https://api.github.com/repos/underdogio/webmock","forks_url":"https://api.github.com/repos/underdogio/webmock/forks","keys_url":"https://api.github.com/repos/underdogio/webmock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/underdogio/webmock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/underdogio/webmock/teams","hooks_url":"https://api.github.com/repos/underdogio/webmock/hooks","issue_events_url":"https://api.github.com/repos/underdogio/webmock/issues/events{/number}","events_url":"https://api.github.com/repos/underdogio/webmock/events","assignees_url":"https://api.github.com/repos/underdogio/webmock/assignees{/user}","branches_url":"https://api.github.com/repos/underdogio/webmock/branches{/branch}","tags_url":"https://api.github.com/repos/underdogio/webmock/tags","blobs_url":"https://api.github.com/repos/underdogio/webmock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/underdogio/webmock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/underdogio/webmock/git/refs{/sha}","trees_url":"https://api.github.com/repos/underdogio/webmock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/underdogio/webmock/statuses/{sha}","languages_url":"https://api.github.com/repos/underdogio/webmock/languages","stargazers_url":"https://api.github.com/repos/underdogio/webmock/stargazers","contributors_url":"https://api.github.com/repos/underdogio/webmock/contributors","subscribers_url":"https://api.github.com/repos/underdogio/webmock/subscribers","subscription_url":"https://api.github.com/repos/underdogio/webmock/subscription","commits_url":"https://api.github.com/repos/underdogio/webmock/commits{/sha}","git_commits_url":"https://api.github.com/repos/underdogio/webmock/git/commits{/sha}","comments_url":"https://api.github.com/repos/underdogio/webmock/comments{/number}","issue_comment_url":"https://api.github.com/repos/underdogio/webmock/issues/comments{/number}","contents_url":"https://api.github.com/repos/underdogio/webmock/contents/{+path}","compare_url":"https://api.github.com/repos/underdogio/webmock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/underdogio/webmock/merges","archive_url":"https://api.github.com/repos/underdogio/webmock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/underdogio/webmock/downloads","issues_url":"https://api.github.com/repos/underdogio/webmock/issues{/number}","pulls_url":"https://api.github.com/repos/underdogio/webmock/pulls{/number}","milestones_url":"https://api.github.com/repos/underdogio/webmock/milestones{/number}","notifications_url":"https://api.github.com/repos/underdogio/webmock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/underdogio/webmock/labels{/name}","releases_url":"https://api.github.com/repos/underdogio/webmock/releases{/id}","created_at":"2015-11-05T21:59:05Z","updated_at":"2015-11-05T21:59:06Z","pushed_at":"2015-11-05T22:54:11Z","git_url":"git://github.com/underdogio/webmock.git","ssh_url":"git@github.com:underdogio/webmock.git","clone_url":"https://github.com/underdogio/webmock.git","svn_url":"https://github.com/underdogio/webmock","homepage":"","size":3815,"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":"bblimke:master","ref":"master","sha":"4d40934217e81fa53e1de798d6a622136d582d4d","user":{"login":"bblimke","id":15547,"avatar_url":"https://avatars.githubusercontent.com/u/15547?v=3","gravatar_id":"","url":"https://api.github.com/users/bblimke","html_url":"https://github.com/bblimke","followers_url":"https://api.github.com/users/bblimke/followers","following_url":"https://api.github.com/users/bblimke/following{/other_user}","gists_url":"https://api.github.com/users/bblimke/gists{/gist_id}","starred_url":"https://api.github.com/users/bblimke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bblimke/subscriptions","organizations_url":"https://api.github.com/users/bblimke/orgs","repos_url":"https://api.github.com/users/bblimke/repos","events_url":"https://api.github.com/users/bblimke/events{/privacy}","received_events_url":"https://api.github.com/users/bblimke/received_events","type":"User","site_admin":false},"repo":{"id":363163,"name":"webmock","full_name":"bblimke/webmock","owner":{"login":"bblimke","id":15547,"avatar_url":"https://avatars.githubusercontent.com/u/15547?v=3","gravatar_id":"","url":"https://api.github.com/users/bblimke","html_url":"https://github.com/bblimke","followers_url":"https://api.github.com/users/bblimke/followers","following_url":"https://api.github.com/users/bblimke/following{/other_user}","gists_url":"https://api.github.com/users/bblimke/gists{/gist_id}","starred_url":"https://api.github.com/users/bblimke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bblimke/subscriptions","organizations_url":"https://api.github.com/users/bblimke/orgs","repos_url":"https://api.github.com/users/bblimke/repos","events_url":"https://api.github.com/users/bblimke/events{/privacy}","received_events_url":"https://api.github.com/users/bblimke/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bblimke/webmock","description":"Library for stubbing and setting expectations on HTTP requests in Ruby.","fork":false,"url":"https://api.github.com/repos/bblimke/webmock","forks_url":"https://api.github.com/repos/bblimke/webmock/forks","keys_url":"https://api.github.com/repos/bblimke/webmock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bblimke/webmock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bblimke/webmock/teams","hooks_url":"https://api.github.com/repos/bblimke/webmock/hooks","issue_events_url":"https://api.github.com/repos/bblimke/webmock/issues/events{/number}","events_url":"https://api.github.com/repos/bblimke/webmock/events","assignees_url":"https://api.github.com/repos/bblimke/webmock/assignees{/user}","branches_url":"https://api.github.com/repos/bblimke/webmock/branches{/branch}","tags_url":"https://api.github.com/repos/bblimke/webmock/tags","blobs_url":"https://api.github.com/repos/bblimke/webmock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bblimke/webmock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bblimke/webmock/git/refs{/sha}","trees_url":"https://api.github.com/repos/bblimke/webmock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bblimke/webmock/statuses/{sha}","languages_url":"https://api.github.com/repos/bblimke/webmock/languages","stargazers_url":"https://api.github.com/repos/bblimke/webmock/stargazers","contributors_url":"https://api.github.com/repos/bblimke/webmock/contributors","subscribers_url":"https://api.github.com/repos/bblimke/webmock/subscribers","subscription_url":"https://api.github.com/repos/bblimke/webmock/subscription","commits_url":"https://api.github.com/repos/bblimke/webmock/commits{/sha}","git_commits_url":"https://api.github.com/repos/bblimke/webmock/git/commits{/sha}","comments_url":"https://api.github.com/repos/bblimke/webmock/comments{/number}","issue_comment_url":"https://api.github.com/repos/bblimke/webmock/issues/comments{/number}","contents_url":"https://api.github.com/repos/bblimke/webmock/contents/{+path}","compare_url":"https://api.github.com/repos/bblimke/webmock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bblimke/webmock/merges","archive_url":"https://api.github.com/repos/bblimke/webmock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bblimke/webmock/downloads","issues_url":"https://api.github.com/repos/bblimke/webmock/issues{/number}","pulls_url":"https://api.github.com/repos/bblimke/webmock/pulls{/number}","milestones_url":"https://api.github.com/repos/bblimke/webmock/milestones{/number}","notifications_url":"https://api.github.com/repos/bblimke/webmock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bblimke/webmock/labels{/name}","releases_url":"https://api.github.com/repos/bblimke/webmock/releases{/id}","created_at":"2009-11-06T10:37:29Z","updated_at":"2015-11-05T17:34:31Z","pushed_at":"2015-11-05T14:07:49Z","git_url":"git://github.com/bblimke/webmock.git","ssh_url":"git@github.com:bblimke/webmock.git","clone_url":"https://github.com/bblimke/webmock.git","svn_url":"https://github.com/bblimke/webmock","homepage":"","size":3815,"stargazers_count":1946,"watchers_count":1946,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":282,"mirror_url":null,"open_issues_count":48,"forks":282,"open_issues":48,"watchers":1946,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bblimke/webmock/pulls/544"},"html":{"href":"https://github.com/bblimke/webmock/pull/544"},"issue":{"href":"https://api.github.com/repos/bblimke/webmock/issues/544"},"comments":{"href":"https://api.github.com/repos/bblimke/webmock/issues/544/comments"},"review_comments":{"href":"https://api.github.com/repos/bblimke/webmock/pulls/544/comments"},"review_comment":{"href":"https://api.github.com/repos/bblimke/webmock/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bblimke/webmock/pulls/544/commits"},"statuses":{"href":"https://api.github.com/repos/bblimke/webmock/statuses/4d9e6b5d7fc93a77748e45e1475e8dff2b0548b4"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":79,"deletions":0,"changed_files":2}}