logicalparadox/chai — Issue #15: include/string/contain doc errors
Author: jfirebaugh
Created: 2012-02-13 00:08:45+00:00
State: open

The `include` API doc has this example

expect([1,2,3]).to.contain(2);

I think that's meant to be:

expect([1,2,3]).to.include(2);

`string` has this example:

expect('foobar').to.include.string('bar');

I think that's meant to be:

expect('foobar').to.have.string('bar');

Though, if you did want `include` to work as both a function and a chaining property, it seems to be possible:

```
Object.defineProperty(Assertion.prototype, 'include', {
get: function () {
var include = function (obj) {
this.assert(
~this.obj.indexOf(obj)
, 'expected ' + this.inspect + ' to include ' + inspect(obj)
, 'expected ' + this.inspect + ' to not include ' + inspect(obj));

return this;
};
include.__proto__ = this;
return include;
}
});
```

I think it would be nice if both `include` and `contain` worked this way (i.e. they were synonyms, with the definition above):

expect([1,2,3]).to.contain(2);
expect([1,2,3]).to.include(2);
expect('foobar').to.contain('bar');
expect('foobar').to.include('bar');
expect({foo: 1, bar: 2}).to.contain.keys('foo', 'bar');
expect({foo: 1, bar: 2}).to.include.keys('foo', 'bar');

I can send a pull request if you agree.