Sha256: 0dc3c22e2e37fe032f5c4194f380b68c40d35c7e0a03d6152aad0a422a9c00b5

Contents?: true

Size: 1.22 KB

Versions: 85

Compression:

Stored size: 1.22 KB

Contents

/*!
 * Chai - message composition utility
 * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
 * MIT Licensed
 */

/*!
 * Module dependancies
 */

var flag = require('./flag')
  , getActual = require('./getActual')
  , inspect = require('./inspect')
  , objDisplay = require('./objDisplay');

/**
 * ### .getMessage(object, message, negateMessage)
 *
 * Construct the error message based on flags
 * and template tags. Template tags will return
 * a stringified inspection of the object referenced.
 *
 * Message template tags:
 * - `#{this}` current asserted object
 * - `#{act}` actual value
 * - `#{exp}` expected value
 *
 * @param {Object} object (constructed Assertion)
 * @param {Arguments} chai.Assertion.prototype.assert arguments
 * @name getMessage
 * @api public
 */

module.exports = function (obj, args) {
  var negate = flag(obj, 'negate')
    , val = flag(obj, 'object')
    , expected = args[3]
    , actual = getActual(obj, args)
    , msg = negate ? args[2] : args[1]
    , flagMsg = flag(obj, 'message');

  msg = msg || '';
  msg = msg
    .replace(/#{this}/g, objDisplay(val))
    .replace(/#{act}/g, objDisplay(actual))
    .replace(/#{exp}/g, objDisplay(expected));

  return flagMsg ? flagMsg + ': ' + msg : msg;
};

Version data entries

85 entries across 68 versions & 1 rubygems

Version Path
ende-0.4.25 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.4.24 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.4.23 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.5.1 components/indefinido/indemma/master/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.4.22 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.4.21 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.5.0 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.4.20 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.4.19 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.4.18 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.4.17 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.4.16 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.3.13 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.3.12 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.3.11 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.4.15 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.4.14 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.4.13 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.4.12 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js
ende-0.4.11 vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js