Skip to content

Commit

Permalink
Fixed .a('object') with nulls. Fixed english in error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
rauchg committed Feb 4, 2012
1 parent 4005823 commit 8c0efa1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions expect.js
Expand Up @@ -207,11 +207,17 @@
Assertion.prototype.a = Assertion.prototype.a =
Assertion.prototype.an = function (type) { Assertion.prototype.an = function (type) {
if ('string' == typeof type) { if ('string' == typeof type) {
// proper english in error msg
var n = /^[aeiou]/.test(type) ? 'n' : '';

// typeof with support for 'array' // typeof with support for 'array'
this.assert( this.assert(
'array' == type ? isArray(this.obj) : type == typeof this.obj 'array' == type ? isArray(this.obj) :
, 'expected ' + i(this.obj) + ' to be a ' + type 'object' == type
, 'expected ' + i(this.obj) + ' not to be a ' + type); ? 'object' == typeof this.obj && null !== this.obj
: type == typeof this.obj
, 'expected ' + i(this.obj) + ' to be a' + n + ' ' + type
, 'expected ' + i(this.obj) + ' not to be a' + n + ' ' + type);
} else { } else {
// instanceof // instanceof
var name = type.name || 'supplied constructor'; var name = type.name || 'supplied constructor';
Expand Down

0 comments on commit 8c0efa1

Please sign in to comment.