{"action":"created","comment":{"url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/pulls/comments/240013338","pull_request_review_id":182953623,"id":240013338,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MDAxMzMzOA==","diff_hunk":"@@ -143,4 +143,28 @@ describe('icedfrisby-nock', function() {\n       .expectStatus(599)\n       .toss()\n   })\n+\n+  describe('conditional intercept', function () {\n+    it('sets up a mock which works correctly if condition true', function () {\n+      frisby.create(this.test.title)\n+        .post('http://example.com/test')\n+        .conditionalIntercept(true, nock => nock('http://example.com')\n+          .post('/test')\n+          .reply(418, { someKey: 'someValue' }))\n+        .expectStatus(418)\n+        .expectJSON({ someKey: 'someValue' })\n+        .toss()\n+    })\n+\n+    it('does not set up a mock if condition false', function () {\n+      frisby.create(this.test.title)\n+        .get('http://httpbin.org')\n+        .conditionalIntercept(false, nock => nock('http://httpbin.org')\n+          .get('/')\n+          .reply(418, { someKey: 'someValue' }))\n+        .expectStatus(200)\n+        .toss()","path":"icedfrisby-nock.spec.js","position":24,"original_position":24,"commit_id":"fac4dc7ce65664acf4152f8fe4c34c8512a6e33f","original_commit_id":"fac4dc7ce65664acf4152f8fe4c34c8512a6e33f","user":{"login":"paulmelnikow","id":1487036,"node_id":"MDQ6VXNlcjE0ODcwMzY=","avatar_url":"https://avatars2.githubusercontent.com/u/1487036?v=4","gravatar_id":"","url":"https://api.github.com/users/paulmelnikow","html_url":"https://github.com/paulmelnikow","followers_url":"https://api.github.com/users/paulmelnikow/followers","following_url":"https://api.github.com/users/paulmelnikow/following{/other_user}","gists_url":"https://api.github.com/users/paulmelnikow/gists{/gist_id}","starred_url":"https://api.github.com/users/paulmelnikow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulmelnikow/subscriptions","organizations_url":"https://api.github.com/users/paulmelnikow/orgs","repos_url":"https://api.github.com/users/paulmelnikow/repos","events_url":"https://api.github.com/users/paulmelnikow/events{/privacy}","received_events_url":"https://api.github.com/users/paulmelnikow/received_events","type":"User","site_admin":false},"body":"👍 ","created_at":"2018-12-08T19:00:31Z","updated_at":"2018-12-08T19:04:56Z","html_url":"https://github.com/paulmelnikow/icedfrisby-nock/pull/25#discussion_r240013338","pull_request_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/pulls/25","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/pulls/comments/240013338"},"html":{"href":"https://github.com/paulmelnikow/icedfrisby-nock/pull/25#discussion_r240013338"},"pull_request":{"href":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/pulls/25","id":237075176,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM3MDc1MTc2","html_url":"https://github.com/paulmelnikow/icedfrisby-nock/pull/25","diff_url":"https://github.com/paulmelnikow/icedfrisby-nock/pull/25.diff","patch_url":"https://github.com/paulmelnikow/icedfrisby-nock/pull/25.patch","issue_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/issues/25","number":25,"state":"open","locked":false,"title":"Conditional intercept","user":{"login":"PyvesB","id":10694593,"node_id":"MDQ6VXNlcjEwNjk0NTkz","avatar_url":"https://avatars2.githubusercontent.com/u/10694593?v=4","gravatar_id":"","url":"https://api.github.com/users/PyvesB","html_url":"https://github.com/PyvesB","followers_url":"https://api.github.com/users/PyvesB/followers","following_url":"https://api.github.com/users/PyvesB/following{/other_user}","gists_url":"https://api.github.com/users/PyvesB/gists{/gist_id}","starred_url":"https://api.github.com/users/PyvesB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyvesB/subscriptions","organizations_url":"https://api.github.com/users/PyvesB/orgs","repos_url":"https://api.github.com/users/PyvesB/repos","events_url":"https://api.github.com/users/PyvesB/events{/privacy}","received_events_url":"https://api.github.com/users/PyvesB/received_events","type":"User","site_admin":false},"body":"Whilst working on a [Shields issue](https://github.com/badges/shields/issues/2469), I figured it would be nice to have a function allowing to flexibly opt in and out of an intercept based on a condition.\r\n\r\nFor instance, if an API token is available at runtime, forward to the real endpoint, otherwise intercept the request and mock it. The new `conditionalIntercept` addresses this.\r\n\r\nLet me know whether you think this is sensible. 😉 ","created_at":"2018-12-08T15:55:43Z","updated_at":"2018-12-08T19:04:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"295bb555302d084ea59d323b92ce92cf3b21fce6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/pulls/25/commits","review_comments_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/pulls/25/comments","review_comment_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/pulls/comments{/number}","comments_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/issues/25/comments","statuses_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/statuses/fac4dc7ce65664acf4152f8fe4c34c8512a6e33f","head":{"label":"PyvesB:conditional-intercept","ref":"conditional-intercept","sha":"fac4dc7ce65664acf4152f8fe4c34c8512a6e33f","user":{"login":"PyvesB","id":10694593,"node_id":"MDQ6VXNlcjEwNjk0NTkz","avatar_url":"https://avatars2.githubusercontent.com/u/10694593?v=4","gravatar_id":"","url":"https://api.github.com/users/PyvesB","html_url":"https://github.com/PyvesB","followers_url":"https://api.github.com/users/PyvesB/followers","following_url":"https://api.github.com/users/PyvesB/following{/other_user}","gists_url":"https://api.github.com/users/PyvesB/gists{/gist_id}","starred_url":"https://api.github.com/users/PyvesB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyvesB/subscriptions","organizations_url":"https://api.github.com/users/PyvesB/orgs","repos_url":"https://api.github.com/users/PyvesB/repos","events_url":"https://api.github.com/users/PyvesB/events{/privacy}","received_events_url":"https://api.github.com/users/PyvesB/received_events","type":"User","site_admin":false},"repo":{"id":127323841,"node_id":"MDEwOlJlcG9zaXRvcnkxMjczMjM4NDE=","name":"icedfrisby-nock","full_name":"PyvesB/icedfrisby-nock","private":false,"owner":{"login":"PyvesB","id":10694593,"node_id":"MDQ6VXNlcjEwNjk0NTkz","avatar_url":"https://avatars2.githubusercontent.com/u/10694593?v=4","gravatar_id":"","url":"https://api.github.com/users/PyvesB","html_url":"https://github.com/PyvesB","followers_url":"https://api.github.com/users/PyvesB/followers","following_url":"https://api.github.com/users/PyvesB/following{/other_user}","gists_url":"https://api.github.com/users/PyvesB/gists{/gist_id}","starred_url":"https://api.github.com/users/PyvesB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyvesB/subscriptions","organizations_url":"https://api.github.com/users/PyvesB/orgs","repos_url":"https://api.github.com/users/PyvesB/repos","events_url":"https://api.github.com/users/PyvesB/events{/privacy}","received_events_url":"https://api.github.com/users/PyvesB/received_events","type":"User","site_admin":false},"html_url":"https://github.com/PyvesB/icedfrisby-nock","description":"Concise support for mock requests in IcedFrisby","fork":true,"url":"https://api.github.com/repos/PyvesB/icedfrisby-nock","forks_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/forks","keys_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/teams","hooks_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/hooks","issue_events_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/issues/events{/number}","events_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/events","assignees_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/assignees{/user}","branches_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/branches{/branch}","tags_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/tags","blobs_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/git/refs{/sha}","trees_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/statuses/{sha}","languages_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/languages","stargazers_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/stargazers","contributors_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/contributors","subscribers_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/subscribers","subscription_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/subscription","commits_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/commits{/sha}","git_commits_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/git/commits{/sha}","comments_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/comments{/number}","issue_comment_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/issues/comments{/number}","contents_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/contents/{+path}","compare_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/merges","archive_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/downloads","issues_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/issues{/number}","pulls_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/pulls{/number}","milestones_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/milestones{/number}","notifications_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/labels{/name}","releases_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/releases{/id}","deployments_url":"https://api.github.com/repos/PyvesB/icedfrisby-nock/deployments","created_at":"2018-03-29T17:18:06Z","updated_at":"2018-03-29T17:18:08Z","pushed_at":"2018-12-08T15:58:32Z","git_url":"git://github.com/PyvesB/icedfrisby-nock.git","ssh_url":"git@github.com:PyvesB/icedfrisby-nock.git","clone_url":"https://github.com/PyvesB/icedfrisby-nock.git","svn_url":"https://github.com/PyvesB/icedfrisby-nock","homepage":null,"size":101,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"paulmelnikow:master","ref":"master","sha":"a7d0bb52d4c677bcf65e8f2d2605fc2501eca9a8","user":{"login":"paulmelnikow","id":1487036,"node_id":"MDQ6VXNlcjE0ODcwMzY=","avatar_url":"https://avatars2.githubusercontent.com/u/1487036?v=4","gravatar_id":"","url":"https://api.github.com/users/paulmelnikow","html_url":"https://github.com/paulmelnikow","followers_url":"https://api.github.com/users/paulmelnikow/followers","following_url":"https://api.github.com/users/paulmelnikow/following{/other_user}","gists_url":"https://api.github.com/users/paulmelnikow/gists{/gist_id}","starred_url":"https://api.github.com/users/paulmelnikow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulmelnikow/subscriptions","organizations_url":"https://api.github.com/users/paulmelnikow/orgs","repos_url":"https://api.github.com/users/paulmelnikow/repos","events_url":"https://api.github.com/users/paulmelnikow/events{/privacy}","received_events_url":"https://api.github.com/users/paulmelnikow/received_events","type":"User","site_admin":false},"repo":{"id":88086113,"node_id":"MDEwOlJlcG9zaXRvcnk4ODA4NjExMw==","name":"icedfrisby-nock","full_name":"paulmelnikow/icedfrisby-nock","private":false,"owner":{"login":"paulmelnikow","id":1487036,"node_id":"MDQ6VXNlcjE0ODcwMzY=","avatar_url":"https://avatars2.githubusercontent.com/u/1487036?v=4","gravatar_id":"","url":"https://api.github.com/users/paulmelnikow","html_url":"https://github.com/paulmelnikow","followers_url":"https://api.github.com/users/paulmelnikow/followers","following_url":"https://api.github.com/users/paulmelnikow/following{/other_user}","gists_url":"https://api.github.com/users/paulmelnikow/gists{/gist_id}","starred_url":"https://api.github.com/users/paulmelnikow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulmelnikow/subscriptions","organizations_url":"https://api.github.com/users/paulmelnikow/orgs","repos_url":"https://api.github.com/users/paulmelnikow/repos","events_url":"https://api.github.com/users/paulmelnikow/events{/privacy}","received_events_url":"https://api.github.com/users/paulmelnikow/received_events","type":"User","site_admin":false},"html_url":"https://github.com/paulmelnikow/icedfrisby-nock","description":"Concise support for mock requests in IcedFrisby","fork":false,"url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock","forks_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/forks","keys_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/teams","hooks_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/hooks","issue_events_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/issues/events{/number}","events_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/events","assignees_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/assignees{/user}","branches_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/branches{/branch}","tags_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/tags","blobs_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/git/refs{/sha}","trees_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/statuses/{sha}","languages_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/languages","stargazers_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/stargazers","contributors_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/contributors","subscribers_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/subscribers","subscription_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/subscription","commits_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/commits{/sha}","git_commits_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/git/commits{/sha}","comments_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/comments{/number}","issue_comment_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/issues/comments{/number}","contents_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/contents/{+path}","compare_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/merges","archive_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/downloads","issues_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/issues{/number}","pulls_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/pulls{/number}","milestones_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/milestones{/number}","notifications_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/labels{/name}","releases_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/releases{/id}","deployments_url":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/deployments","created_at":"2017-04-12T18:56:43Z","updated_at":"2018-12-05T15:55:19Z","pushed_at":"2018-12-08T15:58:33Z","git_url":"git://github.com/paulmelnikow/icedfrisby-nock.git","ssh_url":"git@github.com:paulmelnikow/icedfrisby-nock.git","clone_url":"https://github.com/paulmelnikow/icedfrisby-nock.git","svn_url":"https://github.com/paulmelnikow/icedfrisby-nock","homepage":null,"size":128,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/pulls/25"},"html":{"href":"https://github.com/paulmelnikow/icedfrisby-nock/pull/25"},"issue":{"href":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/issues/25"},"comments":{"href":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/paulmelnikow/icedfrisby-nock/statuses/fac4dc7ce65664acf4152f8fe4c34c8512a6e33f"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"paulmelnikow"}}