Skip to content

Commit

Permalink
Release 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
logicalparadox committed May 16, 2012
1 parent d809ff4 commit 37555f6
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 64 deletions.
11 changes: 11 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@

0.2.0 / 2012-05-16
==================

* chai 1.0.0 compatibility
* browser build
* tests for 1.0.0 compatibility
* chai 1.0.0 compatibility
* Merge pull request #1 from JamesMaroney/master
* added link to jack project
* small typo fixes

0.1.0 / 2012-02-13
==================

Expand Down
103 changes: 40 additions & 63 deletions chai-spies.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ module.exports = function (chai, _) {
* @api public
*/

_.addProperty(Assertion, 'spy', function () {
var obj = flag(this, 'object');
Assertion.addProperty('spy', function () {
this.assert(
undefined !== obj.__spy
undefined !== this._obj.__spy
, 'expected #{this} to be a spy'
, 'expected #{this} to not be a spy');
return this;
Expand All @@ -129,25 +128,21 @@ module.exports = function (chai, _) {
* @api public
*/

Object.defineProperty(Assertion.prototype, 'called',
{ get: function () {
var assert = function () {
var obj = flag(this, 'object');
new Assertion(obj).to.be.spy;
Assertion.addProperty('called', function () {
var assert = function () {
new Assertion(this._obj).to.be.spy;

this.assert(
obj.__spy.called === true
, 'expected #{this} to have been called'
, 'expected #{this} to not have been called'
);
this.assert(
this._obj.__spy.called === true
, 'expected #{this} to have been called'
, 'expected #{this} to not have been called'
);

return this;
};
return this;
};

assert.__proto__ = this;
return assert;
}
, configurable: true
assert.__proto__ = this;
return assert;
});

/**
Expand All @@ -158,18 +153,14 @@ module.exports = function (chai, _) {
* @api public
*/

_.addProperty(Assertion, 'once', function () {
var obj = flag(this, 'object');
new Assertion(obj).to.be.spy;

Assertion.addProperty('once', function () {
new Assertion(this._obj).to.be.spy;
this.assert(
obj.__spy.calls.length === 1
this._obj.__spy.calls.length === 1
, 'expected #{this} to have been called once but got #{act}'
, 'expected #{this} to not have been called once'
, 1
, obj.__spy.calls.length );

return this;
, this._obj.__spy.calls.length );
});

/**
Expand All @@ -180,19 +171,15 @@ module.exports = function (chai, _) {
* @api public
*/

_.addProperty(Assertion, 'twice', function () {
var obj = flag(this, 'object');
new Assertion(obj).to.be.spy;

Assertion.addProperty('twice', function () {
new Assertion(this._obj).to.be.spy;
this.assert(
obj.__spy.calls.length === 2
this._obj.__spy.calls.length === 2
, 'expected #{this} to have been called once but got #{act}'
, 'expected #{this} to not have been called once'
, 2
, obj.__spy.calls.length
, this._obj.__spy.calls.length
);

return this;
});

/**
Expand All @@ -204,19 +191,15 @@ module.exports = function (chai, _) {
* @api public
*/

_.addMethod(Assertion, 'exactly', function (n) {
var obj = flag(this, 'object');
new Assertion(obj).to.be.spy;

Assertion.addMethod('exactly', function (n) {
new Assertion(this._obj).to.be.spy;
this.assert(
obj.__spy.calls.length === n
this._obj.__spy.calls.length === n
, 'expected #{this} to have been called #{exp} times but got #{act}'
, 'expected #{this} to not have been called #{exp} times'
, n
, obj.__spy.calls.length
, this._obj.__spy.calls.length
);

return this;
});

/**
Expand All @@ -230,27 +213,24 @@ module.exports = function (chai, _) {

function above (_super) {
return function (n) {
var obj = flag(this, 'object');
if ('undefined' !== obj.__spy) {
new Assertion(obj).to.be.spy;
if ('undefined' !== this._obj.__spy) {
new Assertion(this._obj).to.be.spy;

this.assert(
obj.__spy.calls.length > n
this._obj.__spy.calls.length > n
, 'expected #{this} to have been called more than #{exp} times but got #{act}'
, 'expected #{this} to have been called no more than than #{exp} times but got #{act}'
, n
, obj.__spy.calls.length
, this._obj.__spy.calls.length
);

return this;
} else {
return _super.apply(this, arguments);
_super.apply(this, arguments);
}
}
}

_.overwriteMethod(Assertion, 'above', above);
_.overwriteMethod(Assertion, 'gt', above);
Assertion.overwriteMethod('above', above);
Assertion.overwriteMethod('gt', above);

/**
* # lt (n)
Expand All @@ -263,27 +243,24 @@ module.exports = function (chai, _) {

function below (_super) {
return function (n) {
var obj = flag(this, 'object');
if ('undefined' !== obj.__spy) {
new Assertion(obj).to.be.spy;
if ('undefined' !== this._obj.__spy) {
new Assertion(this._obj).to.be.spy;

this.assert(
obj.__spy.calls.length < n
this._obj.__spy.calls.length < n
, 'expected #{this} to have been called less than #{exp} times but got #{act}'
, 'expected #{this} to have been called at least #{exp} times but got #{act}'
, n
, obj.__spy.calls.length
, this._obj.__spy.calls.length
);

return this;
} else {
return _super.apply(this, arguments);
_super.apply(this, arguments);
}
}
}

_.overwriteMethod(Assertion, 'below', below);
_.overwriteMethod(Assertion, 'lt', below);
Assertion.overwriteMethod('below', below);
Assertion.overwriteMethod('lt', below);
};

}); // module spy
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Jake Luer <jake@alogicalparadox.com> (http://alogicalparadox.com)",
"name": "chai-spies",
"description": "Spies for the Chai assertion library.",
"version": "0.1.0",
"version": "0.2.0",
"repository": {
"type": "git",
"url": "git://github.com/logicalparadox/chai-spies.git"
Expand Down

0 comments on commit 37555f6

Please sign in to comment.