{"action":"created","issue":{"url":"https://api.github.com/repos/sinonjs/sinon/issues/1177","repository_url":"https://api.github.com/repos/sinonjs/sinon","labels_url":"https://api.github.com/repos/sinonjs/sinon/issues/1177/labels{/name}","comments_url":"https://api.github.com/repos/sinonjs/sinon/issues/1177/comments","events_url":"https://api.github.com/repos/sinonjs/sinon/issues/1177/events","html_url":"https://github.com/sinonjs/sinon/issues/1177","id":187022617,"number":1177,"title":"Stubbed getter called on restoring","user":{"login":"micheleDiSalvatoreLoveholidays","id":20278849,"avatar_url":"https://avatars.githubusercontent.com/u/20278849?v=3","gravatar_id":"","url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays","html_url":"https://github.com/micheleDiSalvatoreLoveholidays","followers_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/followers","following_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/following{/other_user}","gists_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/gists{/gist_id}","starred_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/subscriptions","organizations_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/orgs","repos_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/repos","events_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/events{/privacy}","received_events_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/received_events","type":"User","site_admin":false},"labels":[{"id":405918135,"url":"https://api.github.com/repos/sinonjs/sinon/labels/Awaiting%20Response","name":"Awaiting Response","color":"f9d0c4","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-03T10:29:01Z","updated_at":"2016-11-14T11:30:24Z","closed_at":null,"body":"Hi guys, I'm having an issue when I stub a getter. As I've seen [here](https://github.com/sinonjs/sinon/issues/897), it should work, but it could be that I'm not stubbing in the right way. \r\n\r\nSinon version:\r\n```log\r\n$ npm list | grep 'sinon'\r\n+-- karma-chai-sinon@0.1.5\r\n+-- karma-sinon@1.0.5\r\n+-- sinon@1.17.5\r\n+-- sinon-chai@2.8.0\r\n```\r\n\r\nThis is the code to test\r\n```javascript\r\n// stateHandlers.js\r\nexport default {\r\n  get totalPrice() {\r\n    console.log('totalPrice called');\r\n    return 3;\r\n  },\r\n\r\n  get totalWasPrice() {\r\n    console.log('totalWasPrice called');\r\n    return 5;\r\n  },\r\n\r\n  get totalSaving() {\r\n    return this.totalWasPrice - this.totalPrice;\r\n  },\r\n}\r\n``` \r\n\r\nthis is the test\r\n```javascript\r\n// __test__/stateHandlers.spec.js\r\nimport stateHandlers from '../stateHandlers';\r\n\r\ndescribe('stateHandlers', function () {\r\n  describe('#get totalSaving', function () {\r\n    beforeEach(function () {\r\n      console.log('stubbing');\r\n      this.totalWasPriceStub = sinon.stub(stateHandlers, 'totalWasPrice', { get: () => 5 });\r\n      this.totalPriceStub = sinon.stub(stateHandlers, 'totalPrice', { get: () => 3 });\r\n      console.log('stubbed');\r\n    });\r\n\r\n    afterEach(function () {\r\n      console.log('restoring');\r\n      this.totalWasPriceStub.restore();\r\n      this.totalPriceStub.restore();\r\n      console.log('restored');\r\n    });\r\n\r\n    it('returns the right value', function () {\r\n      console.log('running');\r\n      expect(stateHandlers.totalSaving).to.equal(2);\r\n      console.log('run');\r\n    });\r\n  });\r\n});\r\n```\r\n\r\n```log\r\nLOG: 'stubbing'\r\nLOG: 'stubbed'\r\nLOG: 'running'\r\nLOG: 'run'\r\nLOG: 'restoring'\r\nLOG: 'totalWasPrice called'\r\nLOG: 'totalPrice called'\r\nLOG: 'restored'\r\n```"},"comment":{"url":"https://api.github.com/repos/sinonjs/sinon/issues/comments/260312591","html_url":"https://github.com/sinonjs/sinon/issues/1177#issuecomment-260312591","issue_url":"https://api.github.com/repos/sinonjs/sinon/issues/1177","id":260312591,"user":{"login":"micheleDiSalvatoreLoveholidays","id":20278849,"avatar_url":"https://avatars.githubusercontent.com/u/20278849?v=3","gravatar_id":"","url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays","html_url":"https://github.com/micheleDiSalvatoreLoveholidays","followers_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/followers","following_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/following{/other_user}","gists_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/gists{/gist_id}","starred_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/subscriptions","organizations_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/orgs","repos_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/repos","events_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/events{/privacy}","received_events_url":"https://api.github.com/users/micheleDiSalvatoreLoveholidays/received_events","type":"User","site_admin":false},"created_at":"2016-11-14T11:30:24Z","updated_at":"2016-11-14T11:30:24Z","body":"I'm expecting that these logs are not showed \r\n```bash\r\nLOG: 'totalWasPrice called'\r\nLOG: 'totalPrice called'\r\n```\r\n"}}
{"actor":{"display_login":"micheleDiSalvatoreLoveholidays"}}