pivotal/jasmine — pull request #281 by rprieto (2012-09-26 10:12:48+00:00)
Title: Spy: cloning arguments so we can assert on the value at the time they were called

Hi,

I noticed that ```spyOn``` only keeps a reference to the arguments used in function calls.
This can be handy to compare exact reference-equality, but not so much in cases like this:

```
var mock = { fn: function(x) {} };
spyOn(mock, 'fn');

var params = { val: 1 };
mock.fn(params);
params.val = 2;
mock.fn(params);

expect(mock.fn.argsForCall[0]).toEqual([{val: 1}]);
// currently fails, saying it was called with "val = 2"
```

This pull request does a **shallow copy** of all arguments to avoid this - with corresponding unit tests.

All existing tests pass, however it **does** change the existing behaviour, in cases where users are testing for reference-equality of arguments. What do you think? A possibility could be to keep both the reference and a copy, and leave the option of which one to check to the user.