Skip to content

Commit

Permalink
Merge pull request #660 from Turbo87/missing-require
Browse files Browse the repository at this point in the history
Fix missing require() calls
  • Loading branch information
keithamus committed Apr 1, 2016
2 parents 5746f04 + 2fd19ca commit 88cfe2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions lib/chai/utils/addMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* MIT Licensed
*/

var chai = require('../../chai');
var config = require('../config');
var flag = require('./flag');
var transferFlags = require('./transferFlags');

/**
Expand Down Expand Up @@ -32,18 +34,19 @@ var transferFlags = require('./transferFlags');
* @name addMethod
* @api public
*/
var flag = require('./flag');

module.exports = function (ctx, name, method) {
ctx[name] = function () {
var old_ssfi = flag(this, 'ssfi');
if (old_ssfi && config.includeStack === false)
flag(this, 'ssfi', ctx[name]);

var result = method.apply(this, arguments);
if (result !== undefined)
return result;

var newAssertion = new chai.Assertion();
transferFlags(this, newAssertion);

return result === undefined ? newAssertion: result;
return newAssertion;
};
};
7 changes: 5 additions & 2 deletions lib/chai/utils/addProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* MIT Licensed
*/

var chai = require('../../chai');
var config = require('../config');
var flag = require('./flag');
var transferFlags = require('./transferFlags');
Expand Down Expand Up @@ -44,10 +45,12 @@ module.exports = function (ctx, name, getter) {
flag(this, 'ssfi', addProperty);

var result = getter.call(this);
if (result !== undefined)
return result;

var newAssertion = new chai.Assertion();
transferFlags(this, newAssertion);

return result === undefined ? newAssertion: result;
return newAssertion;
}
, configurable: true
});
Expand Down

0 comments on commit 88cfe2e

Please sign in to comment.