Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Release 0.5.1

  • Loading branch information...
commit b91a4e128aa4041c12a86fb6f94aa8c74b909726 1 parent 7890dc6
@logicalparadox logicalparadox authored
View
8 History.md
@@ -1,4 +1,12 @@
+0.5.1 / 2012-03-14
+==================
+
+ * chai.fail no longer exists
+ * Merge branch 'feature/assertdefined'
+ * Added asset#isDefined. Closes #37.
+ * dev docs update for Assertion#assert
+
0.5.0 / 2012-03-07
==================
View
24 chai.js
@@ -140,7 +140,7 @@ function Assertion (obj, msg, stack) {
Assertion.includeStack = false;
/*!
- * # .assert(expression, message, negateMessage)
+ * # .assert(expression, message, negateMessage, expected, actual)
*
* Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
*
@@ -148,6 +148,8 @@ Assertion.includeStack = false;
* @param {Philosophical} expression to be tested
* @param {String} message to display if fails
* @param {String} negatedMessage to display if negated expression fails
+ * @param {*} expected value (remember to check for negation)
+ * @param {*} actual (optional) will default to `this.obj`
* @api private
*/
@@ -1077,7 +1079,7 @@ require.register("chai.js", function(module, exports, require){
var used = [];
var exports = module.exports = {};
-exports.version = '0.5.0';
+exports.version = '0.5.1';
exports.Assertion = require('./assertion');
exports.AssertionError = require('./error');
@@ -1410,6 +1412,24 @@ module.exports = function (chai) {
};
/**
+ * # .isDefined(value, [message])
+ *
+ * Assert `value` is not undefined.
+ *
+ * var tea = 'cup of chai';
+ * assert.isDefined(tea, 'no tea defined');
+ *
+ * @name isUndefined
+ * @param {*} value
+ * @param {String} message
+ * @api public
+ */
+
+ assert.isDefined = function (val, msg) {
+ new Assertion(val, msg).to.not.equal(undefined);
+ };
+
+ /**
* # .isFunction(value, [message])
*
* Assert `value` is a function.
View
24 docs/out/chai.js
@@ -140,7 +140,7 @@ function Assertion (obj, msg, stack) {
Assertion.includeStack = false;
/*!
- * # .assert(expression, message, negateMessage)
+ * # .assert(expression, message, negateMessage, expected, actual)
*
* Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
*
@@ -148,6 +148,8 @@ Assertion.includeStack = false;
* @param {Philosophical} expression to be tested
* @param {String} message to display if fails
* @param {String} negatedMessage to display if negated expression fails
+ * @param {*} expected value (remember to check for negation)
+ * @param {*} actual (optional) will default to `this.obj`
* @api private
*/
@@ -1077,7 +1079,7 @@ require.register("chai.js", function(module, exports, require){
var used = [];
var exports = module.exports = {};
-exports.version = '0.5.0';
+exports.version = '0.5.1';
exports.Assertion = require('./assertion');
exports.AssertionError = require('./error');
@@ -1410,6 +1412,24 @@ module.exports = function (chai) {
};
/**
+ * # .isDefined(value, [message])
+ *
+ * Assert `value` is not undefined.
+ *
+ * var tea = 'cup of chai';
+ * assert.isDefined(tea, 'no tea defined');
+ *
+ * @name isUndefined
+ * @param {*} value
+ * @param {String} message
+ * @api public
+ */
+
+ assert.isDefined = function (val, msg) {
+ new Assertion(val, msg).to.not.equal(undefined);
+ };
+
+ /**
* # .isFunction(value, [message])
*
* Assert `value` is a function.
View
33 docs/out/code/assert.html
@@ -66,6 +66,8 @@
</li>
<li class="keepcase"><a href="#isUndefined" class="scroll">isUndefined</a>
</li>
+ <li class="keepcase"><a href="#isUndefined" class="scroll">isUndefined</a>
+ </li>
<li class="keepcase"><a href="#isFunction" class="scroll">isFunction</a>
</li>
<li class="keepcase"><a href="#isObject" class="scroll">isObject</a>
@@ -567,6 +569,37 @@
</pre>
</div>
</article>
+ <article id="isUndefined-section" class="codeblock">
+ <div class="header"><h1>.isDefined(value, [message])</h1>
+ </div>
+ <div class="ctx">
+ <h3>assert.isDefined()
+ </h3>
+ </div>
+ <div class="tags">
+ <!-- ignroing this-->
+ <div class="tag"><span class="type">&#64;param</span><span class="types">&#123; * &#125;</span><span class="name">value</span><span class="desc"></span>
+ </div>
+ <div class="tag"><span class="type">&#64;param</span><span class="types">&#123; String &#125;</span><span class="name">message</span><span class="desc"></span>
+ </div>
+ <div class="tag"><span class="type">&#64;api</span><span class="visibility">public</span>
+ </div>
+ </div>
+ <div class="description"><p>Assert <code>value</code> is not undefined.</p>
+
+<pre><code> var tea = 'cup of chai';
+ assert.isDefined(tea, 'no tea defined');
+</code></pre>
+ </div>
+ <div class="view-source">View Source
+ </div>
+ <div class="code-wrap">
+ <pre class="source prettyprint"><code>assert.isDefined = function (val, msg) {
+ new Assertion(val, msg).to.not.equal(undefined);
+ };</code>
+ </pre>
+ </div>
+ </article>
<article id="isFunction-section" class="codeblock">
<div class="header"><h1>.isFunction(value, [message])</h1>
</div>
View
2  docs/out/support/coverage/index.html
1 addition, 1 deletion not shown
View
10 docs/out/support/tests/assert.js
@@ -14,7 +14,7 @@ var assert = chai.assert;
function err(fn, msg) {
try {
fn();
- chai.fail('expected an error');
+ throw new chai.AssertionError({ message: 'Expected an error' });
} catch (err) {
assert.equal(msg, err.message);
}
@@ -178,6 +178,14 @@ suite('assert', function () {
}, "expected null to equal undefined");
});
+ test('isDefined', function() {
+ assert.isDefined(null);
+
+ err(function () {
+ assert.isDefined(undefined);
+ }, "expected undefined to not equal undefined");
+ });
+
test('isFunction', function() {
var func = function() {};
assert.isFunction(func);
View
2  docs/out/support/tests/expect.js
@@ -13,7 +13,7 @@ var expect = chai.expect;
function err(fn, msg) {
try {
fn();
- chai.fail('expected an error');
+ throw new chai.AssertionError({ message: 'Expected an error' });
} catch (err) {
expect(msg).to.equal(err.message);
}
View
2  docs/out/support/tests/should.js
@@ -12,7 +12,7 @@ var should = chai.should();
function err(fn, msg) {
try {
fn();
- chai.fail('expected an error');
+ throw new chai.AssertionError({ message: 'Expected an error' });
} catch (err) {
should.equal(msg, err.message);
}
View
2  lib/chai.js
@@ -7,7 +7,7 @@
var used = [];
var exports = module.exports = {};
-exports.version = '0.5.0';
+exports.version = '0.5.1';
exports.Assertion = require('./assertion');
exports.AssertionError = require('./error');
View
2  package.json
@@ -3,7 +3,7 @@
"name": "chai",
"description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic.",
"keywords": [ "test", "assertion", "assert", "testing" ],
- "version": "0.5.0",
+ "version": "0.5.1",
"repository": {
"type": "git",
"url": "https://github.com/logicalparadox/chai"
Please sign in to comment.
Something went wrong with that request. Please try again.