{"action":"closed","issue":{"url":"https://api.github.com/repos/cjohansen/Sinon.JS/issues/791","labels_url":"https://api.github.com/repos/cjohansen/Sinon.JS/issues/791/labels{/name}","comments_url":"https://api.github.com/repos/cjohansen/Sinon.JS/issues/791/comments","events_url":"https://api.github.com/repos/cjohansen/Sinon.JS/issues/791/events","html_url":"https://github.com/cjohansen/Sinon.JS/issues/791","id":96649052,"number":791,"title":"Stub a function for only one argument","user":{"login":"gyandeeps","id":5554486,"avatar_url":"https://avatars.githubusercontent.com/u/5554486?v=3","gravatar_id":"","url":"https://api.github.com/users/gyandeeps","html_url":"https://github.com/gyandeeps","followers_url":"https://api.github.com/users/gyandeeps/followers","following_url":"https://api.github.com/users/gyandeeps/following{/other_user}","gists_url":"https://api.github.com/users/gyandeeps/gists{/gist_id}","starred_url":"https://api.github.com/users/gyandeeps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyandeeps/subscriptions","organizations_url":"https://api.github.com/users/gyandeeps/orgs","repos_url":"https://api.github.com/users/gyandeeps/repos","events_url":"https://api.github.com/users/gyandeeps/events{/privacy}","received_events_url":"https://api.github.com/users/gyandeeps/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-07-22T19:46:12Z","updated_at":"2015-07-26T06:41:07Z","closed_at":"2015-07-26T06:41:07Z","body":"So basically I have an function whose behavior I want to stub only if the argument is equal to something.\r\nExample\r\n\r\n```js\r\nvar foo = {\r\n    bar: function(arg1){\r\n        return true;\r\n    }\r\n};\r\n\r\nvar barStub = sinon.stub(foo, \"bar\");\r\nbarStub.withArgs(\"test\").returns(\"Hi\");\r\n\r\n// Expectations\r\nconsole.log(foo.bar(\"test\")); //works great as it logs \"Hi\"\r\n\r\n// my expectation is to call the original function in all cases except \r\n// when the arg is \"test\"\r\nconsole.log(foo.bar(\"woo\")); //doesnt work as it logs undefined\r\n```"}}