vendor/assets/javascripts/chai-changes.js in konacha-chai-matchers-0.0.2 vs vendor/assets/javascripts/chai-changes.js in konacha-chai-matchers-0.0.3
- old
+ new
@@ -20,11 +20,11 @@
# Changes Matchers
#
*/
chai.Assertion.addMethod('when', function(val, options) {
- var action, definedActions, done, _i, _j, _len, _len1, _results,
+ var action, definedActions, done, result, _i, _j, _len, _len1, _results,
_this = this;
if (options == null) {
options = {};
}
definedActions = flag(this, 'whenActions') || [];
@@ -32,32 +32,30 @@
action = definedActions[_i];
if (typeof action.before === "function") {
action.before(this);
}
}
- if (val.then != null) {
+ result = val();
+ if (result.then != null) {
done = options != null ? options.notify : void 0;
if (done == null) {
done = function() {};
}
- return val.then(function() {
+ return result.then(function() {
var _j, _len1;
try {
for (_j = 0, _len1 = definedActions.length; _j < _len1; _j++) {
action = definedActions[_j];
if (typeof action.after === "function") {
action.after(_this);
}
}
return done();
} catch (error) {
- return done(error);
+ return done(new Error(error));
}
});
} else {
- if (typeof val === "function") {
- val();
- }
_results = [];
for (_j = 0, _len1 = definedActions.length; _j < _len1; _j++) {
action = definedActions[_j];
_results.push(typeof action.after === "function" ? action.after(this) : void 0);
}