{"issue":{"state":"open","created_at":"2011-11-23T22:58:03Z","updated_at":"2011-11-24T00:53:41Z","user":{"gravatar_id":"10734c22bb480db06f8e61d062636ae0","id":1167712,"url":"https://api.github.com/users/ggoforth","login":"ggoforth","avatar_url":"https://secure.gravatar.com/avatar/10734c22bb480db06f8e61d062636ae0?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"comments":1,"body":"To see the issue: http://jsfiddle.net/93EVL/1/\r\n\r\nIssue:\r\nI ran into an issue today where sinon.args was not returning results I was expected.  Seems like we would always want to know exactly what a function is called with.  \r\n\r\nBackstory:\r\nWe have some code where a function receives an options object, and one of the key is {retries: 3}.  Our code will decrement retries, then call another function (that we are spying on) passing to it the options object, until retries === 0.  \r\nWhen all is said and done I would have expected to see:\r\n\r\nourSpiedOnFunction.args === [{retries: 2}, {retries: 1}, {retries: 0}]\r\n\r\nbut instead got:\r\n\r\nourSpiedOnFunction.args === [[retries: 0}, {retries: 0}, {retries: 0}]\r\n\r\nSo, it seems like sinon holds onto the arguments by reference, which is causing this issue.  Demonstration of the issue here: http://jsfiddle.net/93EVL/1/","assignee":null,"number":62,"id":2335693,"labels":[],"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"title":"spy.args can give inaccurate results by referencing arguments","closed_at":null,"html_url":"https://github.com/cjohansen/Sinon.JS/issues/62","milestone":null,"url":"https://api.github.com/repos/cjohansen/Sinon.JS/issues/62"},"action":"created","comment":{"created_at":"2011-11-24T00:53:41Z","updated_at":"2011-11-24T00:53:41Z","user":{"gravatar_id":"c6d819207a3010b39d13e1f59f2c0029","id":617481,"url":"https://api.github.com/users/DomenicDenicola","login":"DomenicDenicola","avatar_url":"https://secure.gravatar.com/avatar/c6d819207a3010b39d13e1f59f2c0029?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"-1.\r\n\r\nFor the use of spies in my tests, it is important that the args be held by reference. For example, DOM nodes and other host objects could not be cloned accurately, and I need to test that the appropriate instance of an object is being passed through in cases where it starts out identical to many other objects.","id":2857028,"url":"https://api.github.com/repos/cjohansen/Sinon.JS/issues/comments/2857028"}}