{"action":"created","issue":{"url":"https://api.github.com/repos/freerange/mocha/issues/292","repository_url":"https://api.github.com/repos/freerange/mocha","labels_url":"https://api.github.com/repos/freerange/mocha/issues/292/labels{/name}","comments_url":"https://api.github.com/repos/freerange/mocha/issues/292/comments","events_url":"https://api.github.com/repos/freerange/mocha/issues/292/events","html_url":"https://github.com/freerange/mocha/issues/292","id":197182949,"number":292,"title":"Prevent calls to Mocha::API methods until the before/setup block for a single test/example","user":{"login":"andyw8","id":13400,"avatar_url":"https://avatars.githubusercontent.com/u/13400?v=3","gravatar_id":"","url":"https://api.github.com/users/andyw8","html_url":"https://github.com/andyw8","followers_url":"https://api.github.com/users/andyw8/followers","following_url":"https://api.github.com/users/andyw8/following{/other_user}","gists_url":"https://api.github.com/users/andyw8/gists{/gist_id}","starred_url":"https://api.github.com/users/andyw8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyw8/subscriptions","organizations_url":"https://api.github.com/users/andyw8/orgs","repos_url":"https://api.github.com/users/andyw8/repos","events_url":"https://api.github.com/users/andyw8/events{/privacy}","received_events_url":"https://api.github.com/users/andyw8/received_events","type":"User","site_admin":false},"labels":[{"id":217486,"url":"https://api.github.com/repos/freerange/mocha/labels/feature-request","name":"feature-request","color":"02e10c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-22T14:11:53Z","updated_at":"2017-01-11T12:50:17Z","closed_at":null,"body":"I'm working on a relatively old Rails codebase which uses Mocha with RSpec.\r\n\r\nThere is some instability in the test suite which is caused by stubbing happening in `before(:all)` blocks:\r\n\r\nhttps://gist.github.com/andyw8/7aa312287dd5c60412475a147900e121\r\n\r\nIf I attempt the same thing with rspec-mocks, it refuses to run:\r\n\r\n`The use of doubles or partial doubles from rspec-mocks outside of the per-test lifecycle is not supported.`\r\n\r\nhttps://relishapp.com/rspec/rspec-mocks/docs/basics/scope#cannot-create-doubles-in-a-`before(:context)`-hook\r\n\r\nIs it possible to have a similar level of protection when using mocha? I'm not sure if this code would belong in Mocha, in RSpec, or perhaps a separate gem."},"comment":{"url":"https://api.github.com/repos/freerange/mocha/issues/comments/271860401","html_url":"https://github.com/freerange/mocha/issues/292#issuecomment-271860401","issue_url":"https://api.github.com/repos/freerange/mocha/issues/292","id":271860401,"user":{"login":"andyw8","id":13400,"avatar_url":"https://avatars.githubusercontent.com/u/13400?v=3","gravatar_id":"","url":"https://api.github.com/users/andyw8","html_url":"https://github.com/andyw8","followers_url":"https://api.github.com/users/andyw8/followers","following_url":"https://api.github.com/users/andyw8/following{/other_user}","gists_url":"https://api.github.com/users/andyw8/gists{/gist_id}","starred_url":"https://api.github.com/users/andyw8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyw8/subscriptions","organizations_url":"https://api.github.com/users/andyw8/orgs","repos_url":"https://api.github.com/users/andyw8/repos","events_url":"https://api.github.com/users/andyw8/events{/privacy}","received_events_url":"https://api.github.com/users/andyw8/received_events","type":"User","site_admin":false},"created_at":"2017-01-11T12:50:17Z","updated_at":"2017-01-11T12:50:17Z","body":"@floehopper thanks for looking into this. Moving the calls from `before(:all)` to `before(:each)` blocks is the approach I've taken, but I'd like to protect against any future occurrences."}}
{"actor":{"display_login":"andyw8"}}