domenic/sinon-chai — pull request #19 by mikelovesrobots (2013-01-08 00:30:55+00:00)
Title: Prevent exception when object spied upon has a #proxy property of its own

We noticed when running tests with `.calledWith` against spine.js controllers that we were getting exceptions in `printfArray`, due to not being able to call `apply` on undefined:

```
function printfArray(array) {
return spy.printf.apply(spy, array);
}
```

`printf` doesn't exist in that line, due to this line:

```
spy = spy.proxy || spy;
```

It's only a problem if the spied-upon object has a `proxy` property of its own. I think the correct solution is to test that the proxy is indeed a spy (using the sinon-chai `isSpy()` test) before reassigning and this patch implements that.

Thanks for making sinon-chai!

Cheers,
- Mike