diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js index 2b7988213..47a4e5ea6 100644 --- a/lib/chai/core/assertions.js +++ b/lib/chai/core/assertions.js @@ -211,13 +211,7 @@ module.exports = function (chai, _) { var obj = flag(this, 'object'); var expected = false; - if (_.type(obj) !== 'array' && _.type(obj) !== 'string' && _.type(obj) !== 'object') { - this.assert( - false - , 'argument of expect() must be an array, an object, or a string, ' + _.type(obj) + ' given' - , 'argument of expect() must be an array, an object, or a string, ' + _.type(obj) + ' given'); - return; - } + new Assertion(obj).to.be.a(['array', 'object', 'string']); if (_.type(obj) === 'array' && _.type(val) === 'object') { for (var i in obj) { diff --git a/test/assert.js b/test/assert.js index cee5daeab..562fd870d 100644 --- a/test/assert.js +++ b/test/assert.js @@ -440,17 +440,24 @@ describe('assert', function () { err(function () { assert.include(42, 'bar'); - }, "argument of expect() must be an array, an object, or a string, number given"); + }, "expected 42 to be an array, an object, or a string"); + + err(function(){ + assert.include(null, 42); + }, "expected null to be an array, an object, or a string"); err(function () { assert.include(undefined, 'bar'); - }, "argument of expect() must be an array, an object, or a string, undefined given"); + }, "expected undefined to be an array, an object, or a string"); }); it('notInclude', function () { assert.notInclude('foobar', 'baz'); assert.notInclude([ 1, 2, 3 ], 4); - assert.notInclude(undefined, 'bar'); + + err(function () { + assert.notInclude(undefined, 'bar'); + }, "expected undefined to be an array, an object, or a string"); err(function () { assert.notInclude('foobar', 'bar'); diff --git a/test/expect.js b/test/expect.js index e7c1171f3..fd2f32463 100644 --- a/test/expect.js +++ b/test/expect.js @@ -668,7 +668,15 @@ describe('expect', function () { err(function(){ expect(42.0).to.include(42); - }, "argument of expect() must be an array, an object, or a string, number given"); + }, "expected 42 to be an array, an object, or a string"); + + err(function(){ + expect(null).to.not.include(42); + }, "expected null to be an array, an object, or a string"); + + err(function(){ + expect(undefined).to.not.include(42); + }, "expected undefined to be an array, an object, or a string"); }); it('keys(array|Object|arguments)', function(){ diff --git a/test/should.js b/test/should.js index 3fbbcf33e..ca0d49e48 100644 --- a/test/should.js +++ b/test/should.js @@ -503,7 +503,7 @@ describe('should', function() { err(function(){ (42).should.include(4); - }, "argument of expect() must be an array, an object, or a string, number given"); + }, "expected 42 to be an array, an object, or a string"); }); it('keys(array|Object|arguments)', function(){