Comparing version 0.1.0 to 0.2.0
0.2.0 / 2011-04-17 | ||
================== | ||
* Added `res.should.have.status(code)` method | ||
* Added `res.should.have.header(field, val)` method | ||
0.1.0 / 2011-04-06 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -34,3 +34,3 @@ | ||
exports.version = '0.1.0'; | ||
exports.version = '0.2.0'; | ||
@@ -569,2 +569,38 @@ /** | ||
return this; | ||
}, | ||
/** | ||
* Assert that header `field` has the given `val`. | ||
* | ||
* @param {String} field | ||
* @param {String} val | ||
* @return {Assertion} for chaining | ||
* @api public | ||
*/ | ||
header: function(field, val){ | ||
this.obj.should.have.property('headers'); | ||
this.obj.headers.should.have.property(field.toLowerCase(), val); | ||
return this; | ||
}, | ||
/** | ||
* Assert `.statusCode` of `code`. | ||
* | ||
* @param {Number} code | ||
* @return {Assertion} for chaining | ||
* @api public | ||
*/ | ||
status: function(code){ | ||
this.obj.should.have.property('statusCode'); | ||
var status = this.obj.statusCode; | ||
this.assert( | ||
code == status | ||
, 'expected response code of ' + code + ' ' + i(statusCodes[code]) | ||
+ ', but got ' + status + ' ' + i(statusCodes[status]) | ||
, 'expected to not respond with ' + code + ' ' + i(statusCodes[code])); | ||
return this; | ||
} | ||
@@ -571,0 +607,0 @@ }; |
{ "name": "should" | ||
, "description": "test framework agnostic BDD-style assertions" | ||
, "version": "0.1.0" | ||
, "version": "0.2.0" | ||
, "author": "TJ Holowaychuk <tj@vision-media.ca>" | ||
@@ -5,0 +5,0 @@ , "contributors": [ "Aseem Kishore <aseem.kishore@gmail.com>" ] |
@@ -27,2 +27,18 @@ _should_ is an expressive, readable, test framework agnostic, assertion library for [node](http://nodejs.org). | ||
## assert extras | ||
As mentioned above, _should_ extends node's _assert_. The returned object from `require('should')` is thus similar to the returned object from `require('assert')`, but it has one extra convenience method: | ||
should.exist('hello') | ||
should.exist([]) | ||
should.exist(null) // will throw | ||
This is equivalent to `should.ok`, which is equivalent to `assert.ok`, but reads a bit better. It gets better, though: | ||
should.not.exist(false) | ||
should.not.exist('') | ||
should.not.exist({}) // will throw | ||
We may add more _assert_ extras in the future... ;) | ||
## modifiers | ||
@@ -29,0 +45,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
168348
1254
306