ende 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/lib/assets/javascripts/aura/extensions/devise.js.coffee +0 -2
  3. data/lib/assets/javascripts/aura/extensions/platform.js.coffee +3 -0
  4. data/lib/assets/javascripts/aura/extensions/rivets.js.coffee +17 -1
  5. data/lib/assets/javascripts/aura/extensions/routes.js.coffee +8 -7
  6. data/lib/assets/javascripts/aura/extensions/states.js.coffee +13 -1
  7. data/lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee +4 -2
  8. data/lib/assets/javascripts/config/load_components.js.coffee +19 -12
  9. data/lib/assets/javascripts/ende.js.coffee +33 -12
  10. data/lib/ende/version.rb +1 -1
  11. data/vendor/assets/components/build.css +111 -0
  12. data/vendor/assets/components/ende_build.js +160 -41
  13. data/vendor/components/indefinido-indemma/build/development.js +3 -118
  14. data/vendor/components/indefinido-indemma/build/release.js +39 -4170
  15. data/vendor/components/indefinido-indemma/build/test.js +3 -118
  16. data/vendor/components/indefinido-indemma/lib/record/associable.js +10 -2
  17. data/vendor/components/indefinido-indemma/lib/record/restfulable.js +26 -15
  18. data/vendor/components/indefinido-indemma/lib/record.js +3 -1
  19. data/vendor/components/indefinido-indemma/src/lib/record/associable.coffee +15 -1
  20. data/vendor/components/indefinido-indemma/src/lib/record/restfulable.coffee +37 -12
  21. data/vendor/components/indefinido-indemma/src/lib/record.coffee +3 -1
  22. data/vendor/components/indefinido-observable/.gitignore +15 -0
  23. data/vendor/components/indefinido-observable/.ruby-gemset +1 -0
  24. data/vendor/components/indefinido-observable/.ruby-version +1 -0
  25. data/vendor/components/indefinido-observable/Gemfile +13 -0
  26. data/vendor/components/indefinido-observable/Guardfile +39 -0
  27. data/vendor/components/indefinido-observable/History.md +0 -0
  28. data/vendor/components/indefinido-observable/Readme.md +116 -0
  29. data/vendor/components/indefinido-observable/build/build.js +14798 -0
  30. data/vendor/components/indefinido-observable/build/development.js +339 -0
  31. data/vendor/components/indefinido-observable/build/release.js +14937 -0
  32. data/vendor/components/indefinido-observable/build/test.js +339 -0
  33. data/vendor/components/indefinido-observable/component.json +5 -1
  34. data/vendor/components/indefinido-observable/components/chaijs-chai/component.json +46 -0
  35. data/vendor/components/indefinido-observable/components/chaijs-chai/index.js +1 -0
  36. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/assertion.js +132 -0
  37. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/core/assertions.js +1270 -0
  38. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/error.js +60 -0
  39. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/interface/assert.js +1060 -0
  40. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/interface/expect.js +12 -0
  41. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/interface/should.js +76 -0
  42. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +94 -0
  43. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addMethod.js +37 -0
  44. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addProperty.js +40 -0
  45. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/eql.js +124 -0
  46. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/flag.js +32 -0
  47. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getActual.js +19 -0
  48. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +25 -0
  49. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getMessage.js +49 -0
  50. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getName.js +20 -0
  51. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getPathValue.js +102 -0
  52. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getProperties.js +35 -0
  53. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/index.js +108 -0
  54. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/inspect.js +316 -0
  55. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/objDisplay.js +48 -0
  56. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +51 -0
  57. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +54 -0
  58. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/test.js +26 -0
  59. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/transferFlags.js +44 -0
  60. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/type.js +45 -0
  61. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai.js +79 -0
  62. data/vendor/components/indefinido-observable/components/component-jquery/component.json +14 -0
  63. data/vendor/components/indefinido-observable/components/component-jquery/index.js +9601 -0
  64. data/vendor/components/indefinido-observable/components/kapit-observe-shim/component.json +11 -0
  65. data/vendor/components/indefinido-observable/components/kapit-observe-utils/component.json +13 -0
  66. data/vendor/components/indefinido-observable/karma.conf.js +92 -0
  67. data/vendor/components/indefinido-observable/lib/adapters/rivets.js +3 -1
  68. data/vendor/components/indefinido-observable/lib/observable.js +47 -13
  69. data/vendor/components/indefinido-observable/spec/legacy/observable_spec.js +126 -0
  70. data/vendor/components/indefinido-observable/spec/observable_spec.js +92 -0
  71. data/vendor/components/indefinido-observable/spec/spec_helper.js +8 -0
  72. data/vendor/components/indefinido-observable/spec/vendor/accessors_spec.js +63 -0
  73. data/vendor/components/indefinido-observable/src/lib/adapters/rivets.js.coffee +15 -0
  74. data/vendor/components/indefinido-observable/src/spec/legacy/observable_spec.coffee +132 -0
  75. data/vendor/components/indefinido-observable/src/spec/observable_spec.coffee +85 -0
  76. data/vendor/components/indefinido-observable/src/spec/spec_helper.coffee +5 -0
  77. data/vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee +59 -0
  78. data/vendor/components/indefinido-observable/vendor/shims/accessors.js +71 -9
  79. data/vendor/components/indefinido-observable/vendor/spec/boot.js +104 -0
  80. data/vendor/components/indefinido-observable/vendor/spec/jasmine.js +2054 -0
  81. metadata +58 -2
@@ -15071,4124 +15071,6 @@ exports.mixin = function(object) {
15071
15071
  return $.extend(object, mixin);
15072
15072
  };
15073
15073
 
