{"action":"created","issue":{"url":"https://api.github.com/repos/mroderick/bogus/issues/8","repository_url":"https://api.github.com/repos/mroderick/bogus","labels_url":"https://api.github.com/repos/mroderick/bogus/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/mroderick/bogus/issues/8/comments","events_url":"https://api.github.com/repos/mroderick/bogus/issues/8/events","html_url":"https://github.com/mroderick/bogus/pull/8","id":124736331,"number":8,"title":"Return promises from requireWithStubs and reset.","user":{"login":"qubyte","id":824753,"avatar_url":"https://avatars.githubusercontent.com/u/824753?v=3","gravatar_id":"","url":"https://api.github.com/users/qubyte","html_url":"https://github.com/qubyte","followers_url":"https://api.github.com/users/qubyte/followers","following_url":"https://api.github.com/users/qubyte/following{/other_user}","gists_url":"https://api.github.com/users/qubyte/gists{/gist_id}","starred_url":"https://api.github.com/users/qubyte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qubyte/subscriptions","organizations_url":"https://api.github.com/users/qubyte/orgs","repos_url":"https://api.github.com/users/qubyte/repos","events_url":"https://api.github.com/users/qubyte/events{/privacy}","received_events_url":"https://api.github.com/users/qubyte/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2016-01-04T10:50:12Z","updated_at":"2016-02-24T17:21:27Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mroderick/bogus/pulls/8","html_url":"https://github.com/mroderick/bogus/pull/8","diff_url":"https://github.com/mroderick/bogus/pull/8.diff","patch_url":"https://github.com/mroderick/bogus/pull/8.patch"},"body":"This is more a proposal than a pull request. If you are open to the idea, I'm happy to move it around and improve the tests. For example, I could make it so that `requireWithStubs` checks for a `callback` and returns a promise when it doesn't find one. I've gone with the simple approach below both for clarity and because I prefer not to check arguments for this kind of thing.\r\n\r\n## Why?\r\n\r\nMocha allows one to return a promise as an alternative to calling a `done` callback. This means that instead of:\r\n\r\n```javascript\r\nlet someModule;\r\n\r\nbefore(function (done) {\r\n    bogus.require('some-module', module => {\r\n        someModule = module;\r\n        done();\r\n    });\r\n});\r\n```\r\n\r\nyou can do\r\n\r\n```javascript\r\nlet someModule;\r\n\r\nbefore(function () {\r\n    return bogus.requireReturningPromise('some-module')\r\n        .then(module => someModule = module);\r\n});\r\n```\r\n\r\nThis is sort of nice, but the feature really comes into its own in the future, or when run with babel:\r\n\r\n```javascript\r\nlet someModule;\r\n\r\nbefore(async function () {\r\n    someModule = await bogus.requireReturningPromise('some-module');\r\n});\r\n```\r\n\r\n# Update:\r\n\r\nI've taken the `requireReturningPromise` method out and added code to make both `requireWithStubs` and `reset` return promises."},"comment":{"url":"https://api.github.com/repos/mroderick/bogus/issues/comments/188360229","html_url":"https://github.com/mroderick/bogus/pull/8#issuecomment-188360229","issue_url":"https://api.github.com/repos/mroderick/bogus/issues/8","id":188360229,"user":{"login":"qubyte","id":824753,"avatar_url":"https://avatars.githubusercontent.com/u/824753?v=3","gravatar_id":"","url":"https://api.github.com/users/qubyte","html_url":"https://github.com/qubyte","followers_url":"https://api.github.com/users/qubyte/followers","following_url":"https://api.github.com/users/qubyte/following{/other_user}","gists_url":"https://api.github.com/users/qubyte/gists{/gist_id}","starred_url":"https://api.github.com/users/qubyte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qubyte/subscriptions","organizations_url":"https://api.github.com/users/qubyte/orgs","repos_url":"https://api.github.com/users/qubyte/repos","events_url":"https://api.github.com/users/qubyte/events{/privacy}","received_events_url":"https://api.github.com/users/qubyte/received_events","type":"User","site_admin":false},"created_at":"2016-02-24T17:21:27Z","updated_at":"2016-02-24T17:21:27Z","body":"Bump!"}}