AdamNowotny/jasmine-signals — pull request #8 by robinjmurphy (2014-02-18 22:53:04+00:00)
Title: Add object/array equality support to toHaveBeenDispatchedWith()

I would like to be able to use `toHaveBeenDispatchedWith` with an object literal:

```js
signal.dispatch({foo: 'bar'});

expect(spy).toHaveBeenDispatchedWith({foo: 'bar'});
// fails
```

At the moment this fails with the error:

```
Expected [Signal active:true numListeners:1] to have been dispatched with ([object Object]) but was with ([object Object])
```

This is because [jasmine-signals.js (line 82)](https://github.com/AdamNowotny/jasmine-signals/blob/master/jasmine-signals.js#L82) only does a simple equality check (`!==`) between the actual and expected parameters.

In the very similar Jasmine matcher `toHaveBeenCalledWith`, this works as expected:

```js
var myObj = {
myMethod: function () {}
};

spyOn(myObj, 'myMethod');

myObj.myMethod({foo: 'bar'});

expect(myObj).toHaveBeenCalledWith({foo: 'bar'});
// passes
```

This is because `toHaveBeenCalledWith` uses the same underlying equality check as `toEqual` (which implements common sense object/array equality).

The underlying equality method is [`jasmine.Env.prototype.equals_`](https://github.com/pivotal/jasmine/blob/v1.3.1/src/core/Env.js#L228).

This PR implements `toHaveBeenDispatchedWith` using the same Jasmine method, which allows for signals that dispatch objects and arrays to be tested easily (as in the above example).

It's worth noting that `jasmine.Env.prototype.equals_` has moved in Jasmine 2.0.0 (the equality check is in [matchersUtil.js ](https://github.com/pivotal/jasmine/blob/master/src/core/matchers/matchersUtil.js#L51), but I'm not sure whether jasmine-signals supports 2.0.0 anyway?