Sha256: 2fd9aa2620f7c16e4b5657b317a6fccd4c6280c00fad041639dd4345f8fdff2d
Contents?: true
Size: 1.69 KB
Versions: 2
Compression:
Stored size: 1.69 KB
Contents
/*! * Chai - overwriteChainableMethod utility * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com> * MIT Licensed */ /** * ### overwriteChainableMethod (ctx, name, method, chainingBehavior) * * Overwites an already existing chainable method * and provides access to the previous function or * property. Must return functions to be used for * name. * * utils.overwriteChainableMethod(chai.Assertion.prototype, 'length', * function (_super) { * } * , function (_super) { * } * ); * * Can also be accessed directly from `chai.Assertion`. * * chai.Assertion.overwriteChainableMethod('foo', fn, fn); * * Then can be used as any other assertion. * * expect(myFoo).to.have.length(3); * expect(myFoo).to.have.length.above(3); * * @param {Object} ctx object whose method / property is to be overwritten * @param {String} name of method / property to overwrite * @param {Function} method function that returns a function to be used for name * @param {Function} chainingBehavior function that returns a function to be used for property * @namespace Utils * @name overwriteChainableMethod * @api public */ module.exports = function (ctx, name, method, chainingBehavior) { var chainableBehavior = ctx.__methods[name]; var _chainingBehavior = chainableBehavior.chainingBehavior; chainableBehavior.chainingBehavior = function () { var result = chainingBehavior(_chainingBehavior).call(this); return result === undefined ? this : result; }; var _method = chainableBehavior.method; chainableBehavior.method = function () { var result = method(_method).apply(this, arguments); return result === undefined ? this : result; }; };
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
mdarray-sol-0.1.0-java | node_modules/chai/lib/chai/utils/overwriteChainableMethod.js |
select_all-rails-0.3.1 | node_modules/chai/lib/chai/utils/overwriteChainableMethod.js |