{"action":"created","issue":{"url":"https://api.github.com/repos/sinonjs/sinon/issues/878","labels_url":"https://api.github.com/repos/sinonjs/sinon/issues/878/labels{/name}","comments_url":"https://api.github.com/repos/sinonjs/sinon/issues/878/comments","events_url":"https://api.github.com/repos/sinonjs/sinon/issues/878/events","html_url":"https://github.com/sinonjs/sinon/issues/878","id":111456082,"number":878,"title":"Stubbing, and restoring do not work with es6 class instances","user":{"login":"autoric","id":918178,"avatar_url":"https://avatars.githubusercontent.com/u/918178?v=3","gravatar_id":"","url":"https://api.github.com/users/autoric","html_url":"https://github.com/autoric","followers_url":"https://api.github.com/users/autoric/followers","following_url":"https://api.github.com/users/autoric/following{/other_user}","gists_url":"https://api.github.com/users/autoric/gists{/gist_id}","starred_url":"https://api.github.com/users/autoric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/autoric/subscriptions","organizations_url":"https://api.github.com/users/autoric/orgs","repos_url":"https://api.github.com/users/autoric/repos","events_url":"https://api.github.com/users/autoric/events{/privacy}","received_events_url":"https://api.github.com/users/autoric/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-14T18:04:24Z","updated_at":"2015-10-16T17:33:08Z","closed_at":null,"body":"### Environment: \r\n - Node 4.2.1\r\n - Sinon 1.15.4\r\n - Writing natively supported es6 syntax, no transpilers.\r\n\r\n### Test Case:\r\n```\r\n'use strict';\r\nconst sinon = require('sinon');\r\n\r\nclass C {\r\n  foo(){ }\r\n}\r\n\r\nconst c = new C();\r\n\r\nconst sandbox = sinon.sandbox.create();\r\n\r\nsandbox.stub(c);\r\nsandbox.restore();\r\nsandbox.stub(c);\r\nsandbox.restore();\r\n```\r\n\r\n### Expected result:\r\nNo errors, code executes and exists cleanly.\r\n\r\n### Actual results:\r\n```\r\nTypeError: Attempted to wrap foo which is already wrapped\r\n    at checkWrappedMethod (/Users/erin.noe-payne/local/lr-zmq/node_modules/sinon/lib/sinon/util/core.js:81:29)\r\n    at Object.wrapMethod (/Users/erin.noe-payne/local/lr-zmq/node_modules/sinon/lib/sinon/util/core.js:121:21)\r\n    at stub (/Users/erin.noe-payne/local/lr-zmq/node_modules/sinon/lib/sinon/stub.js:67:26)\r\n    at /Users/erin.noe-payne/local/lr-zmq/node_modules/sinon/lib/sinon/stub.js:60:25\r\n    at /Users/erin.noe-payne/local/lr-zmq/node_modules/sinon/lib/sinon/walk.js:26:26\r\n    at Array.forEach (native)\r\n    at walkInternal (/Users/erin.noe-payne/local/lr-zmq/node_modules/sinon/lib/sinon/walk.js:23:45)\r\n    at Object.walk (/Users/erin.noe-payne/local/lr-zmq/node_modules/sinon/lib/sinon/walk.js:46:20)\r\n    at Object.stub (/Users/erin.noe-payne/local/lr-zmq/node_modules/sinon/lib/sinon/stub.js:52:23)\r\n    at Object.stub (/Users/erin.noe-payne/local/lr-zmq/node_modules/sinon/lib/sinon/collection.js:106:49)\r\n```\r\n\r\n### More info:\r\n - Manually stubbing and restoring each function does work: `sinon.stub(c, 'foo'); c.foo.restore();`\r\n - Using `sinon.stub` and `sinon.restore` instead of sandboxes does not work - it fails with the same issue, I assume with the same root cause"},"comment":{"url":"https://api.github.com/repos/sinonjs/sinon/issues/comments/148779851","html_url":"https://github.com/sinonjs/sinon/issues/878#issuecomment-148779851","issue_url":"https://api.github.com/repos/sinonjs/sinon/issues/878","id":148779851,"user":{"login":"mroderick","id":20321,"avatar_url":"https://avatars.githubusercontent.com/u/20321?v=3","gravatar_id":"","url":"https://api.github.com/users/mroderick","html_url":"https://github.com/mroderick","followers_url":"https://api.github.com/users/mroderick/followers","following_url":"https://api.github.com/users/mroderick/following{/other_user}","gists_url":"https://api.github.com/users/mroderick/gists{/gist_id}","starred_url":"https://api.github.com/users/mroderick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mroderick/subscriptions","organizations_url":"https://api.github.com/users/mroderick/orgs","repos_url":"https://api.github.com/users/mroderick/repos","events_url":"https://api.github.com/users/mroderick/events{/privacy}","received_events_url":"https://api.github.com/users/mroderick/received_events","type":"User","site_admin":false},"created_at":"2015-10-16T17:33:08Z","updated_at":"2015-10-16T17:33:08Z","body":"Sure, I can look into that this weekend "}}