15074
- });
15075
- require.register("chaijs-assertion-error/index.js", function(exports, require, module){
15076
- /*!
15077
- * assertion-error
15078
- * Copyright(c) 2013 Jake Luer <jake@qualiancy.com>
15079
- * MIT Licensed
15080
- */
15081
-
15082
- /*!
15083
- * Return a function that will copy properties from
15084
- * one object to another excluding any originally
15085
- * listed. Returned function will create a new `{}`.
15086
- *
15087
- * @param {String} excluded properties ...
15088
- * @return {Function}
15089
- */
15090
-
15091
- function exclude () {
15092
- var excludes = [].slice.call(arguments);
15093
-
15094
- function excludeProps (res, obj) {
15095
- Object.keys(obj).forEach(function (key) {
15096
- if (!~excludes.indexOf(key)) res[key] = obj[key];
15097
- });
15098
- }
15099
-
15100
- return function extendExclude () {
15101
- var args = [].slice.call(arguments)
15102
- , i = 0
15103
- , res = {};
15104
-
15105
- for (; i < args.length; i++) {
15106
- excludeProps(res, args[i]);
15107
- }
15108
-
15109
- return res;
15110
- };
15111
- };
15112
-
15113
- /*!
15114
- * Primary Exports
15115
- */
15116
-
15117
- module.exports = AssertionError;
15118
-
15119
- /**
15120
- * ### AssertionError
15121
- *
15122
- * An extension of the JavaScript `Error` constructor for
15123
- * assertion and validation scenarios.
15124
- *
15125
- * @param {String} message
15126
- * @param {Object} properties to include (optional)
15127
- * @param {callee} start stack function (optional)
15128
- */
15129
-
15130
- function AssertionError (message, _props, ssf) {
15131
- var extend = exclude('name', 'message', 'stack', 'constructor', 'toJSON')
15132
- , props = extend(_props || {});
15133
-
15134
- // default values
15135
- this.message = message || 'Unspecified AssertionError';
15136
- this.showDiff = false;
15137
-
15138
- // copy from properties
15139
- for (var key in props) {
15140
- this[key] = props[key];
15141
- }
15142
-
15143
- // capture stack trace
15144
- ssf = ssf || arguments.callee;
15145
- if (ssf && Error.captureStackTrace) {
15146
- Error.captureStackTrace(this, ssf);
15147
- }
15148
- }
15149
-
15150
- /*!
15151
- * Inherit from Error.prototype
15152
- */
15153
-
15154
- AssertionError.prototype = Object.create(Error.prototype);
15155
-
15156
- /*!
15157
- * Statically set name
15158
- */
15159
-
15160
- AssertionError.prototype.name = 'AssertionError';
15161
-
15162
- /*!
15163
- * Ensure correct constructor
15164
- */
15165
-
15166
- AssertionError.prototype.constructor = AssertionError;
15167
-
15168
- /**
15169
- * Allow errors to be converted to JSON for static transfer.
15170
- *
15171
- * @param {Boolean} include stack (default: `true`)
15172
- * @return {Object} object that can be `JSON.stringify`
15173
- */
15174
-
15175
- AssertionError.prototype.toJSON = function (stack) {
15176
- var extend = exclude('constructor', 'toJSON', 'stack')
15177
- , props = extend({ name: this.name }, this);
15178
-
15179
- // include stack if exists and not turned off
15180
- if (false !== stack && this.stack) {
15181
- props.stack = this.stack;
15182
- }
15183
-
15184
- return props;
15185
- };
15186
-
15187
- });
15188
- require.register("chaijs-chai/index.js", function(exports, require, module){
15189
- module.exports = require('./lib/chai');
15190
-
15191
- });
15192
- require.register("chaijs-chai/lib/chai.js", function(exports, require, module){
15193
- /*!
15194
- * chai
15195
- * Copyright(c) 2011-2013 Jake Luer <jake@alogicalparadox.com>
15196
- * MIT Licensed
15197
- */
15198
-
15199
- var used = []
15200
- , exports = module.exports = {};
15201
-
15202
- /*!
15203
- * Chai version
15204
- */
15205
-
15206
- exports.version = '1.7.2';
15207
-
15208
- /*!
15209
- * Assertion Error
15210
- */
15211
-
15212
- exports.AssertionError = require('assertion-error');
15213
-
15214
- /*!
15215
- * Utils for plugins (not exported)
15216
- */
15217
-
15218
- var util = require('./chai/utils');
15219
-
15220
- /**
15221
- * # .use(function)
15222
- *
15223
- * Provides a way to extend the internals of Chai
15224
- *
15225
- * @param {Function}
15226
- * @returns {this} for chaining
15227
- * @api public
15228
- */
15229
-
15230
- exports.use = function (fn) {
15231
- if (!~used.indexOf(fn)) {
15232
- fn(this, util);
15233
- used.push(fn);
15234
- }
15235
-
15236
- return this;
15237
- };
15238
-
15239
- /*!
15240
- * Primary `Assertion` prototype
15241
- */
15242
-
15243
- var assertion = require('./chai/assertion');
15244
- exports.use(assertion);
15245
-
15246
- /*!
15247
- * Core Assertions
15248
- */
15249
-
15250
- var core = require('./chai/core/assertions');
15251
- exports.use(core);
15252
-
15253
- /*!
15254
- * Expect interface
15255
- */
15256
-
15257
- var expect = require('./chai/interface/expect');
15258
- exports.use(expect);
15259
-
15260
- /*!
15261
- * Should interface
15262
- */
15263
-
15264
- var should = require('./chai/interface/should');
15265
- exports.use(should);
15266
-
15267
- /*!
15268
- * Assert interface
15269
- */
15270
-
15271
- var assert = require('./chai/interface/assert');
15272
- exports.use(assert);
15273
-
15274
- });
15275
- require.register("chaijs-chai/lib/chai/assertion.js", function(exports, require, module){
15276
- /*!
15277
- * chai
15278
- * http://chaijs.com
15279
- * Copyright(c) 2011-2013 Jake Luer <jake@alogicalparadox.com>
15280
- * MIT Licensed
15281
- */
15282
-
15283
- module.exports = function (_chai, util) {
15284
- /*!
15285
- * Module dependencies.
15286
- */
15287
-
15288
- var AssertionError = _chai.AssertionError
15289
- , flag = util.flag;
15290
-
15291
- /*!
15292
- * Module export.
15293
- */
15294
-
15295
- _chai.Assertion = Assertion;
15296
-
15297
- /*!
15298
- * Assertion Constructor
15299
- *
15300
- * Creates object for chaining.
15301
- *
15302
- * @api private
15303
- */
15304
-
15305
- function Assertion (obj, msg, stack) {
15306
- flag(this, 'ssfi', stack || arguments.callee);
15307
- flag(this, 'object', obj);
15308
- flag(this, 'message', msg);
15309
- }
15310
-
15311
- /*!
15312
- * ### Assertion.includeStack
15313
- *
15314
- * User configurable property, influences whether stack trace
15315
- * is included in Assertion error message. Default of false
15316
- * suppresses stack trace in the error message
15317
- *
15318
- * Assertion.includeStack = true; // enable stack on error
15319
- *
15320
- * @api public
15321
- */
15322
-
15323
- Assertion.includeStack = false;
15324
-
15325
- /*!
15326
- * ### Assertion.showDiff
15327
- *
15328
- * User configurable property, influences whether or not
15329
- * the `showDiff` flag should be included in the thrown
15330
- * AssertionErrors. `false` will always be `false`; `true`
15331
- * will be true when the assertion has requested a diff
15332
- * be shown.
15333
- *
15334
- * @api public
15335
- */
15336
-
15337
- Assertion.showDiff = true;
15338
-
15339
- Assertion.addProperty = function (name, fn) {
15340
- util.addProperty(this.prototype, name, fn);
15341
- };
15342
-
15343
- Assertion.addMethod = function (name, fn) {
15344
- util.addMethod(this.prototype, name, fn);
15345
- };
15346
-
15347
- Assertion.addChainableMethod = function (name, fn, chainingBehavior) {
15348
- util.addChainableMethod(this.prototype, name, fn, chainingBehavior);
15349
- };
15350
-
15351
- Assertion.overwriteProperty = function (name, fn) {
15352
- util.overwriteProperty(this.prototype, name, fn);
15353
- };
15354
-
15355
- Assertion.overwriteMethod = function (name, fn) {
15356
- util.overwriteMethod(this.prototype, name, fn);
15357
- };
15358
-
15359
- /*!
15360
- * ### .assert(expression, message, negateMessage, expected, actual)
15361
- *
15362
- * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
15363
- *
15364
- * @name assert
15365
- * @param {Philosophical} expression to be tested
15366
- * @param {String} message to display if fails
15367
- * @param {String} negatedMessage to display if negated expression fails
15368
- * @param {Mixed} expected value (remember to check for negation)
15369
- * @param {Mixed} actual (optional) will default to `this.obj`
15370
- * @api private
15371
- */
15372
-
15373
- Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) {
15374
- var ok = util.test(this, arguments);
15375
- if (true !== showDiff) showDiff = false;
15376
- if (true !== Assertion.showDiff) showDiff = false;
15377
-
15378
- if (!ok) {
15379
- var msg = util.getMessage(this, arguments)
15380
- , actual = util.getActual(this, arguments);
15381
- throw new AssertionError(msg, {
15382
- actual: actual
15383
- , expected: expected
15384
- , showDiff: showDiff
15385
- }, (Assertion.includeStack) ? this.assert : flag(this, 'ssfi'));
15386
- }
15387
- };
15388
-
15389
- /*!
15390
- * ### ._obj
15391
- *
15392
- * Quick reference to stored `actual` value for plugin developers.
15393
- *
15394
- * @api private
15395
- */
15396
-
15397
- Object.defineProperty(Assertion.prototype, '_obj',
15398
- { get: function () {
15399
- return flag(this, 'object');
15400
- }
15401
- , set: function (val) {
15402
- flag(this, 'object', val);
15403
- }
15404
- });
15405
- };
15406
-
15407
- });
15408
- require.register("chaijs-chai/lib/chai/core/assertions.js", function(exports, require, module){
15409
- /*!
15410
- * chai
15411
- * http://chaijs.com
15412
- * Copyright(c) 2011-2013 Jake Luer <jake@alogicalparadox.com>
15413
- * MIT Licensed
15414
- */
15415
-
15416
- module.exports = function (chai, _) {
15417
- var Assertion = chai.Assertion
15418
- , toString = Object.prototype.toString
15419
- , flag = _.flag;
15420
-
15421
- /**
15422
- * ### Language Chains
15423
- *
15424
- * The following are provide as chainable getters to
15425
- * improve the readability of your assertions. They
15426
- * do not provide an testing capability unless they
15427
- * have been overwritten by a plugin.
15428
- *
15429
- * **Chains**
15430
- *
15431
- * - to
15432
- * - be
15433
- * - been
15434
- * - is
15435
- * - that
15436
- * - and
15437
- * - have
15438
- * - with
15439
- * - at
15440
- * - of
15441
- * - same
15442
- *
15443
- * @name language chains
15444
- * @api public
15445
- */
15446
-
15447
- [ 'to', 'be', 'been'
15448
- , 'is', 'and', 'have'
15449
- , 'with', 'that', 'at'
15450
- , 'of', 'same' ].forEach(function (chain) {
15451
- Assertion.addProperty(chain, function () {
15452
- return this;
15453
- });
15454
- });
15455
-
15456
- /**
15457
- * ### .not
15458
- *
15459
- * Negates any of assertions following in the chain.
15460
- *
15461
- * expect(foo).to.not.equal('bar');
15462
- * expect(goodFn).to.not.throw(Error);
15463
- * expect({ foo: 'baz' }).to.have.property('foo')
15464
- * .and.not.equal('bar');
15465
- *
15466
- * @name not
15467
- * @api public
15468
- */
15469
-
15470
- Assertion.addProperty('not', function () {
15471
- flag(this, 'negate', true);
15472
- });
15473
-
15474
- /**
15475
- * ### .deep
15476
- *
15477
- * Sets the `deep` flag, later used by the `equal` and
15478
- * `property` assertions.
15479
- *
15480
- * expect(foo).to.deep.equal({ bar: 'baz' });
15481
- * expect({ foo: { bar: { baz: 'quux' } } })
15482
- * .to.have.deep.property('foo.bar.baz', 'quux');
15483
- *
15484
- * @name deep
15485
- * @api public
15486
- */
15487
-
15488
- Assertion.addProperty('deep', function () {
15489
- flag(this, 'deep', true);
15490
- });
15491
-
15492
- /**
15493
- * ### .a(type)
15494
- *
15495
- * The `a` and `an` assertions are aliases that can be
15496
- * used either as language chains or to assert a value's
15497
- * type.
15498
- *
15499
- * // typeof
15500
- * expect('test').to.be.a('string');
15501
- * expect({ foo: 'bar' }).to.be.an('object');
15502
- * expect(null).to.be.a('null');
15503
- * expect(undefined).to.be.an('undefined');
15504
- *
15505
- * // language chain
15506
- * expect(foo).to.be.an.instanceof(Foo);
15507
- *
15508
- * @name a
15509
- * @alias an
15510
- * @param {String} type
15511
- * @param {String} message _optional_
15512
- * @api public
15513
- */
15514
-
15515
- function an (type, msg) {
15516
- if (msg) flag(this, 'message', msg);
15517
- type = type.toLowerCase();
15518
- var obj = flag(this, 'object')
15519
- , article = ~[ 'a', 'e', 'i', 'o', 'u' ].indexOf(type.charAt(0)) ? 'an ' : 'a ';
15520
-
15521
- this.assert(
15522
- type === _.type(obj)
15523
- , 'expected #{this} to be ' + article + type
15524
- , 'expected #{this} not to be ' + article + type
15525
- );
15526
- }
15527
-
15528
- Assertion.addChainableMethod('an', an);
15529
- Assertion.addChainableMethod('a', an);
15530
-
15531
- /**
15532
- * ### .include(value)
15533
- *
15534
- * The `include` and `contain` assertions can be used as either property
15535
- * based language chains or as methods to assert the inclusion of an object
15536
- * in an array or a substring in a string. When used as language chains,
15537
- * they toggle the `contain` flag for the `keys` assertion.
15538
- *
15539
- * expect([1,2,3]).to.include(2);
15540
- * expect('foobar').to.contain('foo');
15541
- * expect({ foo: 'bar', hello: 'universe' }).to.include.keys('foo');
15542
- *
15543
- * @name include
15544
- * @alias contain
15545
- * @param {Object|String|Number} obj
15546
- * @param {String} message _optional_
15547
- * @api public
15548
- */
15549
-
15550
- function includeChainingBehavior () {
15551
- flag(this, 'contains', true);
15552
- }
15553
-
15554
- function include (val, msg) {
15555
- if (msg) flag(this, 'message', msg);
15556
- var obj = flag(this, 'object')
15557
- this.assert(
15558
- ~obj.indexOf(val)
15559
- , 'expected #{this} to include ' + _.inspect(val)
15560
- , 'expected #{this} to not include ' + _.inspect(val));
15561
- }
15562
-
15563
- Assertion.addChainableMethod('include', include, includeChainingBehavior);
15564
- Assertion.addChainableMethod('contain', include, includeChainingBehavior);
15565
-
15566
- /**
15567
- * ### .ok
15568
- *
15569
- * Asserts that the target is truthy.
15570
- *
15571
- * expect('everthing').to.be.ok;
15572
- * expect(1).to.be.ok;
15573
- * expect(false).to.not.be.ok;
15574
- * expect(undefined).to.not.be.ok;
15575
- * expect(null).to.not.be.ok;
15576
- *
15577
- * @name ok
15578
- * @api public
15579
- */
15580
-
15581
- Assertion.addProperty('ok', function () {
15582
- this.assert(
15583
- flag(this, 'object')
15584
- , 'expected #{this} to be truthy'
15585
- , 'expected #{this} to be falsy');
15586
- });
15587
-
15588
- /**
15589
- * ### .true
15590
- *
15591
- * Asserts that the target is `true`.
15592
- *
15593
- * expect(true).to.be.true;
15594
- * expect(1).to.not.be.true;
15595
- *
15596
- * @name true
15597
- * @api public
15598
- */
15599
-
15600
- Assertion.addProperty('true', function () {
15601
- this.assert(
15602
- true === flag(this, 'object')
15603
- , 'expected #{this} to be true'
15604
- , 'expected #{this} to be false'
15605
- , this.negate ? false : true
15606
- );
15607
- });
15608
-
15609
- /**
15610
- * ### .false
15611
- *
15612
- * Asserts that the target is `false`.
15613
- *
15614
- * expect(false).to.be.false;
15615
- * expect(0).to.not.be.false;
15616
- *
15617
- * @name false
15618
- * @api public
15619
- */
15620
-
15621
- Assertion.addProperty('false', function () {
15622
- this.assert(
15623
- false === flag(this, 'object')
15624
- , 'expected #{this} to be false'
15625
- , 'expected #{this} to be true'
15626
- , this.negate ? true : false
15627
- );
15628
- });
15629
-
15630
- /**
15631
- * ### .null
15632
- *
15633
- * Asserts that the target is `null`.
15634
- *
15635
- * expect(null).to.be.null;
15636
- * expect(undefined).not.to.be.null;
15637
- *
15638
- * @name null
15639
- * @api public
15640
- */
15641
-
15642
- Assertion.addProperty('null', function () {
15643
- this.assert(
15644
- null === flag(this, 'object')
15645
- , 'expected #{this} to be null'
15646
- , 'expected #{this} not to be null'
15647
- );
15648
- });
15649
-
15650
- /**
15651
- * ### .undefined
15652
- *
15653
- * Asserts that the target is `undefined`.
15654
- *
15655
- * expect(undefined).to.be.undefined;
15656
- * expect(null).to.not.be.undefined;
15657
- *
15658
- * @name undefined
15659
- * @api public
15660
- */
15661
-
15662
- Assertion.addProperty('undefined', function () {
15663
- this.assert(
15664
- undefined === flag(this, 'object')
15665
- , 'expected #{this} to be undefined'
15666
- , 'expected #{this} not to be undefined'
15667
- );
15668
- });
15669
-
15670
- /**
15671
- * ### .exist
15672
- *
15673
- * Asserts that the target is neither `null` nor `undefined`.
15674
- *
15675
- * var foo = 'hi'
15676
- * , bar = null
15677
- * , baz;
15678
- *
15679
- * expect(foo).to.exist;
15680
- * expect(bar).to.not.exist;
15681
- * expect(baz).to.not.exist;
15682
- *
15683
- * @name exist
15684
- * @api public
15685
- */
15686
-
15687
- Assertion.addProperty('exist', function () {
15688
- this.assert(
15689
- null != flag(this, 'object')
15690
- , 'expected #{this} to exist'
15691
- , 'expected #{this} to not exist'
15692
- );
15693
- });
15694
-
15695
-
15696
- /**
15697
- * ### .empty
15698
- *
15699
- * Asserts that the target's length is `0`. For arrays, it checks
15700
- * the `length` property. For objects, it gets the count of
15701
- * enumerable keys.
15702
- *
15703
- * expect([]).to.be.empty;
15704
- * expect('').to.be.empty;
15705
- * expect({}).to.be.empty;
15706
- *
15707
- * @name empty
15708
- * @api public
15709
- */
15710
-
15711
- Assertion.addProperty('empty', function () {
15712
- var obj = flag(this, 'object')
15713
- , expected = obj;
15714
-
15715
- if (Array.isArray(obj) || 'string' === typeof object) {
15716
- expected = obj.length;
15717
- } else if (typeof obj === 'object') {
15718
- expected = Object.keys(obj).length;
15719
- }
15720
-
15721
- this.assert(
15722
- !expected
15723
- , 'expected #{this} to be empty'
15724
- , 'expected #{this} not to be empty'
15725
- );
15726
- });
15727
-
15728
- /**
15729
- * ### .arguments
15730
- *
15731
- * Asserts that the target is an arguments object.
15732
- *
15733
- * function test () {
15734
- * expect(arguments).to.be.arguments;
15735
- * }
15736
- *
15737
- * @name arguments
15738
- * @alias Arguments
15739
- * @api public
15740
- */
15741
-
15742
- function checkArguments () {
15743
- var obj = flag(this, 'object')
15744
- , type = Object.prototype.toString.call(obj);
15745
- this.assert(
15746
- '[object Arguments]' === type
15747
- , 'expected #{this} to be arguments but got ' + type
15748
- , 'expected #{this} to not be arguments'
15749
- );
15750
- }
15751
-
15752
- Assertion.addProperty('arguments', checkArguments);
15753
- Assertion.addProperty('Arguments', checkArguments);
15754
-
15755
- /**
15756
- * ### .equal(value)
15757
- *
15758
- * Asserts that the target is strictly equal (`===`) to `value`.
15759
- * Alternately, if the `deep` flag is set, asserts that
15760
- * the target is deeply equal to `value`.
15761
- *
15762
- * expect('hello').to.equal('hello');
15763
- * expect(42).to.equal(42);
15764
- * expect(1).to.not.equal(true);
15765
- * expect({ foo: 'bar' }).to.not.equal({ foo: 'bar' });
15766
- * expect({ foo: 'bar' }).to.deep.equal({ foo: 'bar' });
15767
- *
15768
- * @name equal
15769
- * @alias equals
15770
- * @alias eq
15771
- * @alias deep.equal
15772
- * @param {Mixed} value
15773
- * @param {String} message _optional_
15774
- * @api public
15775
- */
15776
-
15777
- function assertEqual (val, msg) {
15778
- if (msg) flag(this, 'message', msg);
15779
- var obj = flag(this, 'object');
15780
- if (flag(this, 'deep')) {
15781
- return this.eql(val);
15782
- } else {
15783
- this.assert(
15784
- val === obj
15785
- , 'expected #{this} to equal #{exp}'
15786
- , 'expected #{this} to not equal #{exp}'
15787
- , val
15788
- , this._obj
15789
- , true
15790
- );
15791
- }
15792
- }
15793
-
15794
- Assertion.addMethod('equal', assertEqual);
15795
- Assertion.addMethod('equals', assertEqual);
15796
- Assertion.addMethod('eq', assertEqual);
15797
-
15798
- /**
15799
- * ### .eql(value)
15800
- *
15801
- * Asserts that the target is deeply equal to `value`.
15802
- *
15803
- * expect({ foo: 'bar' }).to.eql({ foo: 'bar' });
15804
- * expect([ 1, 2, 3 ]).to.eql([ 1, 2, 3 ]);
15805
- *
15806
- * @name eql
15807
- * @alias eqls
15808
- * @param {Mixed} value
15809
- * @param {String} message _optional_
15810
- * @api public
15811
- */
15812
-
15813
- function assertEql(obj, msg) {
15814
- if (msg) flag(this, 'message', msg);
15815
- this.assert(
15816
- _.eql(obj, flag(this, 'object'))
15817
- , 'expected #{this} to deeply equal #{exp}'
15818
- , 'expected #{this} to not deeply equal #{exp}'
15819
- , obj
15820
- , this._obj
15821
- , true
15822
- );
15823
- }
15824
-
15825
- Assertion.addMethod('eql', assertEql);
15826
- Assertion.addMethod('eqls', assertEql);
15827
-
15828
- /**
15829
- * ### .above(value)
15830
- *
15831
- * Asserts that the target is greater than `value`.
15832
- *
15833
- * expect(10).to.be.above(5);
15834
- *
15835
- * Can also be used in conjunction with `length` to
15836
- * assert a minimum length. The benefit being a
15837
- * more informative error message than if the length
15838
- * was supplied directly.
15839
- *
15840
- * expect('foo').to.have.length.above(2);
15841
- * expect([ 1, 2, 3 ]).to.have.length.above(2);
15842
- *
15843
- * @name above
15844
- * @alias gt
15845
- * @alias greaterThan
15846
- * @param {Number} value
15847
- * @param {String} message _optional_
15848
- * @api public
15849
- */
15850
-
15851
- function assertAbove (n, msg) {
15852
- if (msg) flag(this, 'message', msg);
15853
- var obj = flag(this, 'object');
15854
- if (flag(this, 'doLength')) {
15855
- new Assertion(obj, msg).to.have.property('length');
15856
- var len = obj.length;
15857
- this.assert(
15858
- len > n
15859
- , 'expected #{this} to have a length above #{exp} but got #{act}'
15860
- , 'expected #{this} to not have a length above #{exp}'
15861
- , n
15862
- , len
15863
- );
15864
- } else {
15865
- this.assert(
15866
- obj > n
15867
- , 'expected #{this} to be above ' + n
15868
- , 'expected #{this} to be at most ' + n
15869
- );
15870
- }
15871
- }
15872
-
15873
- Assertion.addMethod('above', assertAbove);
15874
- Assertion.addMethod('gt', assertAbove);
15875
- Assertion.addMethod('greaterThan', assertAbove);
15876
-
15877
- /**
15878
- * ### .least(value)
15879
- *
15880
- * Asserts that the target is greater than or equal to `value`.
15881
- *
15882
- * expect(10).to.be.at.least(10);
15883
- *
15884
- * Can also be used in conjunction with `length` to
15885
- * assert a minimum length. The benefit being a
15886
- * more informative error message than if the length
15887
- * was supplied directly.
15888
- *
15889
- * expect('foo').to.have.length.of.at.least(2);
15890
- * expect([ 1, 2, 3 ]).to.have.length.of.at.least(3);
15891
- *
15892
- * @name least
15893
- * @alias gte
15894
- * @param {Number} value
15895
- * @param {String} message _optional_
15896
- * @api public
15897
- */
15898
-
15899
- function assertLeast (n, msg) {
15900
- if (msg) flag(this, 'message', msg);
15901
- var obj = flag(this, 'object');
15902
- if (flag(this, 'doLength')) {
15903
- new Assertion(obj, msg).to.have.property('length');
15904
- var len = obj.length;
15905
- this.assert(
15906
- len >= n
15907
- , 'expected #{this} to have a length at least #{exp} but got #{act}'
15908
- , 'expected #{this} to have a length below #{exp}'
15909
- , n
15910
- , len
15911
- );
15912
- } else {
15913
- this.assert(
15914
- obj >= n
15915
- , 'expected #{this} to be at least ' + n
15916
- , 'expected #{this} to be below ' + n
15917
- );
15918
- }
15919
- }
15920
-
15921
- Assertion.addMethod('least', assertLeast);
15922
- Assertion.addMethod('gte', assertLeast);
15923
-
15924
- /**
15925
- * ### .below(value)
15926
- *
15927
- * Asserts that the target is less than `value`.
15928
- *
15929
- * expect(5).to.be.below(10);
15930
- *
15931
- * Can also be used in conjunction with `length` to
15932
- * assert a maximum length. The benefit being a
15933
- * more informative error message than if the length
15934
- * was supplied directly.
15935
- *
15936
- * expect('foo').to.have.length.below(4);
15937
- * expect([ 1, 2, 3 ]).to.have.length.below(4);
15938
- *
15939
- * @name below
15940
- * @alias lt
15941
- * @alias lessThan
15942
- * @param {Number} value
15943
- * @param {String} message _optional_
15944
- * @api public
15945
- */
15946
-
15947
- function assertBelow (n, msg) {
15948
- if (msg) flag(this, 'message', msg);
15949
- var obj = flag(this, 'object');
15950
- if (flag(this, 'doLength')) {
15951
- new Assertion(obj, msg).to.have.property('length');
15952
- var len = obj.length;
15953
- this.assert(
15954
- len < n
15955
- , 'expected #{this} to have a length below #{exp} but got #{act}'
15956
- , 'expected #{this} to not have a length below #{exp}'
15957
- , n
15958
- , len
15959
- );
15960
- } else {
15961
- this.assert(
15962
- obj < n
15963
- , 'expected #{this} to be below ' + n
15964
- , 'expected #{this} to be at least ' + n
15965
- );
15966
- }
15967
- }
15968
-
15969
- Assertion.addMethod('below', assertBelow);
15970
- Assertion.addMethod('lt', assertBelow);
15971
- Assertion.addMethod('lessThan', assertBelow);
15972
-
15973
- /**
15974
- * ### .most(value)
15975
- *
15976
- * Asserts that the target is less than or equal to `value`.
15977
- *
15978
- * expect(5).to.be.at.most(5);
15979
- *
15980
- * Can also be used in conjunction with `length` to
15981
- * assert a maximum length. The benefit being a
15982
- * more informative error message than if the length
15983
- * was supplied directly.
15984
- *
15985
- * expect('foo').to.have.length.of.at.most(4);
15986
- * expect([ 1, 2, 3 ]).to.have.length.of.at.most(3);
15987
- *
15988
- * @name most
15989
- * @alias lte
15990
- * @param {Number} value
15991
- * @param {String} message _optional_
15992
- * @api public
15993
- */
15994
-
15995
- function assertMost (n, msg) {
15996
- if (msg) flag(this, 'message', msg);
15997
- var obj = flag(this, 'object');
15998
- if (flag(this, 'doLength')) {
15999
- new Assertion(obj, msg).to.have.property('length');
16000
- var len = obj.length;
16001
- this.assert(
16002
- len <= n
16003
- , 'expected #{this} to have a length at most #{exp} but got #{act}'
16004
- , 'expected #{this} to have a length above #{exp}'
16005
- , n
16006
- , len
16007
- );
16008
- } else {
16009
- this.assert(
16010
- obj <= n
16011
- , 'expected #{this} to be at most ' + n
16012
- , 'expected #{this} to be above ' + n
16013
- );
16014
- }
16015
- }
16016
-
16017
- Assertion.addMethod('most', assertMost);
16018
- Assertion.addMethod('lte', assertMost);
16019
-
16020
- /**
16021
- * ### .within(start, finish)
16022
- *
16023
- * Asserts that the target is within a range.
16024
- *
16025
- * expect(7).to.be.within(5,10);
16026
- *
16027
- * Can also be used in conjunction with `length` to
16028
- * assert a length range. The benefit being a
16029
- * more informative error message than if the length
16030
- * was supplied directly.
16031
- *
16032
- * expect('foo').to.have.length.within(2,4);
16033
- * expect([ 1, 2, 3 ]).to.have.length.within(2,4);
16034
- *
16035
- * @name within
16036
- * @param {Number} start lowerbound inclusive
16037
- * @param {Number} finish upperbound inclusive
16038
- * @param {String} message _optional_
16039
- * @api public
16040
- */
16041
-
16042
- Assertion.addMethod('within', function (start, finish, msg) {
16043
- if (msg) flag(this, 'message', msg);
16044
- var obj = flag(this, 'object')
16045
- , range = start + '..' + finish;
16046
- if (flag(this, 'doLength')) {
16047
- new Assertion(obj, msg).to.have.property('length');
16048
- var len = obj.length;
16049
- this.assert(
16050
- len >= start && len <= finish
16051
- , 'expected #{this} to have a length within ' + range
16052
- , 'expected #{this} to not have a length within ' + range
16053
- );
16054
- } else {
16055
- this.assert(
16056
- obj >= start && obj <= finish
16057
- , 'expected #{this} to be within ' + range
16058
- , 'expected #{this} to not be within ' + range
16059
- );
16060
- }
16061
- });
16062
-
16063
- /**
16064
- * ### .instanceof(constructor)
16065
- *
16066
- * Asserts that the target is an instance of `constructor`.
16067
- *
16068
- * var Tea = function (name) { this.name = name; }
16069
- * , Chai = new Tea('chai');
16070
- *
16071
- * expect(Chai).to.be.an.instanceof(Tea);
16072
- * expect([ 1, 2, 3 ]).to.be.instanceof(Array);
16073
- *
16074
- * @name instanceof
16075
- * @param {Constructor} constructor
16076
- * @param {String} message _optional_
16077
- * @alias instanceOf
16078
- * @api public
16079
- */
16080
-
16081
- function assertInstanceOf (constructor, msg) {
16082
- if (msg) flag(this, 'message', msg);
16083
- var name = _.getName(constructor);
16084
- this.assert(
16085
- flag(this, 'object') instanceof constructor
16086
- , 'expected #{this} to be an instance of ' + name
16087
- , 'expected #{this} to not be an instance of ' + name
16088
- );
16089
- };
16090
-
16091
- Assertion.addMethod('instanceof', assertInstanceOf);
16092
- Assertion.addMethod('instanceOf', assertInstanceOf);
16093
-
16094
- /**
16095
- * ### .property(name, [value])
16096
- *
16097
- * Asserts that the target has a property `name`, optionally asserting that
16098
- * the value of that property is strictly equal to `value`.
16099
- * If the `deep` flag is set, you can use dot- and bracket-notation for deep
16100
- * references into objects and arrays.
16101
- *
16102
- * // simple referencing
16103
- * var obj = { foo: 'bar' };
16104
- * expect(obj).to.have.property('foo');
16105
- * expect(obj).to.have.property('foo', 'bar');
16106
- *
16107
- * // deep referencing
16108
- * var deepObj = {
16109
- * green: { tea: 'matcha' }
16110
- * , teas: [ 'chai', 'matcha', { tea: 'konacha' } ]
16111
- * };
16112
-
16113
- * expect(deepObj).to.have.deep.property('green.tea', 'matcha');
16114
- * expect(deepObj).to.have.deep.property('teas[1]', 'matcha');
16115
- * expect(deepObj).to.have.deep.property('teas[2].tea', 'konacha');
16116
- *
16117
- * You can also use an array as the starting point of a `deep.property`
16118
- * assertion, or traverse nested arrays.
16119
- *
16120
- * var arr = [
16121
- * [ 'chai', 'matcha', 'konacha' ]
16122
- * , [ { tea: 'chai' }
16123
- * , { tea: 'matcha' }
16124
- * , { tea: 'konacha' } ]
16125
- * ];
16126
- *
16127
- * expect(arr).to.have.deep.property('[0][1]', 'matcha');
16128
- * expect(arr).to.have.deep.property('[1][2].tea', 'konacha');
16129
- *
16130
- * Furthermore, `property` changes the subject of the assertion
16131
- * to be the value of that property from the original object. This
16132
- * permits for further chainable assertions on that property.
16133
- *
16134
- * expect(obj).to.have.property('foo')
16135
- * .that.is.a('string');
16136
- * expect(deepObj).to.have.property('green')
16137
- * .that.is.an('object')
16138
- * .that.deep.equals({ tea: 'matcha' });
16139
- * expect(deepObj).to.have.property('teas')
16140
- * .that.is.an('array')
16141
- * .with.deep.property('[2]')
16142
- * .that.deep.equals({ tea: 'konacha' });
16143
- *
16144
- * @name property
16145
- * @alias deep.property
16146
- * @param {String} name
16147
- * @param {Mixed} value (optional)
16148
- * @param {String} message _optional_
16149
- * @returns value of property for chaining
16150
- * @api public
16151
- */
16152
-
16153
- Assertion.addMethod('property', function (name, val, msg) {
16154
- if (msg) flag(this, 'message', msg);
16155
-
16156
- var descriptor = flag(this, 'deep') ? 'deep property ' : 'property '
16157
- , negate = flag(this, 'negate')
16158
- , obj = flag(this, 'object')
16159
- , value = flag(this, 'deep')
16160
- ? _.getPathValue(name, obj)
16161
- : obj[name];
16162
-
16163
- if (negate && undefined !== val) {
16164
- if (undefined === value) {
16165
- msg = (msg != null) ? msg + ': ' : '';
16166
- throw new Error(msg + _.inspect(obj) + ' has no ' + descriptor + _.inspect(name));
16167
- }
16168
- } else {
16169
- this.assert(
16170
- undefined !== value
16171
- , 'expected #{this} to have a ' + descriptor + _.inspect(name)
16172
- , 'expected #{this} to not have ' + descriptor + _.inspect(name));
16173
- }
16174
-
16175
- if (undefined !== val) {
16176
- this.assert(
16177
- val === value
16178
- , 'expected #{this} to have a ' + descriptor + _.inspect(name) + ' of #{exp}, but got #{act}'
16179
- , 'expected #{this} to not have a ' + descriptor + _.inspect(name) + ' of #{act}'
16180
- , val
16181
- , value
16182
- );
16183
- }
16184
-
16185
- flag(this, 'object', value);
16186
- });
16187
-
16188
-
16189
- /**
16190
- * ### .ownProperty(name)
16191
- *
16192
- * Asserts that the target has an own property `name`.
16193
- *
16194
- * expect('test').to.have.ownProperty('length');
16195
- *
16196
- * @name ownProperty
16197
- * @alias haveOwnProperty
16198
- * @param {String} name
16199
- * @param {String} message _optional_
16200
- * @api public
16201
- */
16202
-
16203
- function assertOwnProperty (name, msg) {
16204
- if (msg) flag(this, 'message', msg);
16205
- var obj = flag(this, 'object');
16206
- this.assert(
16207
- obj.hasOwnProperty(name)
16208
- , 'expected #{this} to have own property ' + _.inspect(name)
16209
- , 'expected #{this} to not have own property ' + _.inspect(name)
16210
- );
16211
- }
16212
-
16213
- Assertion.addMethod('ownProperty', assertOwnProperty);
16214
- Assertion.addMethod('haveOwnProperty', assertOwnProperty);
16215
-
16216
- /**
16217
- * ### .length(value)
16218
- *
16219
- * Asserts that the target's `length` property has
16220
- * the expected value.
16221
- *
16222
- * expect([ 1, 2, 3]).to.have.length(3);
16223
- * expect('foobar').to.have.length(6);
16224
- *
16225
- * Can also be used as a chain precursor to a value
16226
- * comparison for the length property.
16227
- *
16228
- * expect('foo').to.have.length.above(2);
16229
- * expect([ 1, 2, 3 ]).to.have.length.above(2);
16230
- * expect('foo').to.have.length.below(4);
16231
- * expect([ 1, 2, 3 ]).to.have.length.below(4);
16232
- * expect('foo').to.have.length.within(2,4);
16233
- * expect([ 1, 2, 3 ]).to.have.length.within(2,4);
16234
- *
16235
- * @name length
16236
- * @alias lengthOf
16237
- * @param {Number} length
16238
- * @param {String} message _optional_
16239
- * @api public
16240
- */
16241
-
16242
- function assertLengthChain () {
16243
- flag(this, 'doLength', true);
16244
- }
16245
-
16246
- function assertLength (n, msg) {
16247
- if (msg) flag(this, 'message', msg);
16248
- var obj = flag(this, 'object');
16249
- new Assertion(obj, msg).to.have.property('length');
16250
- var len = obj.length;
16251
-
16252
- this.assert(
16253
- len == n
16254
- , 'expected #{this} to have a length of #{exp} but got #{act}'
16255
- , 'expected #{this} to not have a length of #{act}'
16256
- , n
16257
- , len
16258
- );
16259
- }
16260
-
16261
- Assertion.addChainableMethod('length', assertLength, assertLengthChain);
16262
- Assertion.addMethod('lengthOf', assertLength, assertLengthChain);
16263
-
16264
- /**
16265
- * ### .match(regexp)
16266
- *
16267
- * Asserts that the target matches a regular expression.
16268
- *
16269
- * expect('foobar').to.match(/^foo/);
16270
- *
16271
- * @name match
16272
- * @param {RegExp} RegularExpression
16273
- * @param {String} message _optional_
16274
- * @api public
16275
- */
16276
-
16277
- Assertion.addMethod('match', function (re, msg) {
16278
- if (msg) flag(this, 'message', msg);
16279
- var obj = flag(this, 'object');
16280
- this.assert(
16281
- re.exec(obj)
16282
- , 'expected #{this} to match ' + re
16283
- , 'expected #{this} not to match ' + re
16284
- );
16285
- });
16286
-
16287
- /**
16288
- * ### .string(string)
16289
- *
16290
- * Asserts that the string target contains another string.
16291
- *
16292
- * expect('foobar').to.have.string('bar');
16293
- *
16294
- * @name string
16295
- * @param {String} string
16296
- * @param {String} message _optional_
16297
- * @api public
16298
- */
16299
-
16300
- Assertion.addMethod('string', function (str, msg) {
16301
- if (msg) flag(this, 'message', msg);
16302
- var obj = flag(this, 'object');
16303
- new Assertion(obj, msg).is.a('string');
16304
-
16305
- this.assert(
16306
- ~obj.indexOf(str)
16307
- , 'expected #{this} to contain ' + _.inspect(str)
16308
- , 'expected #{this} to not contain ' + _.inspect(str)
16309
- );
16310
- });
16311
-
16312
-
16313
- /**
16314
- * ### .keys(key1, [key2], [...])
16315
- *
16316
- * Asserts that the target has exactly the given keys, or
16317
- * asserts the inclusion of some keys when using the
16318
- * `include` or `contain` modifiers.
16319
- *
16320
- * expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']);
16321
- * expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar');
16322
- *
16323
- * @name keys
16324
- * @alias key
16325
- * @param {String...|Array} keys
16326
- * @api public
16327
- */
16328
-
16329
- function assertKeys (keys) {
16330
- var obj = flag(this, 'object')
16331
- , str
16332
- , ok = true;
16333
-
16334
- keys = keys instanceof Array
16335
- ? keys
16336
- : Array.prototype.slice.call(arguments);
16337
-
16338
- if (!keys.length) throw new Error('keys required');
16339
-
16340
- var actual = Object.keys(obj)
16341
- , len = keys.length;
16342
-
16343
- // Inclusion
16344
- ok = keys.every(function(key){
16345
- return ~actual.indexOf(key);
16346
- });
16347
-
16348
- // Strict
16349
- if (!flag(this, 'negate') && !flag(this, 'contains')) {
16350
- ok = ok && keys.length == actual.length;
16351
- }
16352
-
16353
- // Key string
16354
- if (len > 1) {
16355
- keys = keys.map(function(key){
16356
- return _.inspect(key);
16357
- });
16358
- var last = keys.pop();
16359
- str = keys.join(', ') + ', and ' + last;
16360
- } else {
16361
- str = _.inspect(keys[0]);
16362
- }
16363
-
16364
- // Form
16365
- str = (len > 1 ? 'keys ' : 'key ') + str;
16366
-
16367
- // Have / include
16368
- str = (flag(this, 'contains') ? 'contain ' : 'have ') + str;
16369
-
16370
- // Assertion
16371
- this.assert(
16372
- ok
16373
- , 'expected #{this} to ' + str
16374
- , 'expected #{this} to not ' + str
16375
- );
16376
- }
16377
-
16378
- Assertion.addMethod('keys', assertKeys);
16379
- Assertion.addMethod('key', assertKeys);
16380
-
16381
- /**
16382
- * ### .throw(constructor)
16383
- *
16384
- * Asserts that the function target will throw a specific error, or specific type of error
16385
- * (as determined using `instanceof`), optionally with a RegExp or string inclusion test
16386
- * for the error's message.
16387
- *
16388
- * var err = new ReferenceError('This is a bad function.');
16389
- * var fn = function () { throw err; }
16390
- * expect(fn).to.throw(ReferenceError);
16391
- * expect(fn).to.throw(Error);
16392
- * expect(fn).to.throw(/bad function/);
16393
- * expect(fn).to.not.throw('good function');
16394
- * expect(fn).to.throw(ReferenceError, /bad function/);
16395
- * expect(fn).to.throw(err);
16396
- * expect(fn).to.not.throw(new RangeError('Out of range.'));
16397
- *
16398
- * Please note that when a throw expectation is negated, it will check each
16399
- * parameter independently, starting with error constructor type. The appropriate way
16400
- * to check for the existence of a type of error but for a message that does not match
16401
- * is to use `and`.
16402
- *
16403
- * expect(fn).to.throw(ReferenceError)
16404
- * .and.not.throw(/good function/);
16405
- *
16406
- * @name throw
16407
- * @alias throws
16408
- * @alias Throw
16409
- * @param {ErrorConstructor} constructor
16410
- * @param {String|RegExp} expected error message
16411
- * @param {String} message _optional_
16412
- * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
16413
- * @api public
16414
- */
16415
-
16416
- function assertThrows (constructor, errMsg, msg) {
16417
- if (msg) flag(this, 'message', msg);
16418
- var obj = flag(this, 'object');
16419
- new Assertion(obj, msg).is.a('function');
16420
-
16421
- var thrown = false
16422
- , desiredError = null
16423
- , name = null
16424
- , thrownError = null;
16425
-
16426
- if (arguments.length === 0) {
16427
- errMsg = null;
16428
- constructor = null;
16429
- } else if (constructor && (constructor instanceof RegExp || 'string' === typeof constructor)) {
16430
- errMsg = constructor;
16431
- constructor = null;
16432
- } else if (constructor && constructor instanceof Error) {
16433
- desiredError = constructor;
16434
- constructor = null;
16435
- errMsg = null;
16436
- } else if (typeof constructor === 'function') {
16437
- name = (new constructor()).name;
16438
- } else {
16439
- constructor = null;
16440
- }
16441
-
16442
- try {
16443
- obj();
16444
- } catch (err) {
16445
- // first, check desired error
16446
- if (desiredError) {
16447
- this.assert(
16448
- err === desiredError
16449
- , 'expected #{this} to throw #{exp} but #{act} was thrown'
16450
- , 'expected #{this} to not throw #{exp}'
16451
- , desiredError
16452
- , err
16453
- );
16454
-
16455
- return this;
16456
- }
16457
- // next, check constructor
16458
- if (constructor) {
16459
- this.assert(
16460
- err instanceof constructor
16461
- , 'expected #{this} to throw #{exp} but #{act} was thrown'
16462
- , 'expected #{this} to not throw #{exp} but #{act} was thrown'
16463
- , name
16464
- , err
16465
- );
16466
-
16467
- if (!errMsg) return this;
16468
- }
16469
- // next, check message
16470
- var message = 'object' === _.type(err) && "message" in err
16471
- ? err.message
16472
- : '' + err;
16473
-
16474
- if ((message != null) && errMsg && errMsg instanceof RegExp) {
16475
- this.assert(
16476
- errMsg.exec(message)
16477
- , 'expected #{this} to throw error matching #{exp} but got #{act}'
16478
- , 'expected #{this} to throw error not matching #{exp}'
16479
- , errMsg
16480
- , message
16481
- );
16482
-
16483
- return this;
16484
- } else if ((message != null) && errMsg && 'string' === typeof errMsg) {
16485
- this.assert(
16486
- ~message.indexOf(errMsg)
16487
- , 'expected #{this} to throw error including #{exp} but got #{act}'
16488
- , 'expected #{this} to throw error not including #{act}'
16489
- , errMsg
16490
- , message
16491
- );
16492
-
16493
- return this;
16494
- } else {
16495
- thrown = true;
16496
- thrownError = err;
16497
- }
16498
- }
16499
-
16500
- var actuallyGot = ''
16501
- , expectedThrown = name !== null
16502
- ? name
16503
- : desiredError
16504
- ? '#{exp}' //_.inspect(desiredError)
16505
- : 'an error';
16506
-
16507
- if (thrown) {
16508
- actuallyGot = ' but #{act} was thrown'
16509
- }
16510
-
16511
- this.assert(
16512
- thrown === true
16513
- , 'expected #{this} to throw ' + expectedThrown + actuallyGot
16514
- , 'expected #{this} to not throw ' + expectedThrown + actuallyGot
16515
- , desiredError
16516
- , thrownError
16517
- );
16518
- };
16519
-
16520
- Assertion.addMethod('throw', assertThrows);
16521
- Assertion.addMethod('throws', assertThrows);
16522
- Assertion.addMethod('Throw', assertThrows);
16523
-
16524
- /**
16525
- * ### .respondTo(method)
16526
- *
16527
- * Asserts that the object or class target will respond to a method.
16528
- *
16529
- * Klass.prototype.bar = function(){};
16530
- * expect(Klass).to.respondTo('bar');
16531
- * expect(obj).to.respondTo('bar');
16532
- *
16533
- * To check if a constructor will respond to a static function,
16534
- * set the `itself` flag.
16535
- *
16536
- * Klass.baz = function(){};
16537
- * expect(Klass).itself.to.respondTo('baz');
16538
- *
16539
- * @name respondTo
16540
- * @param {String} method
16541
- * @param {String} message _optional_
16542
- * @api public
16543
- */
16544
-
16545
- Assertion.addMethod('respondTo', function (method, msg) {
16546
- if (msg) flag(this, 'message', msg);
16547
- var obj = flag(this, 'object')
16548
- , itself = flag(this, 'itself')
16549
- , context = ('function' === _.type(obj) && !itself)
16550
- ? obj.prototype[method]
16551
- : obj[method];
16552
-
16553
- this.assert(
16554
- 'function' === typeof context
16555
- , 'expected #{this} to respond to ' + _.inspect(method)
16556
- , 'expected #{this} to not respond to ' + _.inspect(method)
16557
- );
16558
- });
16559
-
16560
- /**
16561
- * ### .itself
16562
- *
16563
- * Sets the `itself` flag, later used by the `respondTo` assertion.
16564
- *
16565
- * function Foo() {}
16566
- * Foo.bar = function() {}
16567
- * Foo.prototype.baz = function() {}
16568
- *
16569
- * expect(Foo).itself.to.respondTo('bar');
16570
- * expect(Foo).itself.not.to.respondTo('baz');
16571
- *
16572
- * @name itself
16573
- * @api public
16574
- */
16575
-
16576
- Assertion.addProperty('itself', function () {
16577
- flag(this, 'itself', true);
16578
- });
16579
-
16580
- /**
16581
- * ### .satisfy(method)
16582
- *
16583
- * Asserts that the target passes a given truth test.
16584
- *
16585
- * expect(1).to.satisfy(function(num) { return num > 0; });
16586
- *
16587
- * @name satisfy
16588
- * @param {Function} matcher
16589
- * @param {String} message _optional_
16590
- * @api public
16591
- */
16592
-
16593
- Assertion.addMethod('satisfy', function (matcher, msg) {
16594
- if (msg) flag(this, 'message', msg);
16595
- var obj = flag(this, 'object');
16596
- this.assert(
16597
- matcher(obj)
16598
- , 'expected #{this} to satisfy ' + _.objDisplay(matcher)
16599
- , 'expected #{this} to not satisfy' + _.objDisplay(matcher)
16600
- , this.negate ? false : true
16601
- , matcher(obj)
16602
- );
16603
- });
16604
-
16605
- /**
16606
- * ### .closeTo(expected, delta)
16607
- *
16608
- * Asserts that the target is equal `expected`, to within a +/- `delta` range.
16609
- *
16610
- * expect(1.5).to.be.closeTo(1, 0.5);
16611
- *
16612
- * @name closeTo
16613
- * @param {Number} expected
16614
- * @param {Number} delta
16615
- * @param {String} message _optional_
16616
- * @api public
16617
- */
16618
-
16619
- Assertion.addMethod('closeTo', function (expected, delta, msg) {
16620
- if (msg) flag(this, 'message', msg);
16621
- var obj = flag(this, 'object');
16622
- this.assert(
16623
- Math.abs(obj - expected) <= delta
16624
- , 'expected #{this} to be close to ' + expected + ' +/- ' + delta
16625
- , 'expected #{this} not to be close to ' + expected + ' +/- ' + delta
16626
- );
16627
- });
16628
-
16629
- function isSubsetOf(subset, superset) {
16630
- return subset.every(function(elem) {
16631
- return superset.indexOf(elem) !== -1;
16632
- })
16633
- }
16634
-
16635
- /**
16636
- * ### .members(set)
16637
- *
16638
- * Asserts that the target is a superset of `set`,
16639
- * or that the target and `set` have the same members.
16640
- *
16641
- * expect([1, 2, 3]).to.include.members([3, 2]);
16642
- * expect([1, 2, 3]).to.not.include.members([3, 2, 8]);
16643
- *
16644
- * expect([4, 2]).to.have.members([2, 4]);
16645
- * expect([5, 2]).to.not.have.members([5, 2, 1]);
16646
- *
16647
- * @name members
16648
- * @param {Array} set
16649
- * @param {String} message _optional_
16650
- * @api public
16651
- */
16652
-
16653
- Assertion.addMethod('members', function (subset, msg) {
16654
- if (msg) flag(this, 'message', msg);
16655
- var obj = flag(this, 'object');
16656
-
16657
- new Assertion(obj).to.be.an('array');
16658
- new Assertion(subset).to.be.an('array');
16659
-
16660
- if (flag(this, 'contains')) {
16661
- return this.assert(
16662
- isSubsetOf(subset, obj)
16663
- , 'expected #{this} to be a superset of #{act}'
16664
- , 'expected #{this} to not be a superset of #{act}'
16665
- , obj
16666
- , subset
16667
- );
16668
- }
16669
-
16670
- this.assert(
16671
- isSubsetOf(obj, subset) && isSubsetOf(subset, obj)
16672
- , 'expected #{this} to have the same members as #{act}'
16673
- , 'expected #{this} to not have the same members as #{act}'
16674
- , obj
16675
- , subset
16676
- );
16677
- });
16678
- };
16679
-
16680
- });
16681
- require.register("chaijs-chai/lib/chai/interface/assert.js", function(exports, require, module){
16682
- /*!
16683
- * chai
16684
- * Copyright(c) 2011-2013 Jake Luer <jake@alogicalparadox.com>
16685
- * MIT Licensed
16686
- */
16687
-
16688
-
16689
- module.exports = function (chai, util) {
16690
-
16691
- /*!
16692
- * Chai dependencies.
16693
- */
16694
-
16695
- var Assertion = chai.Assertion
16696
- , flag = util.flag;
16697
-
16698
- /*!
16699
- * Module export.
16700
- */
16701
-
16702
- /**
16703
- * ### assert(expression, message)
16704
- *
16705
- * Write your own test expressions.
16706
- *
16707
- * assert('foo' !== 'bar', 'foo is not bar');
16708
- * assert(Array.isArray([]), 'empty arrays are arrays');
16709
- *
16710
- * @param {Mixed} expression to test for truthiness
16711
- * @param {String} message to display on error
16712
- * @name assert
16713
- * @api public
16714
- */
16715
-
16716
- var assert = chai.assert = function (express, errmsg) {
16717
- var test = new Assertion(null);
16718
- test.assert(
16719
- express
16720
- , errmsg
16721
- , '[ negation message unavailable ]'
16722
- );
16723
- };
16724
-
16725
- /**
16726
- * ### .fail(actual, expected, [message], [operator])
16727
- *
16728
- * Throw a failure. Node.js `assert` module-compatible.
16729
- *
16730
- * @name fail
16731
- * @param {Mixed} actual
16732
- * @param {Mixed} expected
16733
- * @param {String} message
16734
- * @param {String} operator
16735
- * @api public
16736
- */
16737
-
16738
- assert.fail = function (actual, expected, message, operator) {
16739
- throw new chai.AssertionError({
16740
- actual: actual
16741
- , expected: expected
16742
- , message: message
16743
- , operator: operator
16744
- , stackStartFunction: assert.fail
16745
- });
16746
- };
16747
-
16748
- /**
16749
- * ### .ok(object, [message])
16750
- *
16751
- * Asserts that `object` is truthy.
16752
- *
16753
- * assert.ok('everything', 'everything is ok');
16754
- * assert.ok(false, 'this will fail');
16755
- *
16756
- * @name ok
16757
- * @param {Mixed} object to test
16758
- * @param {String} message
16759
- * @api public
16760
- */
16761
-
16762
- assert.ok = function (val, msg) {
16763
- new Assertion(val, msg).is.ok;
16764
- };
16765
-
16766
- /**
16767
- * ### .notOk(object, [message])
16768
- *
16769
- * Asserts that `object` is falsy.
16770
- *
16771
- * assert.notOk('everything', 'this will fail');
16772
- * assert.notOk(false, 'this will pass');
16773
- *
16774
- * @name notOk
16775
- * @param {Mixed} object to test
16776
- * @param {String} message
16777
- * @api public
16778
- */
16779
-
16780
- assert.notOk = function (val, msg) {
16781
- new Assertion(val, msg).is.not.ok;
16782
- };
16783
-
16784
- /**
16785
- * ### .equal(actual, expected, [message])
16786
- *
16787
- * Asserts non-strict equality (`==`) of `actual` and `expected`.
16788
- *
16789
- * assert.equal(3, '3', '== coerces values to strings');
16790
- *
16791
- * @name equal
16792
- * @param {Mixed} actual
16793
- * @param {Mixed} expected
16794
- * @param {String} message
16795
- * @api public
16796
- */
16797
-
16798
- assert.equal = function (act, exp, msg) {
16799
- var test = new Assertion(act, msg);
16800
-
16801
- test.assert(
16802
- exp == flag(test, 'object')
16803
- , 'expected #{this} to equal #{exp}'
16804
- , 'expected #{this} to not equal #{act}'
16805
- , exp
16806
- , act
16807
- );
16808
- };
16809
-
16810
- /**
16811
- * ### .notEqual(actual, expected, [message])
16812
- *
16813
- * Asserts non-strict inequality (`!=`) of `actual` and `expected`.
16814
- *
16815
- * assert.notEqual(3, 4, 'these numbers are not equal');
16816
- *
16817
- * @name notEqual
16818
- * @param {Mixed} actual
16819
- * @param {Mixed} expected
16820
- * @param {String} message
16821
- * @api public
16822
- */
16823
-
16824
- assert.notEqual = function (act, exp, msg) {
16825
- var test = new Assertion(act, msg);
16826
-
16827
- test.assert(
16828
- exp != flag(test, 'object')
16829
- , 'expected #{this} to not equal #{exp}'
16830
- , 'expected #{this} to equal #{act}'
16831
- , exp
16832
- , act
16833
- );
16834
- };
16835
-
16836
- /**
16837
- * ### .strictEqual(actual, expected, [message])
16838
- *
16839
- * Asserts strict equality (`===`) of `actual` and `expected`.
16840
- *
16841
- * assert.strictEqual(true, true, 'these booleans are strictly equal');
16842
- *
16843
- * @name strictEqual
16844
- * @param {Mixed} actual
16845
- * @param {Mixed} expected
16846
- * @param {String} message
16847
- * @api public
16848
- */
16849
-
16850
- assert.strictEqual = function (act, exp, msg) {
16851
- new Assertion(act, msg).to.equal(exp);
16852
- };
16853
-
16854
- /**
16855
- * ### .notStrictEqual(actual, expected, [message])
16856
- *
16857
- * Asserts strict inequality (`!==`) of `actual` and `expected`.
16858
- *
16859
- * assert.notStrictEqual(3, '3', 'no coercion for strict equality');
16860
- *
16861
- * @name notStrictEqual
16862
- * @param {Mixed} actual
16863
- * @param {Mixed} expected
16864
- * @param {String} message
16865
- * @api public
16866
- */
16867
-
16868
- assert.notStrictEqual = function (act, exp, msg) {
16869
- new Assertion(act, msg).to.not.equal(exp);
16870
- };
16871
-
16872
- /**
16873
- * ### .deepEqual(actual, expected, [message])
16874
- *
16875
- * Asserts that `actual` is deeply equal to `expected`.
16876
- *
16877
- * assert.deepEqual({ tea: 'green' }, { tea: 'green' });
16878
- *
16879
- * @name deepEqual
16880
- * @param {Mixed} actual
16881
- * @param {Mixed} expected
16882
- * @param {String} message
16883
- * @api public
16884
- */
16885
-
16886
- assert.deepEqual = function (act, exp, msg) {
16887
- new Assertion(act, msg).to.eql(exp);
16888
- };
16889
-
16890
- /**
16891
- * ### .notDeepEqual(actual, expected, [message])
16892
- *
16893
- * Assert that `actual` is not deeply equal to `expected`.
16894
- *
16895
- * assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' });
16896
- *
16897
- * @name notDeepEqual
16898
- * @param {Mixed} actual
16899
- * @param {Mixed} expected
16900
- * @param {String} message
16901
- * @api public
16902
- */
16903
-
16904
- assert.notDeepEqual = function (act, exp, msg) {
16905
- new Assertion(act, msg).to.not.eql(exp);
16906
- };
16907
-
16908
- /**
16909
- * ### .isTrue(value, [message])
16910
- *
16911
- * Asserts that `value` is true.
16912
- *
16913
- * var teaServed = true;
16914
- * assert.isTrue(teaServed, 'the tea has been served');
16915
- *
16916
- * @name isTrue
16917
- * @param {Mixed} value
16918
- * @param {String} message
16919
- * @api public
16920
- */
16921
-
16922
- assert.isTrue = function (val, msg) {
16923
- new Assertion(val, msg).is['true'];
16924
- };
16925
-
16926
- /**
16927
- * ### .isFalse(value, [message])
16928
- *
16929
- * Asserts that `value` is false.
16930
- *
16931
- * var teaServed = false;
16932
- * assert.isFalse(teaServed, 'no tea yet? hmm...');
16933
- *
16934
- * @name isFalse
16935
- * @param {Mixed} value
16936
- * @param {String} message
16937
- * @api public
16938
- */
16939
-
16940
- assert.isFalse = function (val, msg) {
16941
- new Assertion(val, msg).is['false'];
16942
- };
16943
-
16944
- /**
16945
- * ### .isNull(value, [message])
16946
- *
16947
- * Asserts that `value` is null.
16948
- *
16949
- * assert.isNull(err, 'there was no error');
16950
- *
16951
- * @name isNull
16952
- * @param {Mixed} value
16953
- * @param {String} message
16954
- * @api public
16955
- */
16956
-
16957
- assert.isNull = function (val, msg) {
16958
- new Assertion(val, msg).to.equal(null);
16959
- };
16960
-
16961
- /**
16962
- * ### .isNotNull(value, [message])
16963
- *
16964
- * Asserts that `value` is not null.
16965
- *
16966
- * var tea = 'tasty chai';
16967
- * assert.isNotNull(tea, 'great, time for tea!');
16968
- *
16969
- * @name isNotNull
16970
- * @param {Mixed} value
16971
- * @param {String} message
16972
- * @api public
16973
- */
16974
-
16975
- assert.isNotNull = function (val, msg) {
16976
- new Assertion(val, msg).to.not.equal(null);
16977
- };
16978
-
16979
- /**
16980
- * ### .isUndefined(value, [message])
16981
- *
16982
- * Asserts that `value` is `undefined`.
16983
- *
16984
- * var tea;
16985
- * assert.isUndefined(tea, 'no tea defined');
16986
- *
16987
- * @name isUndefined
16988
- * @param {Mixed} value
16989
- * @param {String} message
16990
- * @api public
16991
- */
16992
-
16993
- assert.isUndefined = function (val, msg) {
16994
- new Assertion(val, msg).to.equal(undefined);
16995
- };
16996
-
16997
- /**
16998
- * ### .isDefined(value, [message])
16999
- *
17000
- * Asserts that `value` is not `undefined`.
17001
- *
17002
- * var tea = 'cup of chai';
17003
- * assert.isDefined(tea, 'tea has been defined');
17004
- *
17005
- * @name isDefined
17006
- * @param {Mixed} value
17007
- * @param {String} message
17008
- * @api public
17009
- */
17010
-
17011
- assert.isDefined = function (val, msg) {
17012
- new Assertion(val, msg).to.not.equal(undefined);
17013
- };
17014
-
17015
- /**
17016
- * ### .isFunction(value, [message])
17017
- *
17018
- * Asserts that `value` is a function.
17019
- *
17020
- * function serveTea() { return 'cup of tea'; };
17021
- * assert.isFunction(serveTea, 'great, we can have tea now');
17022
- *
17023
- * @name isFunction
17024
- * @param {Mixed} value
17025
- * @param {String} message
17026
- * @api public
17027
- */
17028
-
17029
- assert.isFunction = function (val, msg) {
17030
- new Assertion(val, msg).to.be.a('function');
17031
- };
17032
-
17033
- /**
17034
- * ### .isNotFunction(value, [message])
17035
- *
17036
- * Asserts that `value` is _not_ a function.
17037
- *
17038
- * var serveTea = [ 'heat', 'pour', 'sip' ];
17039
- * assert.isNotFunction(serveTea, 'great, we have listed the steps');
17040
- *
17041
- * @name isNotFunction
17042
- * @param {Mixed} value
17043
- * @param {String} message
17044
- * @api public
17045
- */
17046
-
17047
- assert.isNotFunction = function (val, msg) {
17048
- new Assertion(val, msg).to.not.be.a('function');
17049
- };
17050
-
17051
- /**
17052
- * ### .isObject(value, [message])
17053
- *
17054
- * Asserts that `value` is an object (as revealed by
17055
- * `Object.prototype.toString`).
17056
- *
17057
- * var selection = { name: 'Chai', serve: 'with spices' };
17058
- * assert.isObject(selection, 'tea selection is an object');
17059
- *
17060
- * @name isObject
17061
- * @param {Mixed} value
17062
- * @param {String} message
17063
- * @api public
17064
- */
17065
-
17066
- assert.isObject = function (val, msg) {
17067
- new Assertion(val, msg).to.be.a('object');
17068
- };
17069
-
17070
- /**
17071
- * ### .isNotObject(value, [message])
17072
- *
17073
- * Asserts that `value` is _not_ an object.
17074
- *
17075
- * var selection = 'chai'
17076
- * assert.isObject(selection, 'tea selection is not an object');
17077
- * assert.isObject(null, 'null is not an object');
17078
- *
17079
- * @name isNotObject
17080
- * @param {Mixed} value
17081
- * @param {String} message
17082
- * @api public
17083
- */
17084
-
17085
- assert.isNotObject = function (val, msg) {
17086
- new Assertion(val, msg).to.not.be.a('object');
17087
- };
17088
-
17089
- /**
17090
- * ### .isArray(value, [message])
17091
- *
17092
- * Asserts that `value` is an array.
17093
- *
17094
- * var menu = [ 'green', 'chai', 'oolong' ];
17095
- * assert.isArray(menu, 'what kind of tea do we want?');
17096
- *
17097
- * @name isArray
17098
- * @param {Mixed} value
17099
- * @param {String} message
17100
- * @api public
17101
- */
17102
-
17103
- assert.isArray = function (val, msg) {
17104
- new Assertion(val, msg).to.be.an('array');
17105
- };
17106
-
17107
- /**
17108
- * ### .isNotArray(value, [message])
17109
- *
17110
- * Asserts that `value` is _not_ an array.
17111
- *
17112
- * var menu = 'green|chai|oolong';
17113
- * assert.isNotArray(menu, 'what kind of tea do we want?');
17114
- *
17115
- * @name isNotArray
17116
- * @param {Mixed} value
17117
- * @param {String} message
17118
- * @api public
17119
- */
17120
-
17121
- assert.isNotArray = function (val, msg) {
17122
- new Assertion(val, msg).to.not.be.an('array');
17123
- };
17124
-
17125
- /**
17126
- * ### .isString(value, [message])
17127
- *
17128
- * Asserts that `value` is a string.
17129
- *
17130
- * var teaOrder = 'chai';
17131
- * assert.isString(teaOrder, 'order placed');
17132
- *
17133
- * @name isString
17134
- * @param {Mixed} value
17135
- * @param {String} message
17136
- * @api public
17137
- */
17138
-
17139
- assert.isString = function (val, msg) {
17140
- new Assertion(val, msg).to.be.a('string');
17141
- };
17142
-
17143
- /**
17144
- * ### .isNotString(value, [message])
17145
- *
17146
- * Asserts that `value` is _not_ a string.
17147
- *
17148
- * var teaOrder = 4;
17149
- * assert.isNotString(teaOrder, 'order placed');
17150
- *
17151
- * @name isNotString
17152
- * @param {Mixed} value
17153
- * @param {String} message
17154
- * @api public
17155
- */
17156
-
17157
- assert.isNotString = function (val, msg) {
17158
- new Assertion(val, msg).to.not.be.a('string');
17159
- };
17160
-
17161
- /**
17162
- * ### .isNumber(value, [message])
17163
- *
17164
- * Asserts that `value` is a number.
17165
- *
17166
- * var cups = 2;
17167
- * assert.isNumber(cups, 'how many cups');
17168
- *
17169
- * @name isNumber
17170
- * @param {Number} value
17171
- * @param {String} message
17172
- * @api public
17173
- */
17174
-
17175
- assert.isNumber = function (val, msg) {
17176
- new Assertion(val, msg).to.be.a('number');
17177
- };
17178
-
17179
- /**
17180
- * ### .isNotNumber(value, [message])
17181
- *
17182
- * Asserts that `value` is _not_ a number.
17183
- *
17184
- * var cups = '2 cups please';
17185
- * assert.isNotNumber(cups, 'how many cups');
17186
- *
17187
- * @name isNotNumber
17188
- * @param {Mixed} value
17189
- * @param {String} message
17190
- * @api public
17191
- */
17192
-
17193
- assert.isNotNumber = function (val, msg) {
17194
- new Assertion(val, msg).to.not.be.a('number');
17195
- };
17196
-
17197
- /**
17198
- * ### .isBoolean(value, [message])
17199
- *
17200
- * Asserts that `value` is a boolean.
17201
- *
17202
- * var teaReady = true
17203
- * , teaServed = false;
17204
- *
17205
- * assert.isBoolean(teaReady, 'is the tea ready');
17206
- * assert.isBoolean(teaServed, 'has tea been served');
17207
- *
17208
- * @name isBoolean
17209
- * @param {Mixed} value
17210
- * @param {String} message
17211
- * @api public
17212
- */
17213
-
17214
- assert.isBoolean = function (val, msg) {
17215
- new Assertion(val, msg).to.be.a('boolean');
17216
- };
17217
-
17218
- /**
17219
- * ### .isNotBoolean(value, [message])
17220
- *
17221
- * Asserts that `value` is _not_ a boolean.
17222
- *
17223
- * var teaReady = 'yep'
17224
- * , teaServed = 'nope';
17225
- *
17226
- * assert.isNotBoolean(teaReady, 'is the tea ready');
17227
- * assert.isNotBoolean(teaServed, 'has tea been served');
17228
- *
17229
- * @name isNotBoolean
17230
- * @param {Mixed} value
17231
- * @param {String} message
17232
- * @api public
17233
- */
17234
-
17235
- assert.isNotBoolean = function (val, msg) {
17236
- new Assertion(val, msg).to.not.be.a('boolean');
17237
- };
17238
-
17239
- /**
17240
- * ### .typeOf(value, name, [message])
17241
- *
17242
- * Asserts that `value`'s type is `name`, as determined by
17243
- * `Object.prototype.toString`.
17244
- *
17245
- * assert.typeOf({ tea: 'chai' }, 'object', 'we have an object');
17246
- * assert.typeOf(['chai', 'jasmine'], 'array', 'we have an array');
17247
- * assert.typeOf('tea', 'string', 'we have a string');
17248
- * assert.typeOf(/tea/, 'regexp', 'we have a regular expression');
17249
- * assert.typeOf(null, 'null', 'we have a null');
17250
- * assert.typeOf(undefined, 'undefined', 'we have an undefined');
17251
- *
17252
- * @name typeOf
17253
- * @param {Mixed} value
17254
- * @param {String} name
17255
- * @param {String} message
17256
- * @api public
17257
- */
17258
-
17259
- assert.typeOf = function (val, type, msg) {
17260
- new Assertion(val, msg).to.be.a(type);
17261
- };
17262
-
17263
- /**
17264
- * ### .notTypeOf(value, name, [message])
17265
- *
17266
- * Asserts that `value`'s type is _not_ `name`, as determined by
17267
- * `Object.prototype.toString`.
17268
- *
17269
- * assert.notTypeOf('tea', 'number', 'strings are not numbers');
17270
- *
17271
- * @name notTypeOf
17272
- * @param {Mixed} value
17273
- * @param {String} typeof name
17274
- * @param {String} message
17275
- * @api public
17276
- */
17277
-
17278
- assert.notTypeOf = function (val, type, msg) {
17279
- new Assertion(val, msg).to.not.be.a(type);
17280
- };
17281
-
17282
- /**
17283
- * ### .instanceOf(object, constructor, [message])
17284
- *
17285
- * Asserts that `value` is an instance of `constructor`.
17286
- *
17287
- * var Tea = function (name) { this.name = name; }
17288
- * , chai = new Tea('chai');
17289
- *
17290
- * assert.instanceOf(chai, Tea, 'chai is an instance of tea');
17291
- *
17292
- * @name instanceOf
17293
- * @param {Object} object
17294
- * @param {Constructor} constructor
17295
- * @param {String} message
17296
- * @api public
17297
- */
17298
-
17299
- assert.instanceOf = function (val, type, msg) {
17300
- new Assertion(val, msg).to.be.instanceOf(type);
17301
- };
17302
-
17303
- /**
17304
- * ### .notInstanceOf(object, constructor, [message])
17305
- *
17306
- * Asserts `value` is not an instance of `constructor`.
17307
- *
17308
- * var Tea = function (name) { this.name = name; }
17309
- * , chai = new String('chai');
17310
- *
17311
- * assert.notInstanceOf(chai, Tea, 'chai is not an instance of tea');
17312
- *
17313
- * @name notInstanceOf
17314
- * @param {Object} object
17315
- * @param {Constructor} constructor
17316
- * @param {String} message
17317
- * @api public
17318
- */
17319
-
17320
- assert.notInstanceOf = function (val, type, msg) {
17321
- new Assertion(val, msg).to.not.be.instanceOf(type);
17322
- };
17323
-
17324
- /**
17325
- * ### .include(haystack, needle, [message])
17326
- *
17327
- * Asserts that `haystack` includes `needle`. Works
17328
- * for strings and arrays.
17329
- *
17330
- * assert.include('foobar', 'bar', 'foobar contains string "bar"');
17331
- * assert.include([ 1, 2, 3 ], 3, 'array contains value');
17332
- *
17333
- * @name include
17334
- * @param {Array|String} haystack
17335
- * @param {Mixed} needle
17336
- * @param {String} message
17337
- * @api public
17338
- */
17339
-
17340
- assert.include = function (exp, inc, msg) {
17341
- var obj = new Assertion(exp, msg);
17342
-
17343
- if (Array.isArray(exp)) {
17344
- obj.to.include(inc);
17345
- } else if ('string' === typeof exp) {
17346
- obj.to.contain.string(inc);
17347
- } else {
17348
- throw new chai.AssertionError(
17349
- 'expected an array or string'
17350
- , null
17351
- , assert.include
17352
- );
17353
- }
17354
- };
17355
-
17356
- /**
17357
- * ### .notInclude(haystack, needle, [message])
17358
- *
17359
- * Asserts that `haystack` does not include `needle`. Works
17360
- * for strings and arrays.
17361
- *i
17362
- * assert.notInclude('foobar', 'baz', 'string not include substring');
17363
- * assert.notInclude([ 1, 2, 3 ], 4, 'array not include contain value');
17364
- *
17365
- * @name notInclude
17366
- * @param {Array|String} haystack
17367
- * @param {Mixed} needle
17368
- * @param {String} message
17369
- * @api public
17370
- */
17371
-
17372
- assert.notInclude = function (exp, inc, msg) {
17373
- var obj = new Assertion(exp, msg);
17374
-
17375
- if (Array.isArray(exp)) {
17376
- obj.to.not.include(inc);
17377
- } else if ('string' === typeof exp) {
17378
- obj.to.not.contain.string(inc);
17379
- } else {
17380
- throw new chai.AssertionError(
17381
- 'expected an array or string'
17382
- , null
17383
- , assert.notInclude
17384
- );
17385
- }
17386
- };
17387
-
17388
- /**
17389
- * ### .match(value, regexp, [message])
17390
- *
17391
- * Asserts that `value` matches the regular expression `regexp`.
17392
- *
17393
- * assert.match('foobar', /^foo/, 'regexp matches');
17394
- *
17395
- * @name match
17396
- * @param {Mixed} value
17397
- * @param {RegExp} regexp
17398
- * @param {String} message
17399
- * @api public
17400
- */
17401
-
17402
- assert.match = function (exp, re, msg) {
17403
- new Assertion(exp, msg).to.match(re);
17404
- };
17405
-
17406
- /**
17407
- * ### .notMatch(value, regexp, [message])
17408
- *
17409
- * Asserts that `value` does not match the regular expression `regexp`.
17410
- *
17411
- * assert.notMatch('foobar', /^foo/, 'regexp does not match');
17412
- *
17413
- * @name notMatch
17414
- * @param {Mixed} value
17415
- * @param {RegExp} regexp
17416
- * @param {String} message
17417
- * @api public
17418
- */
17419
-
17420
- assert.notMatch = function (exp, re, msg) {
17421
- new Assertion(exp, msg).to.not.match(re);
17422
- };
17423
-
17424
- /**
17425
- * ### .property(object, property, [message])
17426
- *
17427
- * Asserts that `object` has a property named by `property`.
17428
- *
17429
- * assert.property({ tea: { green: 'matcha' }}, 'tea');
17430
- *
17431
- * @name property
17432
- * @param {Object} object
17433
- * @param {String} property
17434
- * @param {String} message
17435
- * @api public
17436
- */
17437
-
17438
- assert.property = function (obj, prop, msg) {
17439
- new Assertion(obj, msg).to.have.property(prop);
17440
- };
17441
-
17442
- /**
17443
- * ### .notProperty(object, property, [message])
17444
- *
17445
- * Asserts that `object` does _not_ have a property named by `property`.
17446
- *
17447
- * assert.notProperty({ tea: { green: 'matcha' }}, 'coffee');
17448
- *
17449
- * @name notProperty
17450
- * @param {Object} object
17451
- * @param {String} property
17452
- * @param {String} message
17453
- * @api public
17454
- */
17455
-
17456
- assert.notProperty = function (obj, prop, msg) {
17457
- new Assertion(obj, msg).to.not.have.property(prop);
17458
- };
17459
-
17460
- /**
17461
- * ### .deepProperty(object, property, [message])
17462
- *
17463
- * Asserts that `object` has a property named by `property`, which can be a
17464
- * string using dot- and bracket-notation for deep reference.
17465
- *
17466
- * assert.deepProperty({ tea: { green: 'matcha' }}, 'tea.green');
17467
- *
17468
- * @name deepProperty
17469
- * @param {Object} object
17470
- * @param {String} property
17471
- * @param {String} message
17472
- * @api public
17473
- */
17474
-
17475
- assert.deepProperty = function (obj, prop, msg) {
17476
- new Assertion(obj, msg).to.have.deep.property(prop);
17477
- };
17478
-
17479
- /**
17480
- * ### .notDeepProperty(object, property, [message])
17481
- *
17482
- * Asserts that `object` does _not_ have a property named by `property`, which
17483
- * can be a string using dot- and bracket-notation for deep reference.
17484
- *
17485
- * assert.notDeepProperty({ tea: { green: 'matcha' }}, 'tea.oolong');
17486
- *
17487
- * @name notDeepProperty
17488
- * @param {Object} object
17489
- * @param {String} property
17490
- * @param {String} message
17491
- * @api public
17492
- */
17493
-
17494
- assert.notDeepProperty = function (obj, prop, msg) {
17495
- new Assertion(obj, msg).to.not.have.deep.property(prop);
17496
- };
17497
-
17498
- /**
17499
- * ### .propertyVal(object, property, value, [message])
17500
- *
17501
- * Asserts that `object` has a property named by `property` with value given
17502
- * by `value`.
17503
- *
17504
- * assert.propertyVal({ tea: 'is good' }, 'tea', 'is good');
17505
- *
17506
- * @name propertyVal
17507
- * @param {Object} object
17508
- * @param {String} property
17509
- * @param {Mixed} value
17510
- * @param {String} message
17511
- * @api public
17512
- */
17513
-
17514
- assert.propertyVal = function (obj, prop, val, msg) {
17515
- new Assertion(obj, msg).to.have.property(prop, val);
17516
- };
17517
-
17518
- /**
17519
- * ### .propertyNotVal(object, property, value, [message])
17520
- *
17521
- * Asserts that `object` has a property named by `property`, but with a value
17522
- * different from that given by `value`.
17523
- *
17524
- * assert.propertyNotVal({ tea: 'is good' }, 'tea', 'is bad');
17525
- *
17526
- * @name propertyNotVal
17527
- * @param {Object} object
17528
- * @param {String} property
17529
- * @param {Mixed} value
17530
- * @param {String} message
17531
- * @api public
17532
- */
17533
-
17534
- assert.propertyNotVal = function (obj, prop, val, msg) {
17535
- new Assertion(obj, msg).to.not.have.property(prop, val);
17536
- };
17537
-
17538
- /**
17539
- * ### .deepPropertyVal(object, property, value, [message])
17540
- *
17541
- * Asserts that `object` has a property named by `property` with value given
17542
- * by `value`. `property` can use dot- and bracket-notation for deep
17543
- * reference.
17544
- *
17545
- * assert.deepPropertyVal({ tea: { green: 'matcha' }}, 'tea.green', 'matcha');
17546
- *
17547
- * @name deepPropertyVal
17548
- * @param {Object} object
17549
- * @param {String} property
17550
- * @param {Mixed} value
17551
- * @param {String} message
17552
- * @api public
17553
- */
17554
-
17555
- assert.deepPropertyVal = function (obj, prop, val, msg) {
17556
- new Assertion(obj, msg).to.have.deep.property(prop, val);
17557
- };
17558
-
17559
- /**
17560
- * ### .deepPropertyNotVal(object, property, value, [message])
17561
- *
17562
- * Asserts that `object` has a property named by `property`, but with a value
17563
- * different from that given by `value`. `property` can use dot- and
17564
- * bracket-notation for deep reference.
17565
- *
17566
- * assert.deepPropertyNotVal({ tea: { green: 'matcha' }}, 'tea.green', 'konacha');
17567
- *
17568
- * @name deepPropertyNotVal
17569
- * @param {Object} object
17570
- * @param {String} property
17571
- * @param {Mixed} value
17572
- * @param {String} message
17573
- * @api public
17574
- */
17575
-
17576
- assert.deepPropertyNotVal = function (obj, prop, val, msg) {
17577
- new Assertion(obj, msg).to.not.have.deep.property(prop, val);
17578
- };
17579
-
17580
- /**
17581
- * ### .lengthOf(object, length, [message])
17582
- *
17583
- * Asserts that `object` has a `length` property with the expected value.
17584
- *
17585
- * assert.lengthOf([1,2,3], 3, 'array has length of 3');
17586
- * assert.lengthOf('foobar', 5, 'string has length of 6');
17587
- *
17588
- * @name lengthOf
17589
- * @param {Mixed} object
17590
- * @param {Number} length
17591
- * @param {String} message
17592
- * @api public
17593
- */
17594
-
17595
- assert.lengthOf = function (exp, len, msg) {
17596
- new Assertion(exp, msg).to.have.length(len);
17597
- };
17598
-
17599
- /**
17600
- * ### .throws(function, [constructor/string/regexp], [string/regexp], [message])
17601
- *
17602
- * Asserts that `function` will throw an error that is an instance of
17603
- * `constructor`, or alternately that it will throw an error with message
17604
- * matching `regexp`.
17605
- *
17606
- * assert.throw(fn, 'function throws a reference error');
17607
- * assert.throw(fn, /function throws a reference error/);
17608
- * assert.throw(fn, ReferenceError);
17609
- * assert.throw(fn, ReferenceError, 'function throws a reference error');
17610
- * assert.throw(fn, ReferenceError, /function throws a reference error/);
17611
- *
17612
- * @name throws
17613
- * @alias throw
17614
- * @alias Throw
17615
- * @param {Function} function
17616
- * @param {ErrorConstructor} constructor
17617
- * @param {RegExp} regexp
17618
- * @param {String} message
17619
- * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
17620
- * @api public
17621
- */
17622
-
17623
- assert.Throw = function (fn, errt, errs, msg) {
17624
- if ('string' === typeof errt || errt instanceof RegExp) {
17625
- errs = errt;
17626
- errt = null;
17627
- }
17628
-
17629
- new Assertion(fn, msg).to.Throw(errt, errs);
17630
- };
17631
-
17632
- /**
17633
- * ### .doesNotThrow(function, [constructor/regexp], [message])
17634
- *
17635
- * Asserts that `function` will _not_ throw an error that is an instance of
17636
- * `constructor`, or alternately that it will not throw an error with message
17637
- * matching `regexp`.
17638
- *
17639
- * assert.doesNotThrow(fn, Error, 'function does not throw');
17640
- *
17641
- * @name doesNotThrow
17642
- * @param {Function} function
17643
- * @param {ErrorConstructor} constructor
17644
- * @param {RegExp} regexp
17645
- * @param {String} message
17646
- * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
17647
- * @api public
17648
- */
17649
-
17650
- assert.doesNotThrow = function (fn, type, msg) {
17651
- if ('string' === typeof type) {
17652
- msg = type;
17653
- type = null;
17654
- }
17655
-
17656
- new Assertion(fn, msg).to.not.Throw(type);
17657
- };
17658
-
17659
- /**
17660
- * ### .operator(val1, operator, val2, [message])
17661
- *
17662
- * Compares two values using `operator`.
17663
- *
17664
- * assert.operator(1, '<', 2, 'everything is ok');
17665
- * assert.operator(1, '>', 2, 'this will fail');
17666
- *
17667
- * @name operator
17668
- * @param {Mixed} val1
17669
- * @param {String} operator
17670
- * @param {Mixed} val2
17671
- * @param {String} message
17672
- * @api public
17673
- */
17674
-
17675
- assert.operator = function (val, operator, val2, msg) {
17676
- if (!~['==', '===', '>', '>=', '<', '<=', '!=', '!=='].indexOf(operator)) {
17677
- throw new Error('Invalid operator "' + operator + '"');
17678
- }
17679
- var test = new Assertion(eval(val + operator + val2), msg);
17680
- test.assert(
17681
- true === flag(test, 'object')
17682
- , 'expected ' + util.inspect(val) + ' to be ' + operator + ' ' + util.inspect(val2)
17683
- , 'expected ' + util.inspect(val) + ' to not be ' + operator + ' ' + util.inspect(val2) );
17684
- };
17685
-
17686
- /**
17687
- * ### .closeTo(actual, expected, delta, [message])
17688
- *
17689
- * Asserts that the target is equal `expected`, to within a +/- `delta` range.
17690
- *
17691
- * assert.closeTo(1.5, 1, 0.5, 'numbers are close');
17692
- *
17693
- * @name closeTo
17694
- * @param {Number} actual
17695
- * @param {Number} expected
17696
- * @param {Number} delta
17697
- * @param {String} message
17698
- * @api public
17699
- */
17700
-
17701
- assert.closeTo = function (act, exp, delta, msg) {
17702
- new Assertion(act, msg).to.be.closeTo(exp, delta);
17703
- };
17704
-
17705
- /**
17706
- * ### .sameMembers(set1, set2, [message])
17707
- *
17708
- * Asserts that `set1` and `set2` have the same members.
17709
- * Order is not taken into account.
17710
- *
17711
- * assert.sameMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'same members');
17712
- *
17713
- * @name sameMembers
17714
- * @param {Array} superset
17715
- * @param {Array} subset
17716
- * @param {String} message
17717
- * @api public
17718
- */
17719
-
17720
- assert.sameMembers = function (set1, set2, msg) {
17721
- new Assertion(set1, msg).to.have.same.members(set2);
17722
- }
17723
-
17724
- /**
17725
- * ### .includeMembers(superset, subset, [message])
17726
- *
17727
- * Asserts that `subset` is included in `superset`.
17728
- * Order is not taken into account.
17729
- *
17730
- * assert.includeMembers([ 1, 2, 3 ], [ 2, 1 ], 'include members');
17731
- *
17732
- * @name includeMembers
17733
- * @param {Array} superset
17734
- * @param {Array} subset
17735
- * @param {String} message
17736
- * @api public
17737
- */
17738
-
17739
- assert.includeMembers = function (superset, subset, msg) {
17740
- new Assertion(superset, msg).to.include.members(subset);
17741
- }
17742
-
17743
- /*!
17744
- * Undocumented / untested
17745
- */
17746
-
17747
- assert.ifError = function (val, msg) {
17748
- new Assertion(val, msg).to.not.be.ok;
17749
- };
17750
-
17751
- /*!
17752
- * Aliases.
17753
- */
17754
-
17755
- (function alias(name, as){
17756
- assert[as] = assert[name];
17757
- return alias;
17758
- })
17759
- ('Throw', 'throw')
17760
- ('Throw', 'throws');
17761
- };
17762
-
17763
- });
17764
- require.register("chaijs-chai/lib/chai/interface/expect.js", function(exports, require, module){
17765
- /*!
17766
- * chai
17767
- * Copyright(c) 2011-2013 Jake Luer <jake@alogicalparadox.com>
17768
- * MIT Licensed
17769
- */
17770
-
17771
- module.exports = function (chai, util) {
17772
- chai.expect = function (val, message) {
17773
- return new chai.Assertion(val, message);
17774
- };
17775
- };
17776
-
17777
-
17778
- });
17779
- require.register("chaijs-chai/lib/chai/interface/should.js", function(exports, require, module){
17780
- /*!
17781
- * chai
17782
- * Copyright(c) 2011-2013 Jake Luer <jake@alogicalparadox.com>
17783
- * MIT Licensed
17784
- */
17785
-
17786
- module.exports = function (chai, util) {
17787
- var Assertion = chai.Assertion;
17788
-
17789
- function loadShould () {
17790
- // modify Object.prototype to have `should`
17791
- Object.defineProperty(Object.prototype, 'should',
17792
- {
17793
- set: function (value) {
17794
- // See https://github.com/chaijs/chai/issues/86: this makes
17795
- // `whatever.should = someValue` actually set `someValue`, which is
17796
- // especially useful for `global.should = require('chai').should()`.
17797
- //
17798
- // Note that we have to use [[DefineProperty]] instead of [[Put]]
17799
- // since otherwise we would trigger this very setter!
17800
- Object.defineProperty(this, 'should', {
17801
- value: value,
17802
- enumerable: true,
17803
- configurable: true,
17804
- writable: true
17805
- });
17806
- }
17807
- , get: function(){
17808
- if (this instanceof String || this instanceof Number) {
17809
- return new Assertion(this.constructor(this));
17810
- } else if (this instanceof Boolean) {
17811
- return new Assertion(this == true);
17812
- }
17813
- return new Assertion(this);
17814
- }
17815
- , configurable: true
17816
- });
17817
-
17818
- var should = {};
17819
-
17820
- should.equal = function (val1, val2, msg) {
17821
- new Assertion(val1, msg).to.equal(val2);
17822
- };
17823
-
17824
- should.Throw = function (fn, errt, errs, msg) {
17825
- new Assertion(fn, msg).to.Throw(errt, errs);
17826
- };
17827
-
17828
- should.exist = function (val, msg) {
17829
- new Assertion(val, msg).to.exist;
17830
- }
17831
-
17832
- // negation
17833
- should.not = {}
17834
-
17835
- should.not.equal = function (val1, val2, msg) {
17836
- new Assertion(val1, msg).to.not.equal(val2);
17837
- };
17838
-
17839
- should.not.Throw = function (fn, errt, errs, msg) {
17840
- new Assertion(fn, msg).to.not.Throw(errt, errs);
17841
- };
17842
-
17843
- should.not.exist = function (val, msg) {
17844
- new Assertion(val, msg).to.not.exist;
17845
- }
17846
-
17847
- should['throw'] = should['Throw'];
17848
- should.not['throw'] = should.not['Throw'];
17849
-
17850
- return should;
17851
- };
17852
-
17853
- chai.should = loadShould;
17854
- chai.Should = loadShould;
17855
- };
17856
-
17857
- });
17858
- require.register("chaijs-chai/lib/chai/utils/addChainableMethod.js", function(exports, require, module){
17859
- /*!
17860
- * Chai - addChainingMethod utility
17861
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
17862
- * MIT Licensed
17863
- */
17864
-
17865
- /*!
17866
- * Module dependencies
17867
- */
17868
-
17869
- var transferFlags = require('./transferFlags');
17870
-
17871
- /*!
17872
- * Module variables
17873
- */
17874
-
17875
- // Check whether `__proto__` is supported
17876
- var hasProtoSupport = '__proto__' in Object;
17877
-
17878
- // Without `__proto__` support, this module will need to add properties to a function.
17879
- // However, some Function.prototype methods cannot be overwritten,
17880
- // and there seems no easy cross-platform way to detect them (@see chaijs/chai/issues/69).
17881
- var excludeNames = /^(?:length|name|arguments|caller)$/;
17882
-
17883
- // Cache `Function` properties
17884
- var call = Function.prototype.call,
17885
- apply = Function.prototype.apply;
17886
-
17887
- /**
17888
- * ### addChainableMethod (ctx, name, method, chainingBehavior)
17889
- *
17890
- * Adds a method to an object, such that the method can also be chained.
17891
- *
17892
- * utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) {
17893
- * var obj = utils.flag(this, 'object');
17894
- * new chai.Assertion(obj).to.be.equal(str);
17895
- * });
17896
- *
17897
- * Can also be accessed directly from `chai.Assertion`.
17898
- *
17899
- * chai.Assertion.addChainableMethod('foo', fn, chainingBehavior);
17900
- *
17901
- * The result can then be used as both a method assertion, executing both `method` and
17902
- * `chainingBehavior`, or as a language chain, which only executes `chainingBehavior`.
17903
- *
17904
- * expect(fooStr).to.be.foo('bar');
17905
- * expect(fooStr).to.be.foo.equal('foo');
17906
- *
17907
- * @param {Object} ctx object to which the method is added
17908
- * @param {String} name of method to add
17909
- * @param {Function} method function to be used for `name`, when called
17910
- * @param {Function} chainingBehavior function to be called every time the property is accessed
17911
- * @name addChainableMethod
17912
- * @api public
17913
- */
17914
-
17915
- module.exports = function (ctx, name, method, chainingBehavior) {
17916
- if (typeof chainingBehavior !== 'function')
17917
- chainingBehavior = function () { };
17918
-
17919
- Object.defineProperty(ctx, name,
17920
- { get: function () {
17921
- chainingBehavior.call(this);
17922
-
17923
- var assert = function () {
17924
- var result = method.apply(this, arguments);
17925
- return result === undefined ? this : result;
17926
- };
17927
-
17928
- // Use `__proto__` if available
17929
- if (hasProtoSupport) {
17930
- // Inherit all properties from the object by replacing the `Function` prototype
17931
- var prototype = assert.__proto__ = Object.create(this);
17932
- // Restore the `call` and `apply` methods from `Function`
17933
- prototype.call = call;
17934
- prototype.apply = apply;
17935
- }
17936
- // Otherwise, redefine all properties (slow!)
17937
- else {
17938
- var asserterNames = Object.getOwnPropertyNames(ctx);
17939
- asserterNames.forEach(function (asserterName) {
17940
- if (!excludeNames.test(asserterName)) {
17941
- var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
17942
- Object.defineProperty(assert, asserterName, pd);
17943
- }
17944
- });
17945
- }
17946
-
17947
- transferFlags(this, assert);
17948
- return assert;
17949
- }
17950
- , configurable: true
17951
- });
17952
- };
17953
-
17954
- });
17955
- require.register("chaijs-chai/lib/chai/utils/addMethod.js", function(exports, require, module){
17956
- /*!
17957
- * Chai - addMethod utility
17958
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
17959
- * MIT Licensed
17960
- */
17961
-
17962
- /**
17963
- * ### .addMethod (ctx, name, method)
17964
- *
17965
- * Adds a method to the prototype of an object.
17966
- *
17967
- * utils.addMethod(chai.Assertion.prototype, 'foo', function (str) {
17968
- * var obj = utils.flag(this, 'object');
17969
- * new chai.Assertion(obj).to.be.equal(str);
17970
- * });
17971
- *
17972
- * Can also be accessed directly from `chai.Assertion`.
17973
- *
17974
- * chai.Assertion.addMethod('foo', fn);
17975
- *
17976
- * Then can be used as any other assertion.
17977
- *
17978
- * expect(fooStr).to.be.foo('bar');
17979
- *
17980
- * @param {Object} ctx object to which the method is added
17981
- * @param {String} name of method to add
17982
- * @param {Function} method function to be used for name
17983
- * @name addMethod
17984
- * @api public
17985
- */
17986
-
17987
- module.exports = function (ctx, name, method) {
17988
- ctx[name] = function () {
17989
- var result = method.apply(this, arguments);
17990
- return result === undefined ? this : result;
17991
- };
17992
- };
17993
-
17994
- });
17995
- require.register("chaijs-chai/lib/chai/utils/addProperty.js", function(exports, require, module){
17996
- /*!
17997
- * Chai - addProperty utility
17998
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
17999
- * MIT Licensed
18000
- */
18001
-
18002
- /**
18003
- * ### addProperty (ctx, name, getter)
18004
- *
18005
- * Adds a property to the prototype of an object.
18006
- *
18007
- * utils.addProperty(chai.Assertion.prototype, 'foo', function () {
18008
- * var obj = utils.flag(this, 'object');
18009
- * new chai.Assertion(obj).to.be.instanceof(Foo);
18010
- * });
18011
- *
18012
- * Can also be accessed directly from `chai.Assertion`.
18013
- *
18014
- * chai.Assertion.addProperty('foo', fn);
18015
- *
18016
- * Then can be used as any other assertion.
18017
- *
18018
- * expect(myFoo).to.be.foo;
18019
- *
18020
- * @param {Object} ctx object to which the property is added
18021
- * @param {String} name of property to add
18022
- * @param {Function} getter function to be used for name
18023
- * @name addProperty
18024
- * @api public
18025
- */
18026
-
18027
- module.exports = function (ctx, name, getter) {
18028
- Object.defineProperty(ctx, name,
18029
- { get: function () {
18030
- var result = getter.call(this);
18031
- return result === undefined ? this : result;
18032
- }
18033
- , configurable: true
18034
- });
18035
- };
18036
-
18037
- });
18038
- require.register("chaijs-chai/lib/chai/utils/eql.js", function(exports, require, module){
18039
- // This is (almost) directly from Node.js assert
18040
- // https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/assert.js
18041
-
18042
- module.exports = _deepEqual;
18043
-
18044
- var getEnumerableProperties = require('./getEnumerableProperties');
18045
-
18046
- // for the browser
18047
- var Buffer;
18048
- try {
18049
- Buffer = require('buffer').Buffer;
18050
- } catch (ex) {
18051
- Buffer = {
18052
- isBuffer: function () { return false; }
18053
- };
18054
- }
18055
-
18056
- function _deepEqual(actual, expected, memos) {
18057
-
18058
- // 7.1. All identical values are equivalent, as determined by ===.
18059
- if (actual === expected) {
18060
- return true;
18061
-
18062
- } else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) {
18063
- if (actual.length != expected.length) return false;
18064
-
18065
- for (var i = 0; i < actual.length; i++) {
18066
- if (actual[i] !== expected[i]) return false;
18067
- }
18068
-
18069
- return true;
18070
-
18071
- // 7.2. If the expected value is a Date object, the actual value is
18072
- // equivalent if it is also a Date object that refers to the same time.
18073
- } else if (expected instanceof Date) {
18074
- if (!(actual instanceof Date)) return false;
18075
- return actual.getTime() === expected.getTime();
18076
-
18077
- // 7.3. Other pairs that do not both pass typeof value == 'object',
18078
- // equivalence is determined by ==.
18079
- } else if (typeof actual != 'object' && typeof expected != 'object') {
18080
- return actual === expected;
18081
-
18082
- } else if (expected instanceof RegExp) {
18083
- if (!(actual instanceof RegExp)) return false;
18084
- return actual.toString() === expected.toString();
18085
-
18086
- // 7.4. For all other Object pairs, including Array objects, equivalence is
18087
- // determined by having the same number of owned properties (as verified
18088
- // with Object.prototype.hasOwnProperty.call), the same set of keys
18089
- // (although not necessarily the same order), equivalent values for every
18090
- // corresponding key, and an identical 'prototype' property. Note: this
18091
- // accounts for both named and indexed properties on Arrays.
18092
- } else {
18093
- return objEquiv(actual, expected, memos);
18094
- }
18095
- }
18096
-
18097
- function isUndefinedOrNull(value) {
18098
- return value === null || value === undefined;
18099
- }
18100
-
18101
- function isArguments(object) {
18102
- return Object.prototype.toString.call(object) == '[object Arguments]';
18103
- }
18104
-
18105
- function objEquiv(a, b, memos) {
18106
- if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
18107
- return false;
18108
-
18109
- // an identical 'prototype' property.
18110
- if (a.prototype !== b.prototype) return false;
18111
-
18112
- // check if we have already compared a and b
18113
- var i;
18114
- if (memos) {
18115
- for(i = 0; i < memos.length; i++) {
18116
- if ((memos[i][0] === a && memos[i][1] === b) ||
18117
- (memos[i][0] === b && memos[i][1] === a))
18118
- return true;
18119
- }
18120
- } else {
18121
- memos = [];
18122
- }
18123
-
18124
- //~~~I've managed to break Object.keys through screwy arguments passing.
18125
- // Converting to array solves the problem.
18126
- if (isArguments(a)) {
18127
- if (!isArguments(b)) {
18128
- return false;
18129
- }
18130
- a = pSlice.call(a);
18131
- b = pSlice.call(b);
18132
- return _deepEqual(a, b, memos);
18133
- }
18134
- try {
18135
- var ka = getEnumerableProperties(a),
18136
- kb = getEnumerableProperties(b),
18137
- key;
18138
- } catch (e) {//happens when one is a string literal and the other isn't
18139
- return false;
18140
- }
18141
-
18142
- // having the same number of owned properties (keys incorporates
18143
- // hasOwnProperty)
18144
- if (ka.length != kb.length)
18145
- return false;
18146
-
18147
- //the same set of keys (although not necessarily the same order),
18148
- ka.sort();
18149
- kb.sort();
18150
- //~~~cheap key test
18151
- for (i = ka.length - 1; i >= 0; i--) {
18152
- if (ka[i] != kb[i])
18153
- return false;
18154
- }
18155
-
18156
- // remember objects we have compared to guard against circular references
18157
- memos.push([ a, b ]);
18158
-
18159
- //equivalent values for every corresponding key, and
18160
- //~~~possibly expensive deep test
18161
- for (i = ka.length - 1; i >= 0; i--) {
18162
- key = ka[i];
18163
- if (!_deepEqual(a[key], b[key], memos)) return false;
18164
- }
18165
-
18166
- return true;
18167
- }
18168
-
18169
- });
18170
- require.register("chaijs-chai/lib/chai/utils/flag.js", function(exports, require, module){
18171
- /*!
18172
- * Chai - flag utility
18173
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
18174
- * MIT Licensed
18175
- */
18176
-
18177
- /**
18178
- * ### flag(object ,key, [value])
18179
- *
18180
- * Get or set a flag value on an object. If a
18181
- * value is provided it will be set, else it will
18182
- * return the currently set value or `undefined` if
18183
- * the value is not set.
18184
- *
18185
- * utils.flag(this, 'foo', 'bar'); // setter
18186
- * utils.flag(this, 'foo'); // getter, returns `bar`
18187
- *
18188
- * @param {Object} object (constructed Assertion
18189
- * @param {String} key
18190
- * @param {Mixed} value (optional)
18191
- * @name flag
18192
- * @api private
18193
- */
18194
-
18195
- module.exports = function (obj, key, value) {
18196
- var flags = obj.__flags || (obj.__flags = Object.create(null));
18197
- if (arguments.length === 3) {
18198
- flags[key] = value;
18199
- } else {
18200
- return flags[key];
18201
- }
18202
- };
18203
-
18204
- });
18205
- require.register("chaijs-chai/lib/chai/utils/getActual.js", function(exports, require, module){
18206
- /*!
18207
- * Chai - getActual utility
18208
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
18209
- * MIT Licensed
18210
- */
18211
-
18212
- /**
18213
- * # getActual(object, [actual])
18214
- *
18215
- * Returns the `actual` value for an Assertion
18216
- *
18217
- * @param {Object} object (constructed Assertion)
18218
- * @param {Arguments} chai.Assertion.prototype.assert arguments
18219
- */
18220
-
18221
- module.exports = function (obj, args) {
18222
- var actual = args[4];
18223
- return 'undefined' !== typeof actual ? actual : obj._obj;
18224
- };
18225
-
18226
- });
18227
- require.register("chaijs-chai/lib/chai/utils/getEnumerableProperties.js", function(exports, require, module){
18228
- /*!
18229
- * Chai - getEnumerableProperties utility
18230
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
18231
- * MIT Licensed
18232
- */
18233
-
18234
- /**
18235
- * ### .getEnumerableProperties(object)
18236
- *
18237
- * This allows the retrieval of enumerable property names of an object,
18238
- * inherited or not.
18239
- *
18240
- * @param {Object} object
18241
- * @returns {Array}
18242
- * @name getEnumerableProperties
18243
- * @api public
18244
- */
18245
-
18246
- module.exports = function getEnumerableProperties(object) {
18247
- var result = [];
18248
- for (var name in object) {
18249
- result.push(name);
18250
- }
18251
- return result;
18252
- };
18253
-
18254
- });
18255
- require.register("chaijs-chai/lib/chai/utils/getMessage.js", function(exports, require, module){
18256
- /*!
18257
- * Chai - message composition utility
18258
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
18259
- * MIT Licensed
18260
- */
18261
-
18262
- /*!
18263
- * Module dependancies
18264
- */
18265
-
18266
- var flag = require('./flag')
18267
- , getActual = require('./getActual')
18268
- , inspect = require('./inspect')
18269
- , objDisplay = require('./objDisplay');
18270
-
18271
- /**
18272
- * ### .getMessage(object, message, negateMessage)
18273
- *
18274
- * Construct the error message based on flags
18275
- * and template tags. Template tags will return
18276
- * a stringified inspection of the object referenced.
18277
- *
18278
- * Message template tags:
18279
- * - `#{this}` current asserted object
18280
- * - `#{act}` actual value
18281
- * - `#{exp}` expected value
18282
- *
18283
- * @param {Object} object (constructed Assertion)
18284
- * @param {Arguments} chai.Assertion.prototype.assert arguments
18285
- * @name getMessage
18286
- * @api public
18287
- */
18288
-
18289
- module.exports = function (obj, args) {
18290
- var negate = flag(obj, 'negate')
18291
- , val = flag(obj, 'object')
18292
- , expected = args[3]
18293
- , actual = getActual(obj, args)
18294
- , msg = negate ? args[2] : args[1]
18295
- , flagMsg = flag(obj, 'message');
18296
-
18297
- msg = msg || '';
18298
- msg = msg
18299
- .replace(/#{this}/g, objDisplay(val))
18300
- .replace(/#{act}/g, objDisplay(actual))
18301
- .replace(/#{exp}/g, objDisplay(expected));
18302
-
18303
- return flagMsg ? flagMsg + ': ' + msg : msg;
18304
- };
18305
-
18306
- });
18307
- require.register("chaijs-chai/lib/chai/utils/getName.js", function(exports, require, module){
18308
- /*!
18309
- * Chai - getName utility
18310
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
18311
- * MIT Licensed
18312
- */
18313
-
18314
- /**
18315
- * # getName(func)
18316
- *
18317
- * Gets the name of a function, in a cross-browser way.
18318
- *
18319
- * @param {Function} a function (usually a constructor)
18320
- */
18321
-
18322
- module.exports = function (func) {
18323
- if (func.name) return func.name;
18324
-
18325
- var match = /^\s?function ([^(]*)\(/.exec(func);
18326
- return match && match[1] ? match[1] : "";
18327
- };
18328
-
18329
- });
18330
- require.register("chaijs-chai/lib/chai/utils/getPathValue.js", function(exports, require, module){
18331
- /*!
18332
- * Chai - getPathValue utility
18333
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
18334
- * @see https://github.com/logicalparadox/filtr
18335
- * MIT Licensed
18336
- */
18337
-
18338
- /**
18339
- * ### .getPathValue(path, object)
18340
- *
18341
- * This allows the retrieval of values in an
18342
- * object given a string path.
18343
- *
18344
- * var obj = {
18345
- * prop1: {
18346
- * arr: ['a', 'b', 'c']
18347
- * , str: 'Hello'
18348
- * }
18349
- * , prop2: {
18350
- * arr: [ { nested: 'Universe' } ]
18351
- * , str: 'Hello again!'
18352
- * }
18353
- * }
18354
- *
18355
- * The following would be the results.
18356
- *
18357
- * getPathValue('prop1.str', obj); // Hello
18358
- * getPathValue('prop1.att[2]', obj); // b
18359
- * getPathValue('prop2.arr[0].nested', obj); // Universe
18360
- *
18361
- * @param {String} path
18362
- * @param {Object} object
18363
- * @returns {Object} value or `undefined`
18364
- * @name getPathValue
18365
- * @api public
18366
- */
18367
-
18368
- var getPathValue = module.exports = function (path, obj) {
18369
- var parsed = parsePath(path);
18370
- return _getPathValue(parsed, obj);
18371
- };
18372
-
18373
- /*!
18374
- * ## parsePath(path)
18375
- *
18376
- * Helper function used to parse string object
18377
- * paths. Use in conjunction with `_getPathValue`.
18378
- *
18379
- * var parsed = parsePath('myobject.property.subprop');
18380
- *
18381
- * ### Paths:
18382
- *
18383
- * * Can be as near infinitely deep and nested
18384
- * * Arrays are also valid using the formal `myobject.document[3].property`.
18385
- *
18386
- * @param {String} path
18387
- * @returns {Object} parsed
18388
- * @api private
18389
- */
18390
-
18391
- function parsePath (path) {
18392
- var str = path.replace(/\[/g, '.[')
18393
- , parts = str.match(/(\\\.|[^.]+?)+/g);
18394
- return parts.map(function (value) {
18395
- var re = /\[(\d+)\]$/
18396
- , mArr = re.exec(value)
18397
- if (mArr) return { i: parseFloat(mArr[1]) };
18398
- else return { p: value };
18399
- });
18400
- };
18401
-
18402
- /*!
18403
- * ## _getPathValue(parsed, obj)
18404
- *
18405
- * Helper companion function for `.parsePath` that returns
18406
- * the value located at the parsed address.
18407
- *
18408
- * var value = getPathValue(parsed, obj);
18409
- *
18410
- * @param {Object} parsed definition from `parsePath`.
18411
- * @param {Object} object to search against
18412
- * @returns {Object|Undefined} value
18413
- * @api private
18414
- */
18415
-
18416
- function _getPathValue (parsed, obj) {
18417
- var tmp = obj
18418
- , res;
18419
- for (var i = 0, l = parsed.length; i < l; i++) {
18420
- var part = parsed[i];
18421
- if (tmp) {
18422
- if ('undefined' !== typeof part.p)
18423
- tmp = tmp[part.p];
18424
- else if ('undefined' !== typeof part.i)
18425
- tmp = tmp[part.i];
18426
- if (i == (l - 1)) res = tmp;
18427
- } else {
18428
- res = undefined;
18429
- }
18430
- }
18431
- return res;
18432
- };
18433
-
18434
- });
18435
- require.register("chaijs-chai/lib/chai/utils/getProperties.js", function(exports, require, module){
18436
- /*!
18437
- * Chai - getProperties utility
18438
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
18439
- * MIT Licensed
18440
- */
18441
-
18442
- /**
18443
- * ### .getProperties(object)
18444
- *
18445
- * This allows the retrieval of property names of an object, enumerable or not,
18446
- * inherited or not.
18447
- *
18448
- * @param {Object} object
18449
- * @returns {Array}
18450
- * @name getProperties
18451
- * @api public
18452
- */
18453
-
18454
- module.exports = function getProperties(object) {
18455
- var result = Object.getOwnPropertyNames(subject);
18456
-
18457
- function addProperty(property) {
18458
- if (result.indexOf(property) === -1) {
18459
- result.push(property);
18460
- }
18461
- }
18462
-
18463
- var proto = Object.getPrototypeOf(subject);
18464
- while (proto !== null) {
18465
- Object.getOwnPropertyNames(proto).forEach(addProperty);
18466
- proto = Object.getPrototypeOf(proto);
18467
- }
18468
-
18469
- return result;
18470
- };
18471
-
18472
- });
18473
- require.register("chaijs-chai/lib/chai/utils/index.js", function(exports, require, module){
18474
- /*!
18475
- * chai
18476
- * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
18477
- * MIT Licensed
18478
- */
18479
-
18480
- /*!
18481
- * Main exports
18482
- */
18483
-
18484
- var exports = module.exports = {};
18485
-
18486
- /*!
18487
- * test utility
18488
- */
18489
-
18490
- exports.test = require('./test');
18491
-
18492
- /*!
18493
- * type utility
18494
- */
18495
-
18496
- exports.type = require('./type');
18497
-
18498
- /*!
18499
- * message utility
18500
- */
18501
-
18502
- exports.getMessage = require('./getMessage');
18503
-
18504
- /*!
18505
- * actual utility
18506
- */
18507
-
18508
- exports.getActual = require('./getActual');
18509
-
18510
- /*!
18511
- * Inspect util
18512
- */
18513
-
18514
- exports.inspect = require('./inspect');
18515
-
18516
- /*!
18517
- * Object Display util
18518
- */
18519
-
18520
- exports.objDisplay = require('./objDisplay');
18521
-
18522
- /*!
18523
- * Flag utility
18524
- */
18525
-
18526
- exports.flag = require('./flag');
18527
-
18528
- /*!
18529
- * Flag transferring utility
18530
- */
18531
-
18532
- exports.transferFlags = require('./transferFlags');
18533
-
18534
- /*!
18535
- * Deep equal utility
18536
- */
18537
-
18538
- exports.eql = require('./eql');
18539
-
18540
- /*!
18541
- * Deep path value
18542
- */
18543
-
18544
- exports.getPathValue = require('./getPathValue');
18545
-
18546
- /*!
18547
- * Function name
18548
- */
18549
-
18550
- exports.getName = require('./getName');
18551
-
18552
- /*!
18553
- * add Property
18554
- */
18555
-
18556
- exports.addProperty = require('./addProperty');
18557
-
18558
- /*!
18559
- * add Method
18560
- */
18561
-
18562
- exports.addMethod = require('./addMethod');
18563
-
18564
- /*!
18565
- * overwrite Property
18566
- */
18567
-
18568
- exports.overwriteProperty = require('./overwriteProperty');
18569
-
18570
- /*!
18571
- * overwrite Method
18572
- */
18573
-
18574
- exports.overwriteMethod = require('./overwriteMethod');
18575
-
18576
- /*!
18577
- * Add a chainable method
18578
- */
18579
-
18580
- exports.addChainableMethod = require('./addChainableMethod');
18581
-
18582
-
18583
- });
18584
- require.register("chaijs-chai/lib/chai/utils/inspect.js", function(exports, require, module){
18585
- // This is (almost) directly from Node.js utils
18586
- // https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js
18587
-
18588
- var getName = require('./getName');
18589
- var getProperties = require('./getProperties');
18590
- var getEnumerableProperties = require('./getEnumerableProperties');
18591
-
18592
- module.exports = inspect;
18593
-
18594
- /**
18595
- * Echos the value of a value. Trys to print the value out
18596
- * in the best way possible given the different types.
18597
- *
18598
- * @param {Object} obj The object to print out.
18599
- * @param {Boolean} showHidden Flag that shows hidden (not enumerable)
18600
- * properties of objects.
18601
- * @param {Number} depth Depth in which to descend in object. Default is 2.
18602
- * @param {Boolean} colors Flag to turn on ANSI escape codes to color the
18603
- * output. Default is false (no coloring).
18604
- */
18605
- function inspect(obj, showHidden, depth, colors) {
18606
- var ctx = {
18607
- showHidden: showHidden,
18608
- seen: [],
18609
- stylize: function (str) { return str; }
18610
- };
18611
- return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
18612
- }
18613
-
18614
- // https://gist.github.com/1044128/
18615
- var getOuterHTML = function(element) {
18616
- if ('outerHTML' in element) return element.outerHTML;
18617
- var ns = "http://www.w3.org/1999/xhtml";
18618
- var container = document.createElementNS(ns, '_');
18619
- var elemProto = (window.HTMLElement || window.Element).prototype;
18620
- var xmlSerializer = new XMLSerializer();
18621
- var html;
18622
- if (document.xmlVersion) {
18623
- return xmlSerializer.serializeToString(element);
18624
- } else {
18625
- container.appendChild(element.cloneNode(false));
18626
- html = container.innerHTML.replace('><', '>' + element.innerHTML + '<');
18627
- container.innerHTML = '';
18628
- return html;
18629
- }
18630
- };
18631
-
18632
- // Returns true if object is a DOM element.
18633
- var isDOMElement = function (object) {
18634
- if (typeof HTMLElement === 'object') {
18635
- return object instanceof HTMLElement;
18636
- } else {
18637
- return object &&
18638
- typeof object === 'object' &&
18639
- object.nodeType === 1 &&
18640
- typeof object.nodeName === 'string';
18641
- }
18642
- };
18643
-
18644
- function formatValue(ctx, value, recurseTimes) {
18645
- // Provide a hook for user-specified inspect functions.
18646
- // Check that value is an object with an inspect function on it
18647
- if (value && typeof value.inspect === 'function' &&
18648
- // Filter out the util module, it's inspect function is special
18649
- value.inspect !== exports.inspect &&
18650
- // Also filter out any prototype objects using the circular check.
18651
- !(value.constructor && value.constructor.prototype === value)) {
18652
- var ret = value.inspect(recurseTimes);
18653
- if (typeof ret !== 'string') {
18654
- ret = formatValue(ctx, ret, recurseTimes);
18655
- }
18656
- return ret;
18657
- }
18658
-
18659
- // Primitive types cannot have properties
18660
- var primitive = formatPrimitive(ctx, value);
18661
- if (primitive) {
18662
- return primitive;
18663
- }
18664
-
18665
- // If it's DOM elem, get outer HTML.
18666
- if (isDOMElement(value)) {
18667
- return getOuterHTML(value);
18668
- }
18669
-
18670
- // Look up the keys of the object.
18671
- var visibleKeys = getEnumerableProperties(value);
18672
- var keys = ctx.showHidden ? getProperties(value) : visibleKeys;
18673
-
18674
- // Some type of object without properties can be shortcutted.
18675
- // In IE, errors have a single `stack` property, or if they are vanilla `Error`,
18676
- // a `stack` plus `description` property; ignore those for consistency.
18677
- if (keys.length === 0 || (isError(value) && (
18678
- (keys.length === 1 && keys[0] === 'stack') ||
18679
- (keys.length === 2 && keys[0] === 'description' && keys[1] === 'stack')
18680
- ))) {
18681
- if (typeof value === 'function') {
18682
- var name = getName(value);
18683
- var nameSuffix = name ? ': ' + name : '';
18684
- return ctx.stylize('[Function' + nameSuffix + ']', 'special');
18685
- }
18686
- if (isRegExp(value)) {
18687
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
18688
- }
18689
- if (isDate(value)) {
18690
- return ctx.stylize(Date.prototype.toUTCString.call(value), 'date');
18691
- }
18692
- if (isError(value)) {
18693
- return formatError(value);
18694
- }
18695
- }
18696
-
18697
- var base = '', array = false, braces = ['{', '}'];
18698
-
18699
- // Make Array say that they are Array
18700
- if (isArray(value)) {
18701
- array = true;
18702
- braces = ['[', ']'];
18703
- }
18704
-
18705
- // Make functions say that they are functions
18706
- if (typeof value === 'function') {
18707
- var name = getName(value);
18708
- var nameSuffix = name ? ': ' + name : '';
18709
- base = ' [Function' + nameSuffix + ']';
18710
- }
18711
-
18712
- // Make RegExps say that they are RegExps
18713
- if (isRegExp(value)) {
18714
- base = ' ' + RegExp.prototype.toString.call(value);
18715
- }
18716
-
18717
- // Make dates with properties first say the date
18718
- if (isDate(value)) {
18719
- base = ' ' + Date.prototype.toUTCString.call(value);
18720
- }
18721
-
18722
- // Make error with message first say the error
18723
- if (isError(value)) {
18724
- return formatError(value);
18725
- }
18726
-
18727
- if (keys.length === 0 && (!array || value.length == 0)) {
18728
- return braces[0] + base + braces[1];
18729
- }
18730
-
18731
- if (recurseTimes < 0) {
18732
- if (isRegExp(value)) {
18733
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
18734
- } else {
18735
- return ctx.stylize('[Object]', 'special');
18736
- }
18737
- }
18738
-
18739
- ctx.seen.push(value);
18740
-
18741
- var output;
18742
- if (array) {
18743
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
18744
- } else {
18745
- output = keys.map(function(key) {
18746
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
18747
- });
18748
- }
18749
-
18750
- ctx.seen.pop();
18751
-
18752
- return reduceToSingleString(output, base, braces);
18753
- }
18754
-
18755
-
18756
- function formatPrimitive(ctx, value) {
18757
- switch (typeof value) {
18758
- case 'undefined':
18759
- return ctx.stylize('undefined', 'undefined');
18760
-
18761
- case 'string':
18762
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
18763
- .replace(/'/g, "\\'")
18764
- .replace(/\\"/g, '"') + '\'';
18765
- return ctx.stylize(simple, 'string');
18766
-
18767
- case 'number':
18768
- return ctx.stylize('' + value, 'number');
18769
-
18770
- case 'boolean':
18771
- return ctx.stylize('' + value, 'boolean');
18772
- }
18773
- // For some reason typeof null is "object", so special case here.
18774
- if (value === null) {
18775
- return ctx.stylize('null', 'null');
18776
- }
18777
- }
18778
-
18779
-
18780
- function formatError(value) {
18781
- return '[' + Error.prototype.toString.call(value) + ']';
18782
- }
18783
-
18784
-
18785
- function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
18786
- var output = [];
18787
- for (var i = 0, l = value.length; i < l; ++i) {
18788
- if (Object.prototype.hasOwnProperty.call(value, String(i))) {
18789
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
18790
- String(i), true));
18791
- } else {
18792
- output.push('');
18793
- }
18794
- }
18795
- keys.forEach(function(key) {
18796
- if (!key.match(/^\d+$/)) {
18797
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
18798
- key, true));
18799
- }
18800
- });
18801
- return output;
18802
- }
18803
-
18804
-
18805
- function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
18806
- var name, str;
18807
- if (value.__lookupGetter__) {
18808
- if (value.__lookupGetter__(key)) {
18809
- if (value.__lookupSetter__(key)) {
18810
- str = ctx.stylize('[Getter/Setter]', 'special');
18811
- } else {
18812
- str = ctx.stylize('[Getter]', 'special');
18813
- }
18814
- } else {
18815
- if (value.__lookupSetter__(key)) {
18816
- str = ctx.stylize('[Setter]', 'special');
18817
- }
18818
- }
18819
- }
18820
- if (visibleKeys.indexOf(key) < 0) {
18821
- name = '[' + key + ']';
18822
- }
18823
- if (!str) {
18824
- if (ctx.seen.indexOf(value[key]) < 0) {
18825
- if (recurseTimes === null) {
18826
- str = formatValue(ctx, value[key], null);
18827
- } else {
18828
- str = formatValue(ctx, value[key], recurseTimes - 1);
18829
- }
18830
- if (str.indexOf('\n') > -1) {
18831
- if (array) {
18832
- str = str.split('\n').map(function(line) {
18833
- return ' ' + line;
18834
- }).join('\n').substr(2);
18835
- } else {
18836
- str = '\n' + str.split('\n').map(function(line) {
18837
- return ' ' + line;
18838
- }).join('\n');
18839
- }
18840
- }
18841
- } else {
18842
- str = ctx.stylize('[Circular]', 'special');
18843
- }
18844
- }
18845
- if (typeof name === 'undefined') {
18846
- if (array && key.match(/^\d+$/)) {
18847
- return str;
18848
- }
18849
- name = JSON.stringify('' + key);
18850
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
18851
- name = name.substr(1, name.length - 2);
18852
- name = ctx.stylize(name, 'name');
18853
- } else {
18854
- name = name.replace(/'/g, "\\'")
18855
- .replace(/\\"/g, '"')
18856
- .replace(/(^"|"$)/g, "'");
18857
- name = ctx.stylize(name, 'string');
18858
- }
18859
- }
18860
-
18861
- return name + ': ' + str;
18862
- }
18863
-
18864
-
18865
- function reduceToSingleString(output, base, braces) {
18866
- var numLinesEst = 0;
18867
- var length = output.reduce(function(prev, cur) {
18868
- numLinesEst++;
18869
- if (cur.indexOf('\n') >= 0) numLinesEst++;
18870
- return prev + cur.length + 1;
18871
- }, 0);
18872
-
18873
- if (length > 60) {
18874
- return braces[0] +
18875
- (base === '' ? '' : base + '\n ') +
18876
- ' ' +
18877
- output.join(',\n ') +
18878
- ' ' +
18879
- braces[1];
18880
- }
18881
-
18882
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
18883
- }
18884
-
18885
- function isArray(ar) {
18886
- return Array.isArray(ar) ||
18887
- (typeof ar === 'object' && objectToString(ar) === '[object Array]');
18888
- }
18889
-
18890
- function isRegExp(re) {
18891
- return typeof re === 'object' && objectToString(re) === '[object RegExp]';
18892
- }
18893
-
18894
- function isDate(d) {
18895
- return typeof d === 'object' && objectToString(d) === '[object Date]';
18896
- }
18897
-
18898
- function isError(e) {
18899
- return typeof e === 'object' && objectToString(e) === '[object Error]';
18900
- }
18901
-
18902
- function objectToString(o) {
18903
- return Object.prototype.toString.call(o);
18904
- }
18905
-
18906
- });
18907
- require.register("chaijs-chai/lib/chai/utils/objDisplay.js", function(exports, require, module){
18908
- /*!
18909
- * Chai - flag utility
18910
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
18911
- * MIT Licensed
18912
- */
18913
-
18914
- /*!
18915
- * Module dependancies
18916
- */
18917
-
18918
- var inspect = require('./inspect');
18919
-
18920
- /**
18921
- * ### .objDisplay (object)
18922
- *
18923
- * Determines if an object or an array matches
18924
- * criteria to be inspected in-line for error
18925
- * messages or should be truncated.
18926
- *
18927
- * @param {Mixed} javascript object to inspect
18928
- * @name objDisplay
18929
- * @api public
18930
- */
18931
-
18932
- module.exports = function (obj) {
18933
- var str = inspect(obj)
18934
- , type = Object.prototype.toString.call(obj);
18935
-
18936
- if (str.length >= 40) {
18937
- if (type === '[object Function]') {
18938
- return !obj.name || obj.name === ''
18939
- ? '[Function]'
18940
- : '[Function: ' + obj.name + ']';
18941
- } else if (type === '[object Array]') {
18942
- return '[ Array(' + obj.length + ') ]';
18943
- } else if (type === '[object Object]') {
18944
- var keys = Object.keys(obj)
18945
- , kstr = keys.length > 2
18946
- ? keys.splice(0, 2).join(', ') + ', ...'
18947
- : keys.join(', ');
18948
- return '{ Object (' + kstr + ') }';
18949
- } else {
18950
- return str;
18951
- }
18952
- } else {
18953
- return str;
18954
- }
18955
- };
18956
-
18957
- });
18958
- require.register("chaijs-chai/lib/chai/utils/overwriteMethod.js", function(exports, require, module){
18959
- /*!
18960
- * Chai - overwriteMethod utility
18961
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
18962
- * MIT Licensed
18963
- */
18964
-
18965
- /**
18966
- * ### overwriteMethod (ctx, name, fn)
18967
- *
18968
- * Overwites an already existing method and provides
18969
- * access to previous function. Must return function
18970
- * to be used for name.
18971
- *
18972
- * utils.overwriteMethod(chai.Assertion.prototype, 'equal', function (_super) {
18973
- * return function (str) {
18974
- * var obj = utils.flag(this, 'object');
18975
- * if (obj instanceof Foo) {
18976
- * new chai.Assertion(obj.value).to.equal(str);
18977
- * } else {
18978
- * _super.apply(this, arguments);
18979
- * }
18980
- * }
18981
- * });
18982
- *
18983
- * Can also be accessed directly from `chai.Assertion`.
18984
- *
18985
- * chai.Assertion.overwriteMethod('foo', fn);
18986
- *
18987
- * Then can be used as any other assertion.
18988
- *
18989
- * expect(myFoo).to.equal('bar');
18990
- *
18991
- * @param {Object} ctx object whose method is to be overwritten
18992
- * @param {String} name of method to overwrite
18993
- * @param {Function} method function that returns a function to be used for name
18994
- * @name overwriteMethod
18995
- * @api public
18996
- */
18997
-
18998
- module.exports = function (ctx, name, method) {
18999
- var _method = ctx[name]
19000
- , _super = function () { return this; };
19001
-
19002
- if (_method && 'function' === typeof _method)
19003
- _super = _method;
19004
-
19005
- ctx[name] = function () {
19006
- var result = method(_super).apply(this, arguments);
19007
- return result === undefined ? this : result;
19008
- }
19009
- };
19010
-
19011
- });
19012
- require.register("chaijs-chai/lib/chai/utils/overwriteProperty.js", function(exports, require, module){
19013
- /*!
19014
- * Chai - overwriteProperty utility
19015
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
19016
- * MIT Licensed
19017
- */
19018
-
19019
- /**
19020
- * ### overwriteProperty (ctx, name, fn)
19021
- *
19022
- * Overwites an already existing property getter and provides
19023
- * access to previous value. Must return function to use as getter.
19024
- *
19025
- * utils.overwriteProperty(chai.Assertion.prototype, 'ok', function (_super) {
19026
- * return function () {
19027
- * var obj = utils.flag(this, 'object');
19028
- * if (obj instanceof Foo) {
19029
- * new chai.Assertion(obj.name).to.equal('bar');
19030
- * } else {
19031
- * _super.call(this);
19032
- * }
19033
- * }
19034
- * });
19035
- *
19036
- *
19037
- * Can also be accessed directly from `chai.Assertion`.
19038
- *
19039
- * chai.Assertion.overwriteProperty('foo', fn);
19040
- *
19041
- * Then can be used as any other assertion.
19042
- *
19043
- * expect(myFoo).to.be.ok;
19044
- *
19045
- * @param {Object} ctx object whose property is to be overwritten
19046
- * @param {String} name of property to overwrite
19047
- * @param {Function} getter function that returns a getter function to be used for name
19048
- * @name overwriteProperty
19049
- * @api public
19050
- */
19051
-
19052
- module.exports = function (ctx, name, getter) {
19053
- var _get = Object.getOwnPropertyDescriptor(ctx, name)
19054
- , _super = function () {};
19055
-
19056
- if (_get && 'function' === typeof _get.get)
19057
- _super = _get.get
19058
-
19059
- Object.defineProperty(ctx, name,
19060
- { get: function () {
19061
- var result = getter(_super).call(this);
19062
- return result === undefined ? this : result;
19063
- }
19064
- , configurable: true
19065
- });
19066
- };
19067
-
19068
- });
19069
- require.register("chaijs-chai/lib/chai/utils/test.js", function(exports, require, module){
19070
- /*!
19071
- * Chai - test utility
19072
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
19073
- * MIT Licensed
19074
- */
19075
-
19076
- /*!
19077
- * Module dependancies
19078
- */
19079
-
19080
- var flag = require('./flag');
19081
-
19082
- /**
19083
- * # test(object, expression)
19084
- *
19085
- * Test and object for expression.
19086
- *
19087
- * @param {Object} object (constructed Assertion)
19088
- * @param {Arguments} chai.Assertion.prototype.assert arguments
19089
- */
19090
-
19091
- module.exports = function (obj, args) {
19092
- var negate = flag(obj, 'negate')
19093
- , expr = args[0];
19094
- return negate ? !expr : expr;
19095
- };
19096
-
19097
- });
19098
- require.register("chaijs-chai/lib/chai/utils/transferFlags.js", function(exports, require, module){
19099
- /*!
19100
- * Chai - transferFlags utility
19101
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
19102
- * MIT Licensed
19103
- */
19104
-
19105
- /**
19106
- * ### transferFlags(assertion, object, includeAll = true)
19107
- *
19108
- * Transfer all the flags for `assertion` to `object`. If
19109
- * `includeAll` is set to `false`, then the base Chai
19110
- * assertion flags (namely `object`, `ssfi`, and `message`)
19111
- * will not be transferred.
19112
- *
19113
- *
19114
- * var newAssertion = new Assertion();
19115
- * utils.transferFlags(assertion, newAssertion);
19116
- *
19117
- * var anotherAsseriton = new Assertion(myObj);
19118
- * utils.transferFlags(assertion, anotherAssertion, false);
19119
- *
19120
- * @param {Assertion} assertion the assertion to transfer the flags from
19121
- * @param {Object} object the object to transfer the flags too; usually a new assertion
19122
- * @param {Boolean} includeAll
19123
- * @name getAllFlags
19124
- * @api private
19125
- */
19126
-
19127
- module.exports = function (assertion, object, includeAll) {
19128
- var flags = assertion.__flags || (assertion.__flags = Object.create(null));
19129
-
19130
- if (!object.__flags) {
19131
- object.__flags = Object.create(null);
19132
- }
19133
-
19134
- includeAll = arguments.length === 3 ? includeAll : true;
19135
-
19136
- for (var flag in flags) {
19137
- if (includeAll ||
19138
- (flag !== 'object' && flag !== 'ssfi' && flag != 'message')) {
19139
- object.__flags[flag] = flags[flag];
19140
- }
19141
- }
19142
- };
19143
-
19144
- });
19145
- require.register("chaijs-chai/lib/chai/utils/type.js", function(exports, require, module){
19146
- /*!
19147
- * Chai - type utility
19148
- * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
19149
- * MIT Licensed
19150
- */
19151
-
19152
- /*!
19153
- * Detectable javascript natives
19154
- */
19155
-
19156
- var natives = {
19157
- '[object Arguments]': 'arguments'
19158
- , '[object Array]': 'array'
19159
- , '[object Date]': 'date'
19160
- , '[object Function]': 'function'
19161
- , '[object Number]': 'number'
19162
- , '[object RegExp]': 'regexp'
19163
- , '[object String]': 'string'
19164
- };
19165
-
19166
- /**
19167
- * ### type(object)
19168
- *
19169
- * Better implementation of `typeof` detection that can
19170
- * be used cross-browser. Handles the inconsistencies of
19171
- * Array, `null`, and `undefined` detection.
19172
- *
19173
- * utils.type({}) // 'object'
19174
- * utils.type(null) // `null'
19175
- * utils.type(undefined) // `undefined`
19176
- * utils.type([]) // `array`
19177
- *
19178
- * @param {Mixed} object to detect type of
19179
- * @name type
19180
- * @api private
19181
- */
19182
-
19183
- module.exports = function (obj) {
19184
- var str = Object.prototype.toString.call(obj);
19185
- if (natives[str]) return natives[str];
19186
- if (obj === null) return 'null';
19187
- if (obj === undefined) return 'undefined';
19188
- if (obj === Object(obj)) return 'object';
19189
- return typeof obj;
19190
- };
19191
-
19192
15074
  });
19193
15075
  require.register("indemma/index.js", function(exports, require, module){
19194
15076
  module.exports = require('./lib/record');
@@ -24153,7 +20035,9 @@ this.model = (function() {
24153
20035
  data.route || (data.route = this.route);
24154
20036
  data.nested_attributes = this.nested_attributes || [];
24155
20037
  after_initialize = (data.after_initialize || []).concat(this.record.after_initialize);
24156
- creation = extend(Object.create(data), this.record, creation, {
20038
+ creation = extend(Object.create(data, {
20039
+ _shim: {}
20040
+ }), this.record, creation, {
24157
20041
  after_initialize: after_initialize
24158
20042
  });
24159
20043
  _ref = this.record.before_initialize;
@@ -24348,11 +20232,15 @@ subscribers = {
24348
20232
  modifiers = {
24349
20233
  belongs_to: {
24350
20234
  associated_loader: function() {
24351
- var association_name,
20235
+ var association_name, definition, temporary_observed,
24352
20236
  _this = this;
24353
20237
 
24354
20238
  association_name = this.resource.toString();
24355
- return Object.defineProperty(this.owner, association_name, {
20239
+ if (this.owner.observed == null) {
20240
+ this.owner.observed = {};
20241
+ temporary_observed = true;
20242
+ }
20243
+ definition = Object.defineProperty(this.owner, association_name, {
24356
20244
  set: function(associated) {
24357
20245
  return this.observed[association_name] = associated;
24358
20246
  },
@@ -24385,6 +20273,10 @@ modifiers = {
24385
20273
  configurable: true,
24386
20274
  enumerable: true
24387
20275
  });
20276
+ if (temporary_observed) {
20277
+ delete this.owner.observed;
20278
+ }
20279
+ return definition;
24388
20280
  }
24389
20281
  }
24390
20282
  };
@@ -25206,14 +21098,26 @@ restful = {
25206
21098
  return this.saving = false;
25207
21099
  },
25208
21100
  toString: function() {
25209
- var serialized;
21101
+ var e, name, property, serialized;
25210
21102
 
25211
21103
  serialized = {};
25212
21104
  serialized[this.resource] = this.json();
25213
- return JSON.stringify(serialized);
21105
+ try {
21106
+ return JSON.stringify(serialized);
21107
+ } catch (_error) {
21108
+ e = _error;
21109
+ console.warn("restfulable.toString: Failed to stringify record: " + e.message + ". retrying...");
21110
+ for (name in serialized) {
21111
+ property = serialized[name];
21112
+ if (typeof property === 'object') {
21113
+ delete serialized[name];
21114
+ }
21115
+ }
21116
+ return JSON.stringify(serialized);
21117
+ }
25214
21118
  },
25215
21119
  json: function(methods) {
25216
- var attribute, definition, json, name, value, _i, _len, _ref;
21120
+ var definition, json, name, nested, value;
25217
21121
 
25218
21122
  if (methods == null) {
25219
21123
  methods = {};
@@ -25221,10 +21125,11 @@ restful = {
25221
21125
  json = {};
25222
21126
  definition = model[this.resource.toString()];
25223
21127
  for (name in this) {
25224
- if (!(type(value))) {
21128
+ if (observable.ignores.indexOf(name) !== -1) {
25225
21129
  continue;
25226
21130
  }
25227
- if (definition.belongs_to.indexOf(name) !== -1 && this.nested_attributes.indexOf(name) === -1) {
21131
+ nested = this.nested_attributes.indexOf(name) !== -1;
21132
+ if (!nested && (definition.belongs_to.indexOf(name) !== -1 || definition.has_one.indexOf(name) !== -1)) {
25228
21133
  continue;
25229
21134
  }
25230
21135
  value = this[name];
@@ -25235,22 +21140,20 @@ restful = {
25235
21140
  continue;
25236
21141
  }
25237
21142
  if (type(value) === 'object') {
25238
- if (value.toJSON != null) {
25239
- json[name] = value.toJSON(methods[name]);
25240
- } else {
25241
- _ref = this.nested_attributes;
25242
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
25243
- attribute = _ref[_i];
25244
- if (attribute === name) {
25245
- json["" + name + "_attributes"] = value.json(methods[name]);
25246
- }
21143
+ if (nested) {
21144
+ json["" + name + "_attributes"] = value.json(methods[name]);
21145
+ } else if ((value.toJSON != null) || (value.json != null)) {
21146
+ if (value.json != null) {
21147
+ json[name] = value.json(methods[name]);
21148
+ } else {
21149
+ json[name] = value.toJSON(methods[name]);
25247
21150
  }
25248
21151
  }
25249
21152
  } else {
25250
21153
  json[name] = value;
25251
21154
  }
25252
21155
  }
25253
- observable.unobserve(json);
21156
+ json = observable.unobserve(json);
25254
21157
  delete json.dirty;
25255
21158
  delete json.resource;
25256
21159
  delete json.route;
@@ -26220,37 +22123,3 @@ require.alias("indefinido-advisable/lib/advisable.js", "indemma/deps/advisable/l
26220
22123
  require.alias("indefinido-advisable/index.js", "advisable/index.js");
26221
22124
  require.alias("component-jquery/index.js", "indefinido-advisable/deps/jquery/index.js");
26222
22125
 
26223
- require.alias("chaijs-chai/index.js", "indemma/deps/chai/index.js");
26224
- require.alias("chaijs-chai/lib/chai.js", "indemma/deps/chai/lib/chai.js");
26225
- require.alias("chaijs-chai/lib/chai/assertion.js", "indemma/deps/chai/lib/chai/assertion.js");
26226
- require.alias("chaijs-chai/lib/chai/core/assertions.js", "indemma/deps/chai/lib/chai/core/assertions.js");
26227
- require.alias("chaijs-chai/lib/chai/interface/assert.js", "indemma/deps/chai/lib/chai/interface/assert.js");
26228
- require.alias("chaijs-chai/lib/chai/interface/expect.js", "indemma/deps/chai/lib/chai/interface/expect.js");
26229
- require.alias("chaijs-chai/lib/chai/interface/should.js", "indemma/deps/chai/lib/chai/interface/should.js");
26230
- require.alias("chaijs-chai/lib/chai/utils/addChainableMethod.js", "indemma/deps/chai/lib/chai/utils/addChainableMethod.js");
26231
- require.alias("chaijs-chai/lib/chai/utils/addMethod.js", "indemma/deps/chai/lib/chai/utils/addMethod.js");
26232
- require.alias("chaijs-chai/lib/chai/utils/addProperty.js", "indemma/deps/chai/lib/chai/utils/addProperty.js");
26233
- require.alias("chaijs-chai/lib/chai/utils/eql.js", "indemma/deps/chai/lib/chai/utils/eql.js");
26234
- require.alias("chaijs-chai/lib/chai/utils/flag.js", "indemma/deps/chai/lib/chai/utils/flag.js");
26235
- require.alias("chaijs-chai/lib/chai/utils/getActual.js", "indemma/deps/chai/lib/chai/utils/getActual.js");
26236
- require.alias("chaijs-chai/lib/chai/utils/getEnumerableProperties.js", "indemma/deps/chai/lib/chai/utils/getEnumerableProperties.js");
26237
- require.alias("chaijs-chai/lib/chai/utils/getMessage.js", "indemma/deps/chai/lib/chai/utils/getMessage.js");
26238
- require.alias("chaijs-chai/lib/chai/utils/getName.js", "indemma/deps/chai/lib/chai/utils/getName.js");
26239
- require.alias("chaijs-chai/lib/chai/utils/getPathValue.js", "indemma/deps/chai/lib/chai/utils/getPathValue.js");
26240
- require.alias("chaijs-chai/lib/chai/utils/getProperties.js", "indemma/deps/chai/lib/chai/utils/getProperties.js");
26241
- require.alias("chaijs-chai/lib/chai/utils/index.js", "indemma/deps/chai/lib/chai/utils/index.js");
26242
- require.alias("chaijs-chai/lib/chai/utils/inspect.js", "indemma/deps/chai/lib/chai/utils/inspect.js");
26243
- require.alias("chaijs-chai/lib/chai/utils/objDisplay.js", "indemma/deps/chai/lib/chai/utils/objDisplay.js");
26244
- require.alias("chaijs-chai/lib/chai/utils/overwriteMethod.js", "indemma/deps/chai/lib/chai/utils/overwriteMethod.js");
26245
- require.alias("chaijs-chai/lib/chai/utils/overwriteProperty.js", "indemma/deps/chai/lib/chai/utils/overwriteProperty.js");
26246
- require.alias("chaijs-chai/lib/chai/utils/test.js", "indemma/deps/chai/lib/chai/utils/test.js");
26247
- require.alias("chaijs-chai/lib/chai/utils/transferFlags.js", "indemma/deps/chai/lib/chai/utils/transferFlags.js");
26248
- require.alias("chaijs-chai/lib/chai/utils/type.js", "indemma/deps/chai/lib/chai/utils/type.js");
26249
- require.alias("chaijs-chai/index.js", "indemma/deps/chai/index.js");
26250
- require.alias("chaijs-chai/index.js", "chai/index.js");
26251
- require.alias("chaijs-assertion-error/index.js", "chaijs-chai/deps/assertion-error/index.js");
26252
- require.alias("chaijs-assertion-error/index.js", "chaijs-chai/deps/assertion-error/index.js");
26253
- require.alias("chaijs-assertion-error/index.js", "chaijs-assertion-error/index.js");
26254
-
26255
- require.alias("chaijs-chai/index.js", "chaijs-chai/index.js");
26256
-