{"action":"created","issue":{"url":"https://api.github.com/repos/sinonjs/sinon/issues/1211","repository_url":"https://api.github.com/repos/sinonjs/sinon","labels_url":"https://api.github.com/repos/sinonjs/sinon/issues/1211/labels{/name}","comments_url":"https://api.github.com/repos/sinonjs/sinon/issues/1211/comments","events_url":"https://api.github.com/repos/sinonjs/sinon/issues/1211/events","html_url":"https://github.com/sinonjs/sinon/pull/1211","id":197187946,"number":1211,"title":"Add .resolves and .rejects to stub","user":{"login":"Floby","id":235570,"avatar_url":"https://avatars.githubusercontent.com/u/235570?v=3","gravatar_id":"","url":"https://api.github.com/users/Floby","html_url":"https://github.com/Floby","followers_url":"https://api.github.com/users/Floby/followers","following_url":"https://api.github.com/users/Floby/following{/other_user}","gists_url":"https://api.github.com/users/Floby/gists{/gist_id}","starred_url":"https://api.github.com/users/Floby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Floby/subscriptions","organizations_url":"https://api.github.com/users/Floby/orgs","repos_url":"https://api.github.com/users/Floby/repos","events_url":"https://api.github.com/users/Floby/events{/privacy}","received_events_url":"https://api.github.com/users/Floby/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-12-22T14:37:02Z","updated_at":"2016-12-23T07:50:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/sinonjs/sinon/pulls/1211","html_url":"https://github.com/sinonjs/sinon/pull/1211","diff_url":"https://github.com/sinonjs/sinon/pull/1211.diff","patch_url":"https://github.com/sinonjs/sinon/pull/1211.patch"},"body":"#### Purpose (TL;DR)\r\nThis commit adds the possibility for a stub\r\nto be configured to return a promise which will\r\neither resolve or reject\r\n\r\n#### Background (Problem in detail)\r\nThis was already possible, but this adds a shorthand for it\r\n\r\n##### resolving\r\n```javascript\r\nstub.returns(Promise.resolve({}))`\r\n```\r\nbecomes \r\n```javascript\r\nstub.resolves({})\r\n```\r\n\r\n##### rejecting\r\n```javascript\r\nstub.returns(Promise.reject(new Error(\"bad luck\")))\r\n```\r\nbecomes\r\n```javascript\r\nstub.rejects(\"bad luck\")\r\n```\r\n\r\nSince Promises are now part of the standard ES6 feature set, this\r\ncommit does not make use of polyfills or third party library.\r\nThis is problematic for some browsers and generally for contexts where\r\nthe standard is not implemented.\r\n**EDIT** now it does.\r\n\r\n#### Solution  - optional\r\nThis solution works by adding a `resolves` and `rejects` method to the possible behaviors.\r\n\r\n#### How to verify\r\n1. Check out this branch (see github instructions below)\r\n2. `npm install`\r\n3. `npm test`\r\n"},"comment":{"url":"https://api.github.com/repos/sinonjs/sinon/issues/comments/268952593","html_url":"https://github.com/sinonjs/sinon/pull/1211#issuecomment-268952593","issue_url":"https://api.github.com/repos/sinonjs/sinon/issues/1211","id":268952593,"user":{"login":"fatso83","id":618076,"avatar_url":"https://avatars.githubusercontent.com/u/618076?v=3","gravatar_id":"","url":"https://api.github.com/users/fatso83","html_url":"https://github.com/fatso83","followers_url":"https://api.github.com/users/fatso83/followers","following_url":"https://api.github.com/users/fatso83/following{/other_user}","gists_url":"https://api.github.com/users/fatso83/gists{/gist_id}","starred_url":"https://api.github.com/users/fatso83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fatso83/subscriptions","organizations_url":"https://api.github.com/users/fatso83/orgs","repos_url":"https://api.github.com/users/fatso83/repos","events_url":"https://api.github.com/users/fatso83/events{/privacy}","received_events_url":"https://api.github.com/users/fatso83/received_events","type":"User","site_admin":false},"created_at":"2016-12-23T07:50:31Z","updated_at":"2016-12-23T07:50:31Z","body":"Basically ready to merge this if you fix the test naming. Thanks!"}}
{"actor":{"display_login":"fatso83"}}