teabag 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. data/README.md +6 -4
  2. data/app/assets/javascripts/teabag-jasmine.js +2 -2
  3. data/app/assets/javascripts/teabag-mocha.js +348 -21
  4. data/app/assets/javascripts/teabag-qunit.js +2 -2
  5. data/app/assets/javascripts/teabag/mocha.coffee +1 -1
  6. data/app/controllers/teabag/spec_controller.rb +1 -1
  7. data/lib/teabag/console.rb +15 -15
  8. data/lib/teabag/formatters/base_formatter.rb +1 -0
  9. data/lib/teabag/formatters/clean_formatter.rb +13 -0
  10. data/lib/teabag/server.rb +1 -0
  11. data/lib/teabag/suite.rb +22 -1
  12. data/lib/teabag/version.rb +1 -1
  13. data/spec/dummy/log/development.log +4342 -0
  14. data/spec/dummy/log/test.log +1760 -0
  15. data/spec/dummy/tmp/cache/assets/C35/A30/sprockets%2F29906bf540f7d2e081088494b2554989 +0 -0
  16. data/spec/dummy/tmp/cache/assets/C4E/9B0/sprockets%2Fa807397434c9262c3d62da3e91152184 +0 -0
  17. data/spec/dummy/tmp/cache/assets/C59/250/sprockets%2Fa80d3fe493d2476e58c4323996064512 +0 -0
  18. data/spec/dummy/tmp/cache/assets/C75/D50/sprockets%2F5302968a40e08d2c011aa38666d273f6 +0 -0
  19. data/spec/dummy/tmp/cache/assets/C78/F80/sprockets%2F9161622ddd251097a4ab816b8220984c +0 -0
  20. data/spec/dummy/tmp/cache/assets/C7A/EC0/sprockets%2F5c16e4214f5662e1b27932a57c43491b +0 -0
  21. data/spec/dummy/tmp/cache/assets/C89/700/sprockets%2F259935a7704fef0069303ea63fa89408 +0 -0
  22. data/spec/dummy/tmp/cache/assets/C8A/460/sprockets%2F77bffd9959420103906722b404ae8d59 +0 -0
  23. data/spec/dummy/tmp/cache/assets/C91/FA0/sprockets%2F2eb81283f5789ae91a69344552db3856 +0 -0
  24. data/spec/dummy/tmp/cache/assets/C9D/E90/sprockets%2F3045c9533f179d3e1c805d163ed002a0 +0 -0
  25. data/spec/dummy/tmp/cache/assets/CA6/DF0/sprockets%2F7da83747ce56e49393b6b8726587f846 +0 -0
  26. data/spec/dummy/tmp/cache/assets/CA9/C40/sprockets%2F932b7e2cd1e067289ab51190800814df +0 -0
  27. data/spec/dummy/tmp/cache/assets/CAA/0C0/sprockets%2F057b0ce384f16d9202ae84473436cc35 +0 -0
  28. data/spec/dummy/tmp/cache/assets/CAD/410/sprockets%2F651414e5c7e86f05c5108dc71626b25c +0 -0
  29. data/spec/dummy/tmp/cache/assets/CAF/0F0/sprockets%2F6000e67cf3f2377f860c24da7c819701 +0 -0
  30. data/spec/dummy/tmp/cache/assets/CB0/700/sprockets%2F006af6bf0f6b55777b03c4615c853881 +0 -0
  31. data/spec/dummy/tmp/cache/assets/CBB/FA0/sprockets%2F74922109263bdc965b2e9567eec6d154 +0 -0
  32. data/spec/dummy/tmp/cache/assets/CBD/AF0/sprockets%2Fd687ec33822256e9444e8cd04f1b4873 +0 -0
  33. data/spec/dummy/tmp/cache/assets/CBF/630/sprockets%2F707d2db81468088470d476abff35388d +0 -0
  34. data/spec/dummy/tmp/cache/assets/CC2/EC0/sprockets%2F76bf80cb571ca530357f78db78167866 +0 -0
  35. data/spec/dummy/tmp/cache/assets/CCE/C50/sprockets%2Fe12774c2fea852112414bb379a71f31a +0 -0
  36. data/spec/dummy/tmp/cache/assets/CD3/460/sprockets%2F7f3f6802b0b309ed142d0b671c9640c4 +0 -0
  37. data/spec/dummy/tmp/cache/assets/CD9/DD0/sprockets%2Fe5774759168a731da1c1149ecf0e1b03 +0 -0
  38. data/spec/dummy/tmp/cache/assets/CE0/090/sprockets%2F48d5d35ae87d0723318b8bc257fa2237 +0 -0
  39. data/spec/dummy/tmp/cache/assets/CE3/1F0/sprockets%2Fe69a515d3a9d14c669be8871012a7d07 +0 -0
  40. data/spec/dummy/tmp/cache/assets/CE6/270/sprockets%2F2c98152560d18470fec8cf4c6829b4d0 +0 -0
  41. data/spec/dummy/tmp/cache/assets/CE6/7C0/sprockets%2Fa03a2c86ce6724be8542295e1cf24798 +0 -0
  42. data/spec/dummy/tmp/cache/assets/CE7/A60/sprockets%2Ff58eee249aa167d23f8220087bb46684 +0 -0
  43. data/spec/dummy/tmp/cache/assets/CE9/9E0/sprockets%2F135480d497ed7e4884462dc0ef0b80d7 +0 -0
  44. data/spec/dummy/tmp/cache/assets/CEB/680/sprockets%2F67f0794ef8c0576d5c7da34f4437305a +0 -0
  45. data/spec/dummy/tmp/cache/assets/CEB/B40/sprockets%2F1150bf8d912aa100a132251eefaf6045 +0 -0
  46. data/spec/dummy/tmp/cache/assets/CEE/930/sprockets%2Fe196521e15fd8d33e3261d5538fe8f92 +0 -0
  47. data/spec/dummy/tmp/cache/assets/CF4/6F0/sprockets%2Fed96f92571224b862b84d7078b86ded3 +0 -0
  48. data/spec/dummy/tmp/cache/assets/CF8/780/sprockets%2F8845b81ff27cdb57c835836c9f91a265 +0 -0
  49. data/spec/dummy/tmp/cache/assets/CFA/D20/sprockets%2Fb26796b39b3c5d6ed70be7989637a493 +0 -0
  50. data/spec/dummy/tmp/cache/assets/CFB/210/sprockets%2F9104695bfbf9a9d4b94382e6e90487a9 +0 -0
  51. data/spec/dummy/tmp/cache/assets/CFC/380/sprockets%2Fa7443cbd671446a589867dd5f4a4f989 +0 -0
  52. data/spec/dummy/tmp/cache/assets/D00/110/sprockets%2F6a6353b7723a8b21708e0fbfe04bd422 +0 -0
  53. data/spec/dummy/tmp/cache/assets/D03/630/sprockets%2F5d8da32dba6a7be70426a1d554773701 +0 -0
  54. data/spec/dummy/tmp/cache/assets/D04/170/sprockets%2F76ab1dc02e6c7618852708a1e05a2df3 +0 -0
  55. data/spec/dummy/tmp/cache/assets/D04/480/sprockets%2F8bd8f10500b21d2f9d94e4cd1401c936 +0 -0
  56. data/spec/dummy/tmp/cache/assets/D05/8D0/sprockets%2F319f8f235f452343f1ebf03cb262d23d +0 -0
  57. data/spec/dummy/tmp/cache/assets/D09/BF0/sprockets%2F9e6bca5d26f50d9484385d51ba04312c +0 -0
  58. data/spec/dummy/tmp/cache/assets/D0E/570/sprockets%2F90fe371bf8091e88a712124d9cdae260 +0 -0
  59. data/spec/dummy/tmp/cache/assets/D15/4D0/sprockets%2Fdf269dd57c774b930679e00131ca9ae4 +0 -0
  60. data/spec/dummy/tmp/cache/assets/D15/750/sprockets%2F8effdd3e668a4036260a3e370f3b6657 +0 -0
  61. data/spec/dummy/tmp/cache/assets/D17/710/sprockets%2Ffa49fb6823d466e79a195e0cd71340c5 +0 -0
  62. data/spec/dummy/tmp/cache/assets/D1A/D30/sprockets%2F815a5177e9edba0c5c996182ef1b3675 +0 -0
  63. data/spec/dummy/tmp/cache/assets/D1D/560/sprockets%2F1ca784ee7ba1922465147e7f8963eae5 +0 -0
  64. data/spec/dummy/tmp/cache/assets/D1E/AA0/sprockets%2F5c8741a556bc955cd36e61c88582b6dc +0 -0
  65. data/spec/dummy/tmp/cache/assets/D31/9C0/sprockets%2Fbd102a4f5a4985c3519dd6ab0295a1c6 +0 -0
  66. data/spec/dummy/tmp/cache/assets/D35/7C0/sprockets%2Ff536a2606eaf7d542c0985104cb62baf +0 -0
  67. data/spec/dummy/tmp/cache/assets/D37/FF0/sprockets%2F96841ca4cfae32c515077f3f5fc303b2 +0 -0
  68. data/spec/dummy/tmp/cache/assets/D3C/840/sprockets%2Fc6202ec91d567a85bd3d46dc43ea9108 +0 -0
  69. data/spec/dummy/tmp/cache/assets/D44/E90/sprockets%2F05cfc0bf7c9938963d1d1c63248db80d +0 -0
  70. data/spec/dummy/tmp/cache/assets/D45/C30/sprockets%2Fcc744877558178a3adb77c441cadce70 +0 -0
  71. data/spec/dummy/tmp/cache/assets/D47/A90/sprockets%2Fe7ca382b607c595ea6505853f7fb63da +0 -0
  72. data/spec/dummy/tmp/cache/assets/D49/1F0/sprockets%2F773b56f87127c6605e7d1d3faf2b6af6 +0 -0
  73. data/spec/dummy/tmp/cache/assets/D49/A10/sprockets%2Fc4656bd995a6f297c26d19b13aadb963 +0 -0
  74. data/spec/dummy/tmp/cache/assets/D50/D70/sprockets%2Fe2a3e6c95b11e0801a4eebae3a026026 +0 -0
  75. data/spec/dummy/tmp/cache/assets/D51/400/sprockets%2Ff5e433d8a31e80985b75ce598de236be +0 -0
  76. data/spec/dummy/tmp/cache/assets/D54/D80/sprockets%2F631327e25ec20edc723046cdec3bb1c0 +0 -0
  77. data/spec/dummy/tmp/cache/assets/D5A/140/sprockets%2F01f728f33e9bd12104d3b0b1dc7df0a9 +0 -0
  78. data/spec/dummy/tmp/cache/assets/D5C/710/sprockets%2F9427d05cee2caa721241a25a9af1d08f +0 -0
  79. data/spec/dummy/tmp/cache/assets/D5C/CC0/sprockets%2Faa8bf6de211f2765b0a26f112b971f0c +0 -0
  80. data/spec/dummy/tmp/cache/assets/D5E/FA0/sprockets%2Fc81c371ae2d61a6aa1708262fba79e0d +0 -0
  81. data/spec/dummy/tmp/cache/assets/D61/1F0/sprockets%2F0c7a6176d2fc4db00bb9a74d36380fe1 +0 -0
  82. data/spec/dummy/tmp/cache/assets/D67/BC0/sprockets%2F35d2c2b45981ade5a2db2a9c7f37a615 +0 -0
  83. data/spec/dummy/tmp/cache/assets/D69/F90/sprockets%2F6a0795b7b38bd7e6142cd1b88211dade +0 -0
  84. data/spec/dummy/tmp/cache/assets/D6A/950/sprockets%2F429b1806cb7580ebf29f9a12c33cbea6 +0 -0
  85. data/spec/dummy/tmp/cache/assets/D6D/DA0/sprockets%2Fac936bf40b42227a2bf9d474ae9ec149 +0 -0
  86. data/spec/dummy/tmp/cache/assets/D77/B30/sprockets%2F946cf2f17c7eb41037f9ee08ad67ec40 +0 -0
  87. data/spec/dummy/tmp/cache/assets/D78/2F0/sprockets%2F3c61f8915b8f717b1de788e6ecad122c +0 -0
  88. data/spec/dummy/tmp/cache/assets/D7E/C10/sprockets%2F747c98c3cc7494a62dd882752adffb2b +0 -0
  89. data/spec/dummy/tmp/cache/assets/D8C/520/sprockets%2F221cd58a042baac534d27e4cfedc1188 +0 -0
  90. data/spec/dummy/tmp/cache/assets/D8D/370/sprockets%2Fc8ecf0a54ad40917d2607b0d5a6bbb27 +0 -0
  91. data/spec/dummy/tmp/cache/assets/D93/BD0/sprockets%2Ff5e1b60201e08e3ddf8d3de5211f3d5e +0 -0
  92. data/spec/dummy/tmp/cache/assets/DA0/330/sprockets%2Fcbbb4de706387d50f48a72ee6c9c1b80 +0 -0
  93. data/spec/dummy/tmp/cache/assets/DA5/0A0/sprockets%2F7a4b5928cec69ab65afff309a04d6b47 +0 -0
  94. data/spec/dummy/tmp/cache/assets/DAE/6C0/sprockets%2F77c7a8676aeefa73156c55dfcf51cc46 +0 -0
  95. data/spec/dummy/tmp/cache/assets/DB5/040/sprockets%2F9a9da5df88713663b9fbc945facca891 +0 -0
  96. data/spec/dummy/tmp/cache/assets/DC3/230/sprockets%2Fdf52e72eb73be91eccc60182191aed0b +0 -0
  97. data/spec/dummy/tmp/cache/assets/DC7/A10/sprockets%2F84a8af0fcbf401864e1ae5bf092cba94 +0 -0
  98. data/spec/dummy/tmp/cache/assets/DCD/EB0/sprockets%2F4f77f509126ecbced7ea2a5ab290c8d4 +0 -0
  99. data/spec/dummy/tmp/cache/assets/DDB/EF0/sprockets%2Fe790bb18b64df8aa0a9fe94642a9edd8 +0 -0
  100. data/spec/dummy/tmp/cache/assets/DDF/2A0/sprockets%2Fbdb1c7e9d59fd44828d498bee2e1da91 +0 -0
  101. data/spec/dummy/tmp/cache/assets/DE4/140/sprockets%2F139e4ab85d1aacb22c115fa136afdc8a +0 -0
  102. data/spec/dummy/tmp/cache/assets/DEB/110/sprockets%2F2dbdab0ce5babca645cdb5780004f875 +0 -0
  103. data/spec/dummy/tmp/cache/assets/DF6/0E0/sprockets%2F85b10db6e1afe643aba6d396abdd77f0 +0 -0
  104. data/spec/dummy/tmp/cache/assets/DF7/E10/sprockets%2F25e4253aba9a9adcefb72552fb1ff0c8 +0 -0
  105. data/spec/dummy/tmp/cache/assets/DFC/C20/sprockets%2Fd9178ad7e3b401c9fceafd64ea2b50d6 +0 -0
  106. data/spec/dummy/tmp/cache/assets/DFC/C30/sprockets%2Fb50a07cb30b0bd0eec8e98e5de79d65d +0 -0
  107. data/spec/dummy/tmp/cache/assets/E02/6E0/sprockets%2F63d6a5cdb8cefa64ef76b5c6e0fd3720 +0 -0
  108. data/spec/dummy/tmp/cache/assets/E08/BB0/sprockets%2Fefac99af1af28543aef6fb607faa4973 +0 -0
  109. data/spec/dummy/tmp/cache/assets/E08/F20/sprockets%2F4fc5cdcd6974efe7adfe809b30bd6513 +0 -0
  110. data/spec/dummy/tmp/cache/assets/E16/D30/sprockets%2Fd69469e6e7439baacd8df989c0fdacc2 +0 -0
  111. data/spec/dummy/tmp/cache/assets/E17/EF0/sprockets%2Fa291ad64a26afd055dfadabbdf03f154 +0 -0
  112. data/spec/dummy/tmp/cache/assets/E2F/790/sprockets%2F7fac280deaa7ef20a77d5c9b5b9cfc34 +0 -0
  113. data/spec/dummy/tmp/cache/assets/E36/A40/sprockets%2Ff3477eebd69a4f1b8fbdd3f9ef2ba242 +0 -0
  114. data/spec/dummy/tmp/cache/assets/E41/250/sprockets%2F97cf8fe3d7ffaff076f655aefb36da03 +0 -0
  115. data/spec/dummy/tmp/cache/assets/E64/1E0/sprockets%2F81ab4c863fbbdec8dd66afc97ebf034d +0 -0
  116. data/spec/dummy/tmp/cache/assets/E6E/260/sprockets%2Fd9f8ab8b91ef582cc6c99a3ba0dedfe6 +0 -0
  117. data/spec/dummy/tmp/cache/assets/F79/360/sprockets%2F0ce035fefee5ebdabc8efabfbdbd6ee4 +0 -0
  118. data/spec/teabag/console_spec.rb +36 -28
  119. data/spec/teabag/server_spec.rb +4 -2
  120. data/spec/teabag/suite_spec.rb +40 -1
  121. data/vendor/assets/javascripts/{mocha-1.7.4.MIT.LICENSE → mocha-1.8.1.MIT.LICENSE} +0 -0
  122. data/vendor/assets/javascripts/{mocha-1.7.4.js → mocha-1.8.1.js} +346 -19
  123. data/vendor/assets/javascripts/support/chai.MIT.LICENSE +22 -0
  124. data/vendor/assets/javascripts/support/chai.js +3809 -0
  125. data/vendor/assets/javascripts/support/jasmine-jquery.js +13 -10
  126. metadata +17 -6
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2011-2012 Jake Luer jake@alogicalparadox.com
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3809 @@
1
+ !function (name, context, definition) {
2
+ if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') {
3
+ module.exports = definition();
4
+ } else if (typeof define === 'function' && typeof define.amd === 'object') {
5
+ define(function () {
6
+ return definition();
7
+ });
8
+ } else {
9
+ context[name] = definition();
10
+ }
11
+ }('chai', this, function () {
12
+
13
+ function require(p) {
14
+ var path = require.resolve(p)
15
+ , mod = require.modules[path];
16
+ if (!mod) throw new Error('failed to require "' + p + '"');
17
+ if (!mod.exports) {
18
+ mod.exports = {};
19
+ mod.call(mod.exports, mod, mod.exports, require.relative(path));
20
+ }
21
+ return mod.exports;
22
+ }
23
+
24
+ require.modules = {};
25
+
26
+ require.resolve = function (path) {
27
+ var orig = path
28
+ , reg = path + '.js'
29
+ , index = path + '/index.js';
30
+ return require.modules[reg] && reg
31
+ || require.modules[index] && index
32
+ || orig;
33
+ };
34
+
35
+ require.register = function (path, fn) {
36
+ require.modules[path] = fn;
37
+ };
38
+
39
+ require.relative = function (parent) {
40
+ return function(p){
41
+ if ('.' != p.charAt(0)) return require(p);
42
+
43
+ var path = parent.split('/')
44
+ , segs = p.split('/');
45
+ path.pop();
46
+
47
+ for (var i = 0; i < segs.length; i++) {
48
+ var seg = segs[i];
49
+ if ('..' == seg) path.pop();
50
+ else if ('.' != seg) path.push(seg);
51
+ }
52
+
53
+ return require(path.join('/'));
54
+ };
55
+ };
56
+
57
+ require.alias = function (from, to) {
58
+ var fn = require.modules[from];
59
+ require.modules[to] = fn;
60
+ };
61
+
62
+
63
+ require.register("chai.js", function(module, exports, require){
64
+ /*!
65
+ * chai
66
+ * Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>
67
+ * MIT Licensed
68
+ */
69
+
70
+ var used = []
71
+ , exports = module.exports = {};
72
+
73
+ /*!
74
+ * Chai version
75
+ */
76
+
77
+ exports.version = '1.4.2';
78
+
79
+ /*!
80
+ * Primary `Assertion` prototype
81
+ */
82
+
83
+ exports.Assertion = require('./chai/assertion');
84
+
85
+ /*!
86
+ * Assertion Error
87
+ */
88
+
89
+ exports.AssertionError = require('./chai/error');
90
+
91
+ /*!
92
+ * Utils for plugins (not exported)
93
+ */
94
+
95
+ var util = require('./chai/utils');
96
+
97
+ /**
98
+ * # .use(function)
99
+ *
100
+ * Provides a way to extend the internals of Chai
101
+ *
102
+ * @param {Function}
103
+ * @returns {this} for chaining
104
+ * @api public
105
+ */
106
+
107
+ exports.use = function (fn) {
108
+ if (!~used.indexOf(fn)) {
109
+ fn(this, util);
110
+ used.push(fn);
111
+ }
112
+
113
+ return this;
114
+ };
115
+
116
+ /*!
117
+ * Core Assertions
118
+ */
119
+
120
+ var core = require('./chai/core/assertions');
121
+ exports.use(core);
122
+
123
+ /*!
124
+ * Expect interface
125
+ */
126
+
127
+ var expect = require('./chai/interface/expect');
128
+ exports.use(expect);
129
+
130
+ /*!
131
+ * Should interface
132
+ */
133
+
134
+ var should = require('./chai/interface/should');
135
+ exports.use(should);
136
+
137
+ /*!
138
+ * Assert interface
139
+ */
140
+
141
+ var assert = require('./chai/interface/assert');
142
+ exports.use(assert);
143
+
144
+ }); // module: chai.js
145
+
146
+ require.register("chai/assertion.js", function(module, exports, require){
147
+ /*!
148
+ * chai
149
+ * http://chaijs.com
150
+ * Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>
151
+ * MIT Licensed
152
+ */
153
+
154
+ /*!
155
+ * Module dependencies.
156
+ */
157
+
158
+ var AssertionError = require('./error')
159
+ , util = require('./utils')
160
+ , flag = util.flag;
161
+
162
+ /*!
163
+ * Module export.
164
+ */
165
+
166
+ module.exports = Assertion;
167
+
168
+
169
+ /*!
170
+ * Assertion Constructor
171
+ *
172
+ * Creates object for chaining.
173
+ *
174
+ * @api private
175
+ */
176
+
177
+ function Assertion (obj, msg, stack) {
178
+ flag(this, 'ssfi', stack || arguments.callee);
179
+ flag(this, 'object', obj);
180
+ flag(this, 'message', msg);
181
+ }
182
+
183
+ /*!
184
+ * ### Assertion.includeStack
185
+ *
186
+ * User configurable property, influences whether stack trace
187
+ * is included in Assertion error message. Default of false
188
+ * suppresses stack trace in the error message
189
+ *
190
+ * Assertion.includeStack = true; // enable stack on error
191
+ *
192
+ * @api public
193
+ */
194
+
195
+ Assertion.includeStack = false;
196
+
197
+ Assertion.addProperty = function (name, fn) {
198
+ util.addProperty(this.prototype, name, fn);
199
+ };
200
+
201
+ Assertion.addMethod = function (name, fn) {
202
+ util.addMethod(this.prototype, name, fn);
203
+ };
204
+
205
+ Assertion.addChainableMethod = function (name, fn, chainingBehavior) {
206
+ util.addChainableMethod(this.prototype, name, fn, chainingBehavior);
207
+ };
208
+
209
+ Assertion.overwriteProperty = function (name, fn) {
210
+ util.overwriteProperty(this.prototype, name, fn);
211
+ };
212
+
213
+ Assertion.overwriteMethod = function (name, fn) {
214
+ util.overwriteMethod(this.prototype, name, fn);
215
+ };
216
+
217
+ /*!
218
+ * ### .assert(expression, message, negateMessage, expected, actual)
219
+ *
220
+ * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
221
+ *
222
+ * @name assert
223
+ * @param {Philosophical} expression to be tested
224
+ * @param {String} message to display if fails
225
+ * @param {String} negatedMessage to display if negated expression fails
226
+ * @param {Mixed} expected value (remember to check for negation)
227
+ * @param {Mixed} actual (optional) will default to `this.obj`
228
+ * @api private
229
+ */
230
+
231
+ Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) {
232
+ var ok = util.test(this, arguments);
233
+ if (true !== showDiff) showDiff = false;
234
+
235
+ if (!ok) {
236
+ var msg = util.getMessage(this, arguments)
237
+ , actual = util.getActual(this, arguments);
238
+ throw new AssertionError({
239
+ message: msg
240
+ , actual: actual
241
+ , expected: expected
242
+ , stackStartFunction: (Assertion.includeStack) ? this.assert : flag(this, 'ssfi')
243
+ , showDiff: showDiff
244
+ });
245
+ }
246
+ };
247
+
248
+ /*!
249
+ * ### ._obj
250
+ *
251
+ * Quick reference to stored `actual` value for plugin developers.
252
+ *
253
+ * @api private
254
+ */
255
+
256
+ Object.defineProperty(Assertion.prototype, '_obj',
257
+ { get: function () {
258
+ return flag(this, 'object');
259
+ }
260
+ , set: function (val) {
261
+ flag(this, 'object', val);
262
+ }
263
+ });
264
+
265
+ }); // module: chai/assertion.js
266
+
267
+ require.register("chai/core/assertions.js", function(module, exports, require){
268
+ /*!
269
+ * chai
270
+ * http://chaijs.com
271
+ * Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>
272
+ * MIT Licensed
273
+ */
274
+
275
+ module.exports = function (chai, _) {
276
+ var Assertion = chai.Assertion
277
+ , toString = Object.prototype.toString
278
+ , flag = _.flag;
279
+
280
+ /**
281
+ * ### Language Chains
282
+ *
283
+ * The following are provide as chainable getters to
284
+ * improve the readability of your assertions. They
285
+ * do not provide an testing capability unless they
286
+ * have been overwritten by a plugin.
287
+ *
288
+ * **Chains**
289
+ *
290
+ * - to
291
+ * - be
292
+ * - been
293
+ * - is
294
+ * - that
295
+ * - and
296
+ * - have
297
+ * - with
298
+ * - at
299
+ * - of
300
+ *
301
+ * @name language chains
302
+ * @api public
303
+ */
304
+
305
+ [ 'to', 'be', 'been'
306
+ , 'is', 'and', 'have'
307
+ , 'with', 'that', 'at'
308
+ , 'of' ].forEach(function (chain) {
309
+ Assertion.addProperty(chain, function () {
310
+ return this;
311
+ });
312
+ });
313
+
314
+ /**
315
+ * ### .not
316
+ *
317
+ * Negates any of assertions following in the chain.
318
+ *
319
+ * expect(foo).to.not.equal('bar');
320
+ * expect(goodFn).to.not.throw(Error);
321
+ * expect({ foo: 'baz' }).to.have.property('foo')
322
+ * .and.not.equal('bar');
323
+ *
324
+ * @name not
325
+ * @api public
326
+ */
327
+
328
+ Assertion.addProperty('not', function () {
329
+ flag(this, 'negate', true);
330
+ });
331
+
332
+ /**
333
+ * ### .deep
334
+ *
335
+ * Sets the `deep` flag, later used by the `equal` and
336
+ * `property` assertions.
337
+ *
338
+ * expect(foo).to.deep.equal({ bar: 'baz' });
339
+ * expect({ foo: { bar: { baz: 'quux' } } })
340
+ * .to.have.deep.property('foo.bar.baz', 'quux');
341
+ *
342
+ * @name deep
343
+ * @api public
344
+ */
345
+
346
+ Assertion.addProperty('deep', function () {
347
+ flag(this, 'deep', true);
348
+ });
349
+
350
+ /**
351
+ * ### .a(type)
352
+ *
353
+ * The `a` and `an` assertions are aliases that can be
354
+ * used either as language chains or to assert a value's
355
+ * type (as revealed by `Object.prototype.toString`).
356
+ *
357
+ * // typeof
358
+ * expect('test').to.be.a('string');
359
+ * expect({ foo: 'bar' }).to.be.an('object');
360
+ * expect(null).to.be.a('null');
361
+ * expect(undefined).to.be.an('undefined');
362
+ *
363
+ * // language chain
364
+ * expect(foo).to.be.an.instanceof(Foo);
365
+ *
366
+ * @name a
367
+ * @alias an
368
+ * @param {String} type
369
+ * @param {String} message _optional_
370
+ * @api public
371
+ */
372
+
373
+ function an(type, msg) {
374
+ if (msg) flag(this, 'message', msg);
375
+ var obj = flag(this, 'object')
376
+ , klassStart = type.charAt(0).toUpperCase()
377
+ , klass = klassStart + type.slice(1)
378
+ , article = ~[ 'A', 'E', 'I', 'O', 'U' ].indexOf(klassStart) ? 'an ' : 'a ';
379
+
380
+ this.assert(
381
+ '[object ' + klass + ']' === toString.call(obj)
382
+ , 'expected #{this} to be ' + article + type
383
+ , 'expected #{this} not to be ' + article + type
384
+ );
385
+ }
386
+
387
+ Assertion.addChainableMethod('an', an);
388
+ Assertion.addChainableMethod('a', an);
389
+
390
+ /**
391
+ * ### .include(value)
392
+ *
393
+ * The `include` and `contain` assertions can be used as either property
394
+ * based language chains or as methods to assert the inclusion of an object
395
+ * in an array or a substring in a string. When used as language chains,
396
+ * they toggle the `contain` flag for the `keys` assertion.
397
+ *
398
+ * expect([1,2,3]).to.include(2);
399
+ * expect('foobar').to.contain('foo');
400
+ * expect({ foo: 'bar', hello: 'universe' }).to.include.keys('foo');
401
+ *
402
+ * @name include
403
+ * @alias contain
404
+ * @param {Object|String|Number} obj
405
+ * @param {String} message _optional_
406
+ * @api public
407
+ */
408
+
409
+ function includeChainingBehavior () {
410
+ flag(this, 'contains', true);
411
+ }
412
+
413
+ function include (val, msg) {
414
+ if (msg) flag(this, 'message', msg);
415
+ var obj = flag(this, 'object')
416
+ this.assert(
417
+ ~obj.indexOf(val)
418
+ , 'expected #{this} to include ' + _.inspect(val)
419
+ , 'expected #{this} to not include ' + _.inspect(val));
420
+ }
421
+
422
+ Assertion.addChainableMethod('include', include, includeChainingBehavior);
423
+ Assertion.addChainableMethod('contain', include, includeChainingBehavior);
424
+
425
+ /**
426
+ * ### .ok
427
+ *
428
+ * Asserts that the target is truthy.
429
+ *
430
+ * expect('everthing').to.be.ok;
431
+ * expect(1).to.be.ok;
432
+ * expect(false).to.not.be.ok;
433
+ * expect(undefined).to.not.be.ok;
434
+ * expect(null).to.not.be.ok;
435
+ *
436
+ * @name ok
437
+ * @api public
438
+ */
439
+
440
+ Assertion.addProperty('ok', function () {
441
+ this.assert(
442
+ flag(this, 'object')
443
+ , 'expected #{this} to be truthy'
444
+ , 'expected #{this} to be falsy');
445
+ });
446
+
447
+ /**
448
+ * ### .true
449
+ *
450
+ * Asserts that the target is `true`.
451
+ *
452
+ * expect(true).to.be.true;
453
+ * expect(1).to.not.be.true;
454
+ *
455
+ * @name true
456
+ * @api public
457
+ */
458
+
459
+ Assertion.addProperty('true', function () {
460
+ this.assert(
461
+ true === flag(this, 'object')
462
+ , 'expected #{this} to be true'
463
+ , 'expected #{this} to be false'
464
+ , this.negate ? false : true
465
+ );
466
+ });
467
+
468
+ /**
469
+ * ### .false
470
+ *
471
+ * Asserts that the target is `false`.
472
+ *
473
+ * expect(false).to.be.false;
474
+ * expect(0).to.not.be.false;
475
+ *
476
+ * @name false
477
+ * @api public
478
+ */
479
+
480
+ Assertion.addProperty('false', function () {
481
+ this.assert(
482
+ false === flag(this, 'object')
483
+ , 'expected #{this} to be false'
484
+ , 'expected #{this} to be true'
485
+ , this.negate ? true : false
486
+ );
487
+ });
488
+
489
+ /**
490
+ * ### .null
491
+ *
492
+ * Asserts that the target is `null`.
493
+ *
494
+ * expect(null).to.be.null;
495
+ * expect(undefined).not.to.be.null;
496
+ *
497
+ * @name null
498
+ * @api public
499
+ */
500
+
501
+ Assertion.addProperty('null', function () {
502
+ this.assert(
503
+ null === flag(this, 'object')
504
+ , 'expected #{this} to be null'
505
+ , 'expected #{this} not to be null'
506
+ );
507
+ });
508
+
509
+ /**
510
+ * ### .undefined
511
+ *
512
+ * Asserts that the target is `undefined`.
513
+ *
514
+ * expect(undefined).to.be.undefined;
515
+ * expect(null).to.not.be.undefined;
516
+ *
517
+ * @name undefined
518
+ * @api public
519
+ */
520
+
521
+ Assertion.addProperty('undefined', function () {
522
+ this.assert(
523
+ undefined === flag(this, 'object')
524
+ , 'expected #{this} to be undefined'
525
+ , 'expected #{this} not to be undefined'
526
+ );
527
+ });
528
+
529
+ /**
530
+ * ### .exist
531
+ *
532
+ * Asserts that the target is neither `null` nor `undefined`.
533
+ *
534
+ * var foo = 'hi'
535
+ * , bar = null
536
+ * , baz;
537
+ *
538
+ * expect(foo).to.exist;
539
+ * expect(bar).to.not.exist;
540
+ * expect(baz).to.not.exist;
541
+ *
542
+ * @name exist
543
+ * @api public
544
+ */
545
+
546
+ Assertion.addProperty('exist', function () {
547
+ this.assert(
548
+ null != flag(this, 'object')
549
+ , 'expected #{this} to exist'
550
+ , 'expected #{this} to not exist'
551
+ );
552
+ });
553
+
554
+
555
+ /**
556
+ * ### .empty
557
+ *
558
+ * Asserts that the target's length is `0`. For arrays, it checks
559
+ * the `length` property. For objects, it gets the count of
560
+ * enumerable keys.
561
+ *
562
+ * expect([]).to.be.empty;
563
+ * expect('').to.be.empty;
564
+ * expect({}).to.be.empty;
565
+ *
566
+ * @name empty
567
+ * @api public
568
+ */
569
+
570
+ Assertion.addProperty('empty', function () {
571
+ var obj = flag(this, 'object')
572
+ , expected = obj;
573
+
574
+ if (Array.isArray(obj) || 'string' === typeof object) {
575
+ expected = obj.length;
576
+ } else if (typeof obj === 'object') {
577
+ expected = Object.keys(obj).length;
578
+ }
579
+
580
+ this.assert(
581
+ !expected
582
+ , 'expected #{this} to be empty'
583
+ , 'expected #{this} not to be empty'
584
+ );
585
+ });
586
+
587
+ /**
588
+ * ### .arguments
589
+ *
590
+ * Asserts that the target is an arguments object.
591
+ *
592
+ * function test () {
593
+ * expect(arguments).to.be.arguments;
594
+ * }
595
+ *
596
+ * @name arguments
597
+ * @alias Arguments
598
+ * @api public
599
+ */
600
+
601
+ function checkArguments () {
602
+ var obj = flag(this, 'object')
603
+ , type = Object.prototype.toString.call(obj);
604
+ this.assert(
605
+ '[object Arguments]' === type
606
+ , 'expected #{this} to be arguments but got ' + type
607
+ , 'expected #{this} to not be arguments'
608
+ );
609
+ }
610
+
611
+ Assertion.addProperty('arguments', checkArguments);
612
+ Assertion.addProperty('Arguments', checkArguments);
613
+
614
+ /**
615
+ * ### .equal(value)
616
+ *
617
+ * Asserts that the target is strictly equal (`===`) to `value`.
618
+ * Alternately, if the `deep` flag is set, asserts that
619
+ * the target is deeply equal to `value`.
620
+ *
621
+ * expect('hello').to.equal('hello');
622
+ * expect(42).to.equal(42);
623
+ * expect(1).to.not.equal(true);
624
+ * expect({ foo: 'bar' }).to.not.equal({ foo: 'bar' });
625
+ * expect({ foo: 'bar' }).to.deep.equal({ foo: 'bar' });
626
+ *
627
+ * @name equal
628
+ * @alias equals
629
+ * @alias eq
630
+ * @alias deep.equal
631
+ * @param {Mixed} value
632
+ * @param {String} message _optional_
633
+ * @api public
634
+ */
635
+
636
+ function assertEqual (val, msg) {
637
+ if (msg) flag(this, 'message', msg);
638
+ var obj = flag(this, 'object');
639
+ if (flag(this, 'deep')) {
640
+ return this.eql(val);
641
+ } else {
642
+ this.assert(
643
+ val === obj
644
+ , 'expected #{this} to equal #{exp}'
645
+ , 'expected #{this} to not equal #{exp}'
646
+ , val
647
+ , this._obj
648
+ , true
649
+ );
650
+ }
651
+ }
652
+
653
+ Assertion.addMethod('equal', assertEqual);
654
+ Assertion.addMethod('equals', assertEqual);
655
+ Assertion.addMethod('eq', assertEqual);
656
+
657
+ /**
658
+ * ### .eql(value)
659
+ *
660
+ * Asserts that the target is deeply equal to `value`.
661
+ *
662
+ * expect({ foo: 'bar' }).to.eql({ foo: 'bar' });
663
+ * expect([ 1, 2, 3 ]).to.eql([ 1, 2, 3 ]);
664
+ *
665
+ * @name eql
666
+ * @param {Mixed} value
667
+ * @param {String} message _optional_
668
+ * @api public
669
+ */
670
+
671
+ Assertion.addMethod('eql', function (obj, msg) {
672
+ if (msg) flag(this, 'message', msg);
673
+ this.assert(
674
+ _.eql(obj, flag(this, 'object'))
675
+ , 'expected #{this} to deeply equal #{exp}'
676
+ , 'expected #{this} to not deeply equal #{exp}'
677
+ , obj
678
+ , this._obj
679
+ , true
680
+ );
681
+ });
682
+
683
+ /**
684
+ * ### .above(value)
685
+ *
686
+ * Asserts that the target is greater than `value`.
687
+ *
688
+ * expect(10).to.be.above(5);
689
+ *
690
+ * Can also be used in conjunction with `length` to
691
+ * assert a minimum length. The benefit being a
692
+ * more informative error message than if the length
693
+ * was supplied directly.
694
+ *
695
+ * expect('foo').to.have.length.above(2);
696
+ * expect([ 1, 2, 3 ]).to.have.length.above(2);
697
+ *
698
+ * @name above
699
+ * @alias gt
700
+ * @alias greaterThan
701
+ * @param {Number} value
702
+ * @param {String} message _optional_
703
+ * @api public
704
+ */
705
+
706
+ function assertAbove (n, msg) {
707
+ if (msg) flag(this, 'message', msg);
708
+ var obj = flag(this, 'object');
709
+ if (flag(this, 'doLength')) {
710
+ new Assertion(obj, msg).to.have.property('length');
711
+ var len = obj.length;
712
+ this.assert(
713
+ len > n
714
+ , 'expected #{this} to have a length above #{exp} but got #{act}'
715
+ , 'expected #{this} to not have a length above #{exp}'
716
+ , n
717
+ , len
718
+ );
719
+ } else {
720
+ this.assert(
721
+ obj > n
722
+ , 'expected #{this} to be above ' + n
723
+ , 'expected #{this} to be at most ' + n
724
+ );
725
+ }
726
+ }
727
+
728
+ Assertion.addMethod('above', assertAbove);
729
+ Assertion.addMethod('gt', assertAbove);
730
+ Assertion.addMethod('greaterThan', assertAbove);
731
+
732
+ /**
733
+ * ### .least(value)
734
+ *
735
+ * Asserts that the target is greater than or equal to `value`.
736
+ *
737
+ * expect(10).to.be.at.least(10);
738
+ *
739
+ * Can also be used in conjunction with `length` to
740
+ * assert a minimum length. The benefit being a
741
+ * more informative error message than if the length
742
+ * was supplied directly.
743
+ *
744
+ * expect('foo').to.have.length.of.at.least(2);
745
+ * expect([ 1, 2, 3 ]).to.have.length.of.at.least(3);
746
+ *
747
+ * @name least
748
+ * @alias gte
749
+ * @param {Number} value
750
+ * @param {String} message _optional_
751
+ * @api public
752
+ */
753
+
754
+ function assertLeast (n, msg) {
755
+ if (msg) flag(this, 'message', msg);
756
+ var obj = flag(this, 'object');
757
+ if (flag(this, 'doLength')) {
758
+ new Assertion(obj, msg).to.have.property('length');
759
+ var len = obj.length;
760
+ this.assert(
761
+ len >= n
762
+ , 'expected #{this} to have a length at least #{exp} but got #{act}'
763
+ , 'expected #{this} to not have a length below #{exp}'
764
+ , n
765
+ , len
766
+ );
767
+ } else {
768
+ this.assert(
769
+ obj >= n
770
+ , 'expected #{this} to be at least ' + n
771
+ , 'expected #{this} to be below ' + n
772
+ );
773
+ }
774
+ }
775
+
776
+ Assertion.addMethod('least', assertLeast);
777
+ Assertion.addMethod('gte', assertLeast);
778
+
779
+ /**
780
+ * ### .below(value)
781
+ *
782
+ * Asserts that the target is less than `value`.
783
+ *
784
+ * expect(5).to.be.below(10);
785
+ *
786
+ * Can also be used in conjunction with `length` to
787
+ * assert a maximum length. The benefit being a
788
+ * more informative error message than if the length
789
+ * was supplied directly.
790
+ *
791
+ * expect('foo').to.have.length.below(4);
792
+ * expect([ 1, 2, 3 ]).to.have.length.below(4);
793
+ *
794
+ * @name below
795
+ * @alias lt
796
+ * @alias lessThan
797
+ * @param {Number} value
798
+ * @param {String} message _optional_
799
+ * @api public
800
+ */
801
+
802
+ function assertBelow (n, msg) {
803
+ if (msg) flag(this, 'message', msg);
804
+ var obj = flag(this, 'object');
805
+ if (flag(this, 'doLength')) {
806
+ new Assertion(obj, msg).to.have.property('length');
807
+ var len = obj.length;
808
+ this.assert(
809
+ len < n
810
+ , 'expected #{this} to have a length below #{exp} but got #{act}'
811
+ , 'expected #{this} to not have a length below #{exp}'
812
+ , n
813
+ , len
814
+ );
815
+ } else {
816
+ this.assert(
817
+ obj < n
818
+ , 'expected #{this} to be below ' + n
819
+ , 'expected #{this} to be at least ' + n
820
+ );
821
+ }
822
+ }
823
+
824
+ Assertion.addMethod('below', assertBelow);
825
+ Assertion.addMethod('lt', assertBelow);
826
+ Assertion.addMethod('lessThan', assertBelow);
827
+
828
+ /**
829
+ * ### .most(value)
830
+ *
831
+ * Asserts that the target is less than or equal to `value`.
832
+ *
833
+ * expect(5).to.be.at.most(5);
834
+ *
835
+ * Can also be used in conjunction with `length` to
836
+ * assert a maximum length. The benefit being a
837
+ * more informative error message than if the length
838
+ * was supplied directly.
839
+ *
840
+ * expect('foo').to.have.length.of.at.most(4);
841
+ * expect([ 1, 2, 3 ]).to.have.length.of.at.most(3);
842
+ *
843
+ * @name most
844
+ * @alias lte
845
+ * @param {Number} value
846
+ * @param {String} message _optional_
847
+ * @api public
848
+ */
849
+
850
+ function assertMost (n, msg) {
851
+ if (msg) flag(this, 'message', msg);
852
+ var obj = flag(this, 'object');
853
+ if (flag(this, 'doLength')) {
854
+ new Assertion(obj, msg).to.have.property('length');
855
+ var len = obj.length;
856
+ this.assert(
857
+ len <= n
858
+ , 'expected #{this} to have a length at most #{exp} but got #{act}'
859
+ , 'expected #{this} to not have a length above #{exp}'
860
+ , n
861
+ , len
862
+ );
863
+ } else {
864
+ this.assert(
865
+ obj <= n
866
+ , 'expected #{this} to be at most ' + n
867
+ , 'expected #{this} to be above ' + n
868
+ );
869
+ }
870
+ }
871
+
872
+ Assertion.addMethod('most', assertMost);
873
+ Assertion.addMethod('lte', assertMost);
874
+
875
+ /**
876
+ * ### .within(start, finish)
877
+ *
878
+ * Asserts that the target is within a range.
879
+ *
880
+ * expect(7).to.be.within(5,10);
881
+ *
882
+ * Can also be used in conjunction with `length` to
883
+ * assert a length range. The benefit being a
884
+ * more informative error message than if the length
885
+ * was supplied directly.
886
+ *
887
+ * expect('foo').to.have.length.within(2,4);
888
+ * expect([ 1, 2, 3 ]).to.have.length.within(2,4);
889
+ *
890
+ * @name within
891
+ * @param {Number} start lowerbound inclusive
892
+ * @param {Number} finish upperbound inclusive
893
+ * @param {String} message _optional_
894
+ * @api public
895
+ */
896
+
897
+ Assertion.addMethod('within', function (start, finish, msg) {
898
+ if (msg) flag(this, 'message', msg);
899
+ var obj = flag(this, 'object')
900
+ , range = start + '..' + finish;
901
+ if (flag(this, 'doLength')) {
902
+ new Assertion(obj, msg).to.have.property('length');
903
+ var len = obj.length;
904
+ this.assert(
905
+ len >= start && len <= finish
906
+ , 'expected #{this} to have a length within ' + range
907
+ , 'expected #{this} to not have a length within ' + range
908
+ );
909
+ } else {
910
+ this.assert(
911
+ obj >= start && obj <= finish
912
+ , 'expected #{this} to be within ' + range
913
+ , 'expected #{this} to not be within ' + range
914
+ );
915
+ }
916
+ });
917
+
918
+ /**
919
+ * ### .instanceof(constructor)
920
+ *
921
+ * Asserts that the target is an instance of `constructor`.
922
+ *
923
+ * var Tea = function (name) { this.name = name; }
924
+ * , Chai = new Tea('chai');
925
+ *
926
+ * expect(Chai).to.be.an.instanceof(Tea);
927
+ * expect([ 1, 2, 3 ]).to.be.instanceof(Array);
928
+ *
929
+ * @name instanceof
930
+ * @param {Constructor} constructor
931
+ * @param {String} message _optional_
932
+ * @alias instanceOf
933
+ * @api public
934
+ */
935
+
936
+ function assertInstanceOf (constructor, msg) {
937
+ if (msg) flag(this, 'message', msg);
938
+ var name = _.getName(constructor);
939
+ this.assert(
940
+ flag(this, 'object') instanceof constructor
941
+ , 'expected #{this} to be an instance of ' + name
942
+ , 'expected #{this} to not be an instance of ' + name
943
+ );
944
+ };
945
+
946
+ Assertion.addMethod('instanceof', assertInstanceOf);
947
+ Assertion.addMethod('instanceOf', assertInstanceOf);
948
+
949
+ /**
950
+ * ### .property(name, [value])
951
+ *
952
+ * Asserts that the target has a property `name`, optionally asserting that
953
+ * the value of that property is strictly equal to `value`.
954
+ * If the `deep` flag is set, you can use dot- and bracket-notation for deep
955
+ * references into objects and arrays.
956
+ *
957
+ * // simple referencing
958
+ * var obj = { foo: 'bar' };
959
+ * expect(obj).to.have.property('foo');
960
+ * expect(obj).to.have.property('foo', 'bar');
961
+ *
962
+ * // deep referencing
963
+ * var deepObj = {
964
+ * green: { tea: 'matcha' }
965
+ * , teas: [ 'chai', 'matcha', { tea: 'konacha' } ]
966
+ * };
967
+
968
+ * expect(deepObj).to.have.deep.property('green.tea', 'matcha');
969
+ * expect(deepObj).to.have.deep.property('teas[1]', 'matcha');
970
+ * expect(deepObj).to.have.deep.property('teas[2].tea', 'konacha');
971
+ *
972
+ * You can also use an array as the starting point of a `deep.property`
973
+ * assertion, or traverse nested arrays.
974
+ *
975
+ * var arr = [
976
+ * [ 'chai', 'matcha', 'konacha' ]
977
+ * , [ { tea: 'chai' }
978
+ * , { tea: 'matcha' }
979
+ * , { tea: 'konacha' } ]
980
+ * ];
981
+ *
982
+ * expect(arr).to.have.deep.property('[0][1]', 'matcha');
983
+ * expect(arr).to.have.deep.property('[1][2].tea', 'konacha');
984
+ *
985
+ * Furthermore, `property` changes the subject of the assertion
986
+ * to be the value of that property from the original object. This
987
+ * permits for further chainable assertions on that property.
988
+ *
989
+ * expect(obj).to.have.property('foo')
990
+ * .that.is.a('string');
991
+ * expect(deepObj).to.have.property('green')
992
+ * .that.is.an('object')
993
+ * .that.deep.equals({ tea: 'matcha' });
994
+ * expect(deepObj).to.have.property('teas')
995
+ * .that.is.an('array')
996
+ * .with.deep.property('[2]')
997
+ * .that.deep.equals({ tea: 'konacha' });
998
+ *
999
+ * @name property
1000
+ * @alias deep.property
1001
+ * @param {String} name
1002
+ * @param {Mixed} value (optional)
1003
+ * @param {String} message _optional_
1004
+ * @returns value of property for chaining
1005
+ * @api public
1006
+ */
1007
+
1008
+ Assertion.addMethod('property', function (name, val, msg) {
1009
+ if (msg) flag(this, 'message', msg);
1010
+
1011
+ var descriptor = flag(this, 'deep') ? 'deep property ' : 'property '
1012
+ , negate = flag(this, 'negate')
1013
+ , obj = flag(this, 'object')
1014
+ , value = flag(this, 'deep')
1015
+ ? _.getPathValue(name, obj)
1016
+ : obj[name];
1017
+
1018
+ if (negate && undefined !== val) {
1019
+ if (undefined === value) {
1020
+ msg = (msg != null) ? msg + ': ' : '';
1021
+ throw new Error(msg + _.inspect(obj) + ' has no ' + descriptor + _.inspect(name));
1022
+ }
1023
+ } else {
1024
+ this.assert(
1025
+ undefined !== value
1026
+ , 'expected #{this} to have a ' + descriptor + _.inspect(name)
1027
+ , 'expected #{this} to not have ' + descriptor + _.inspect(name));
1028
+ }
1029
+
1030
+ if (undefined !== val) {
1031
+ this.assert(
1032
+ val === value
1033
+ , 'expected #{this} to have a ' + descriptor + _.inspect(name) + ' of #{exp}, but got #{act}'
1034
+ , 'expected #{this} to not have a ' + descriptor + _.inspect(name) + ' of #{act}'
1035
+ , val
1036
+ , value
1037
+ );
1038
+ }
1039
+
1040
+ flag(this, 'object', value);
1041
+ });
1042
+
1043
+
1044
+ /**
1045
+ * ### .ownProperty(name)
1046
+ *
1047
+ * Asserts that the target has an own property `name`.
1048
+ *
1049
+ * expect('test').to.have.ownProperty('length');
1050
+ *
1051
+ * @name ownProperty
1052
+ * @alias haveOwnProperty
1053
+ * @param {String} name
1054
+ * @param {String} message _optional_
1055
+ * @api public
1056
+ */
1057
+
1058
+ function assertOwnProperty (name, msg) {
1059
+ if (msg) flag(this, 'message', msg);
1060
+ var obj = flag(this, 'object');
1061
+ this.assert(
1062
+ obj.hasOwnProperty(name)
1063
+ , 'expected #{this} to have own property ' + _.inspect(name)
1064
+ , 'expected #{this} to not have own property ' + _.inspect(name)
1065
+ );
1066
+ }
1067
+
1068
+ Assertion.addMethod('ownProperty', assertOwnProperty);
1069
+ Assertion.addMethod('haveOwnProperty', assertOwnProperty);
1070
+
1071
+ /**
1072
+ * ### .length(value)
1073
+ *
1074
+ * Asserts that the target's `length` property has
1075
+ * the expected value.
1076
+ *
1077
+ * expect([ 1, 2, 3]).to.have.length(3);
1078
+ * expect('foobar').to.have.length(6);
1079
+ *
1080
+ * Can also be used as a chain precursor to a value
1081
+ * comparison for the length property.
1082
+ *
1083
+ * expect('foo').to.have.length.above(2);
1084
+ * expect([ 1, 2, 3 ]).to.have.length.above(2);
1085
+ * expect('foo').to.have.length.below(4);
1086
+ * expect([ 1, 2, 3 ]).to.have.length.below(4);
1087
+ * expect('foo').to.have.length.within(2,4);
1088
+ * expect([ 1, 2, 3 ]).to.have.length.within(2,4);
1089
+ *
1090
+ * @name length
1091
+ * @alias lengthOf
1092
+ * @param {Number} length
1093
+ * @param {String} message _optional_
1094
+ * @api public
1095
+ */
1096
+
1097
+ function assertLengthChain () {
1098
+ flag(this, 'doLength', true);
1099
+ }
1100
+
1101
+ function assertLength (n, msg) {
1102
+ if (msg) flag(this, 'message', msg);
1103
+ var obj = flag(this, 'object');
1104
+ new Assertion(obj, msg).to.have.property('length');
1105
+ var len = obj.length;
1106
+
1107
+ this.assert(
1108
+ len == n
1109
+ , 'expected #{this} to have a length of #{exp} but got #{act}'
1110
+ , 'expected #{this} to not have a length of #{act}'
1111
+ , n
1112
+ , len
1113
+ );
1114
+ }
1115
+
1116
+ Assertion.addChainableMethod('length', assertLength, assertLengthChain);
1117
+ Assertion.addMethod('lengthOf', assertLength, assertLengthChain);
1118
+
1119
+ /**
1120
+ * ### .match(regexp)
1121
+ *
1122
+ * Asserts that the target matches a regular expression.
1123
+ *
1124
+ * expect('foobar').to.match(/^foo/);
1125
+ *
1126
+ * @name match
1127
+ * @param {RegExp} RegularExpression
1128
+ * @param {String} message _optional_
1129
+ * @api public
1130
+ */
1131
+
1132
+ Assertion.addMethod('match', function (re, msg) {
1133
+ if (msg) flag(this, 'message', msg);
1134
+ var obj = flag(this, 'object');
1135
+ this.assert(
1136
+ re.exec(obj)
1137
+ , 'expected #{this} to match ' + re
1138
+ , 'expected #{this} not to match ' + re
1139
+ );
1140
+ });
1141
+
1142
+ /**
1143
+ * ### .string(string)
1144
+ *
1145
+ * Asserts that the string target contains another string.
1146
+ *
1147
+ * expect('foobar').to.have.string('bar');
1148
+ *
1149
+ * @name string
1150
+ * @param {String} string
1151
+ * @param {String} message _optional_
1152
+ * @api public
1153
+ */
1154
+
1155
+ Assertion.addMethod('string', function (str, msg) {
1156
+ if (msg) flag(this, 'message', msg);
1157
+ var obj = flag(this, 'object');
1158
+ new Assertion(obj, msg).is.a('string');
1159
+
1160
+ this.assert(
1161
+ ~obj.indexOf(str)
1162
+ , 'expected #{this} to contain ' + _.inspect(str)
1163
+ , 'expected #{this} to not contain ' + _.inspect(str)
1164
+ );
1165
+ });
1166
+
1167
+
1168
+ /**
1169
+ * ### .keys(key1, [key2], [...])
1170
+ *
1171
+ * Asserts that the target has exactly the given keys, or
1172
+ * asserts the inclusion of some keys when using the
1173
+ * `include` or `contain` modifiers.
1174
+ *
1175
+ * expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']);
1176
+ * expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar');
1177
+ *
1178
+ * @name keys
1179
+ * @alias key
1180
+ * @param {String...|Array} keys
1181
+ * @api public
1182
+ */
1183
+
1184
+ function assertKeys (keys) {
1185
+ var obj = flag(this, 'object')
1186
+ , str
1187
+ , ok = true;
1188
+
1189
+ keys = keys instanceof Array
1190
+ ? keys
1191
+ : Array.prototype.slice.call(arguments);
1192
+
1193
+ if (!keys.length) throw new Error('keys required');
1194
+
1195
+ var actual = Object.keys(obj)
1196
+ , len = keys.length;
1197
+
1198
+ // Inclusion
1199
+ ok = keys.every(function(key){
1200
+ return ~actual.indexOf(key);
1201
+ });
1202
+
1203
+ // Strict
1204
+ if (!flag(this, 'negate') && !flag(this, 'contains')) {
1205
+ ok = ok && keys.length == actual.length;
1206
+ }
1207
+
1208
+ // Key string
1209
+ if (len > 1) {
1210
+ keys = keys.map(function(key){
1211
+ return _.inspect(key);
1212
+ });
1213
+ var last = keys.pop();
1214
+ str = keys.join(', ') + ', and ' + last;
1215
+ } else {
1216
+ str = _.inspect(keys[0]);
1217
+ }
1218
+
1219
+ // Form
1220
+ str = (len > 1 ? 'keys ' : 'key ') + str;
1221
+
1222
+ // Have / include
1223
+ str = (flag(this, 'contains') ? 'contain ' : 'have ') + str;
1224
+
1225
+ // Assertion
1226
+ this.assert(
1227
+ ok
1228
+ , 'expected #{this} to ' + str
1229
+ , 'expected #{this} to not ' + str
1230
+ );
1231
+ }
1232
+
1233
+ Assertion.addMethod('keys', assertKeys);
1234
+ Assertion.addMethod('key', assertKeys);
1235
+
1236
+ /**
1237
+ * ### .throw(constructor)
1238
+ *
1239
+ * Asserts that the function target will throw a specific error, or specific type of error
1240
+ * (as determined using `instanceof`), optionally with a RegExp or string inclusion test
1241
+ * for the error's message.
1242
+ *
1243
+ * var err = new ReferenceError('This is a bad function.');
1244
+ * var fn = function () { throw err; }
1245
+ * expect(fn).to.throw(ReferenceError);
1246
+ * expect(fn).to.throw(Error);
1247
+ * expect(fn).to.throw(/bad function/);
1248
+ * expect(fn).to.not.throw('good function');
1249
+ * expect(fn).to.throw(ReferenceError, /bad function/);
1250
+ * expect(fn).to.throw(err);
1251
+ * expect(fn).to.not.throw(new RangeError('Out of range.'));
1252
+ *
1253
+ * Please note that when a throw expectation is negated, it will check each
1254
+ * parameter independently, starting with error constructor type. The appropriate way
1255
+ * to check for the existence of a type of error but for a message that does not match
1256
+ * is to use `and`.
1257
+ *
1258
+ * expect(fn).to.throw(ReferenceError)
1259
+ * .and.not.throw(/good function/);
1260
+ *
1261
+ * @name throw
1262
+ * @alias throws
1263
+ * @alias Throw
1264
+ * @param {ErrorConstructor} constructor
1265
+ * @param {String|RegExp} expected error message
1266
+ * @param {String} message _optional_
1267
+ * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
1268
+ * @api public
1269
+ */
1270
+
1271
+ function assertThrows (constructor, errMsg, msg) {
1272
+ if (msg) flag(this, 'message', msg);
1273
+ var obj = flag(this, 'object');
1274
+ new Assertion(obj, msg).is.a('function');
1275
+
1276
+ var thrown = false
1277
+ , desiredError = null
1278
+ , name = null
1279
+ , thrownError = null;
1280
+
1281
+ if (arguments.length === 0) {
1282
+ errMsg = null;
1283
+ constructor = null;
1284
+ } else if (constructor && (constructor instanceof RegExp || 'string' === typeof constructor)) {
1285
+ errMsg = constructor;
1286
+ constructor = null;
1287
+ } else if (constructor && constructor instanceof Error) {
1288
+ desiredError = constructor;
1289
+ constructor = null;
1290
+ errMsg = null;
1291
+ } else if (typeof constructor === 'function') {
1292
+ name = (new constructor()).name;
1293
+ } else {
1294
+ constructor = null;
1295
+ }
1296
+
1297
+ try {
1298
+ obj();
1299
+ } catch (err) {
1300
+ // first, check desired error
1301
+ if (desiredError) {
1302
+ this.assert(
1303
+ err === desiredError
1304
+ , 'expected #{this} to throw ' + _.inspect(desiredError) + ' but ' + _.inspect(err) + ' was thrown'
1305
+ , 'expected #{this} to not throw ' + _.inspect(desiredError)
1306
+ );
1307
+ return this;
1308
+ }
1309
+ // next, check constructor
1310
+ if (constructor) {
1311
+ this.assert(
1312
+ err instanceof constructor
1313
+ , 'expected #{this} to throw ' + name + ' but ' + _.inspect(err) + ' was thrown'
1314
+ , 'expected #{this} to not throw ' + name + ' but ' + _.inspect(err) + ' was thrown');
1315
+ if (!errMsg) return this;
1316
+ }
1317
+ // next, check message
1318
+ if (err.message && errMsg && errMsg instanceof RegExp) {
1319
+ this.assert(
1320
+ errMsg.exec(err.message)
1321
+ , 'expected #{this} to throw error matching ' + errMsg + ' but got ' + _.inspect(err.message)
1322
+ , 'expected #{this} to throw error not matching ' + errMsg
1323
+ );
1324
+ return this;
1325
+ } else if (err.message && errMsg && 'string' === typeof errMsg) {
1326
+ this.assert(
1327
+ ~err.message.indexOf(errMsg)
1328
+ , 'expected #{this} to throw error including #{exp} but got #{act}'
1329
+ , 'expected #{this} to throw error not including #{act}'
1330
+ , errMsg
1331
+ , err.message
1332
+ );
1333
+ return this;
1334
+ } else {
1335
+ thrown = true;
1336
+ thrownError = err;
1337
+ }
1338
+ }
1339
+
1340
+ var expectedThrown = name ? name : desiredError ? _.inspect(desiredError) : 'an error';
1341
+ var actuallyGot = ''
1342
+ if (thrown) {
1343
+ actuallyGot = ' but ' + _.inspect(thrownError) + ' was thrown'
1344
+ }
1345
+
1346
+ this.assert(
1347
+ thrown === true
1348
+ , 'expected #{this} to throw ' + expectedThrown + actuallyGot
1349
+ , 'expected #{this} to not throw ' + expectedThrown + actuallyGot
1350
+ );
1351
+ };
1352
+
1353
+ Assertion.addMethod('throw', assertThrows);
1354
+ Assertion.addMethod('throws', assertThrows);
1355
+ Assertion.addMethod('Throw', assertThrows);
1356
+
1357
+ /**
1358
+ * ### .respondTo(method)
1359
+ *
1360
+ * Asserts that the object or class target will respond to a method.
1361
+ *
1362
+ * Klass.prototype.bar = function(){};
1363
+ * expect(Klass).to.respondTo('bar');
1364
+ * expect(obj).to.respondTo('bar');
1365
+ *
1366
+ * To check if a constructor will respond to a static function,
1367
+ * set the `itself` flag.
1368
+ *
1369
+ * Klass.baz = function(){};
1370
+ * expect(Klass).itself.to.respondTo('baz');
1371
+ *
1372
+ * @name respondTo
1373
+ * @param {String} method
1374
+ * @param {String} message _optional_
1375
+ * @api public
1376
+ */
1377
+
1378
+ Assertion.addMethod('respondTo', function (method, msg) {
1379
+ if (msg) flag(this, 'message', msg);
1380
+ var obj = flag(this, 'object')
1381
+ , itself = flag(this, 'itself')
1382
+ , context = ('function' === typeof obj && !itself)
1383
+ ? obj.prototype[method]
1384
+ : obj[method];
1385
+
1386
+ this.assert(
1387
+ 'function' === typeof context
1388
+ , 'expected #{this} to respond to ' + _.inspect(method)
1389
+ , 'expected #{this} to not respond to ' + _.inspect(method)
1390
+ );
1391
+ });
1392
+
1393
+ /**
1394
+ * ### .itself
1395
+ *
1396
+ * Sets the `itself` flag, later used by the `respondTo` assertion.
1397
+ *
1398
+ * function Foo() {}
1399
+ * Foo.bar = function() {}
1400
+ * Foo.prototype.baz = function() {}
1401
+ *
1402
+ * expect(Foo).itself.to.respondTo('bar');
1403
+ * expect(Foo).itself.not.to.respondTo('baz');
1404
+ *
1405
+ * @name itself
1406
+ * @api public
1407
+ */
1408
+
1409
+ Assertion.addProperty('itself', function () {
1410
+ flag(this, 'itself', true);
1411
+ });
1412
+
1413
+ /**
1414
+ * ### .satisfy(method)
1415
+ *
1416
+ * Asserts that the target passes a given truth test.
1417
+ *
1418
+ * expect(1).to.satisfy(function(num) { return num > 0; });
1419
+ *
1420
+ * @name satisfy
1421
+ * @param {Function} matcher
1422
+ * @param {String} message _optional_
1423
+ * @api public
1424
+ */
1425
+
1426
+ Assertion.addMethod('satisfy', function (matcher, msg) {
1427
+ if (msg) flag(this, 'message', msg);
1428
+ var obj = flag(this, 'object');
1429
+ this.assert(
1430
+ matcher(obj)
1431
+ , 'expected #{this} to satisfy ' + _.inspect(matcher)
1432
+ , 'expected #{this} to not satisfy' + _.inspect(matcher)
1433
+ , this.negate ? false : true
1434
+ , matcher(obj)
1435
+ );
1436
+ });
1437
+
1438
+ /**
1439
+ * ### .closeTo(expected, delta)
1440
+ *
1441
+ * Asserts that the target is equal `expected`, to within a +/- `delta` range.
1442
+ *
1443
+ * expect(1.5).to.be.closeTo(1, 0.5);
1444
+ *
1445
+ * @name closeTo
1446
+ * @param {Number} expected
1447
+ * @param {Number} delta
1448
+ * @param {String} message _optional_
1449
+ * @api public
1450
+ */
1451
+
1452
+ Assertion.addMethod('closeTo', function (expected, delta, msg) {
1453
+ if (msg) flag(this, 'message', msg);
1454
+ var obj = flag(this, 'object');
1455
+ this.assert(
1456
+ Math.abs(obj - expected) <= delta
1457
+ , 'expected #{this} to be close to ' + expected + ' +/- ' + delta
1458
+ , 'expected #{this} not to be close to ' + expected + ' +/- ' + delta
1459
+ );
1460
+ });
1461
+
1462
+ };
1463
+
1464
+ }); // module: chai/core/assertions.js
1465
+
1466
+ require.register("chai/error.js", function(module, exports, require){
1467
+ /*!
1468
+ * chai
1469
+ * Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>
1470
+ * MIT Licensed
1471
+ */
1472
+
1473
+ /*!
1474
+ * Main export
1475
+ */
1476
+
1477
+ module.exports = AssertionError;
1478
+
1479
+ /**
1480
+ * # AssertionError (constructor)
1481
+ *
1482
+ * Create a new assertion error based on the Javascript
1483
+ * `Error` prototype.
1484
+ *
1485
+ * **Options**
1486
+ * - message
1487
+ * - actual
1488
+ * - expected
1489
+ * - operator
1490
+ * - startStackFunction
1491
+ *
1492
+ * @param {Object} options
1493
+ * @api public
1494
+ */
1495
+
1496
+ function AssertionError (options) {
1497
+ options = options || {};
1498
+ this.message = options.message;
1499
+ this.actual = options.actual;
1500
+ this.expected = options.expected;
1501
+ this.operator = options.operator;
1502
+ this.showDiff = options.showDiff;
1503
+
1504
+ if (options.stackStartFunction && Error.captureStackTrace) {
1505
+ var stackStartFunction = options.stackStartFunction;
1506
+ Error.captureStackTrace(this, stackStartFunction);
1507
+ }
1508
+ }
1509
+
1510
+ /*!
1511
+ * Inherit from Error
1512
+ */
1513
+
1514
+ AssertionError.prototype = Object.create(Error.prototype);
1515
+ AssertionError.prototype.name = 'AssertionError';
1516
+ AssertionError.prototype.constructor = AssertionError;
1517
+
1518
+ /**
1519
+ * # toString()
1520
+ *
1521
+ * Override default to string method
1522
+ */
1523
+
1524
+ AssertionError.prototype.toString = function() {
1525
+ return this.message;
1526
+ };
1527
+
1528
+ }); // module: chai/error.js
1529
+
1530
+ require.register("chai/interface/assert.js", function(module, exports, require){
1531
+ /*!
1532
+ * chai
1533
+ * Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>
1534
+ * MIT Licensed
1535
+ */
1536
+
1537
+
1538
+ module.exports = function (chai, util) {
1539
+
1540
+ /*!
1541
+ * Chai dependencies.
1542
+ */
1543
+
1544
+ var Assertion = chai.Assertion
1545
+ , flag = util.flag;
1546
+
1547
+ /*!
1548
+ * Module export.
1549
+ */
1550
+
1551
+ /**
1552
+ * ### assert(expression, message)
1553
+ *
1554
+ * Write your own test expressions.
1555
+ *
1556
+ * assert('foo' !== 'bar', 'foo is not bar');
1557
+ * assert(Array.isArray([]), 'empty arrays are arrays');
1558
+ *
1559
+ * @param {Mixed} expression to test for truthiness
1560
+ * @param {String} message to display on error
1561
+ * @name assert
1562
+ * @api public
1563
+ */
1564
+
1565
+ var assert = chai.assert = function (express, errmsg) {
1566
+ var test = new Assertion(null);
1567
+ test.assert(
1568
+ express
1569
+ , errmsg
1570
+ , '[ negation message unavailable ]'
1571
+ );
1572
+ };
1573
+
1574
+ /**
1575
+ * ### .fail(actual, expected, [message], [operator])
1576
+ *
1577
+ * Throw a failure. Node.js `assert` module-compatible.
1578
+ *
1579
+ * @name fail
1580
+ * @param {Mixed} actual
1581
+ * @param {Mixed} expected
1582
+ * @param {String} message
1583
+ * @param {String} operator
1584
+ * @api public
1585
+ */
1586
+
1587
+ assert.fail = function (actual, expected, message, operator) {
1588
+ throw new chai.AssertionError({
1589
+ actual: actual
1590
+ , expected: expected
1591
+ , message: message
1592
+ , operator: operator
1593
+ , stackStartFunction: assert.fail
1594
+ });
1595
+ };
1596
+
1597
+ /**
1598
+ * ### .ok(object, [message])
1599
+ *
1600
+ * Asserts that `object` is truthy.
1601
+ *
1602
+ * assert.ok('everything', 'everything is ok');
1603
+ * assert.ok(false, 'this will fail');
1604
+ *
1605
+ * @name ok
1606
+ * @param {Mixed} object to test
1607
+ * @param {String} message
1608
+ * @api public
1609
+ */
1610
+
1611
+ assert.ok = function (val, msg) {
1612
+ new Assertion(val, msg).is.ok;
1613
+ };
1614
+
1615
+ /**
1616
+ * ### .equal(actual, expected, [message])
1617
+ *
1618
+ * Asserts non-strict equality (`==`) of `actual` and `expected`.
1619
+ *
1620
+ * assert.equal(3, '3', '== coerces values to strings');
1621
+ *
1622
+ * @name equal
1623
+ * @param {Mixed} actual
1624
+ * @param {Mixed} expected
1625
+ * @param {String} message
1626
+ * @api public
1627
+ */
1628
+
1629
+ assert.equal = function (act, exp, msg) {
1630
+ var test = new Assertion(act, msg);
1631
+
1632
+ test.assert(
1633
+ exp == flag(test, 'object')
1634
+ , 'expected #{this} to equal #{exp}'
1635
+ , 'expected #{this} to not equal #{act}'
1636
+ , exp
1637
+ , act
1638
+ );
1639
+ };
1640
+
1641
+ /**
1642
+ * ### .notEqual(actual, expected, [message])
1643
+ *
1644
+ * Asserts non-strict inequality (`!=`) of `actual` and `expected`.
1645
+ *
1646
+ * assert.notEqual(3, 4, 'these numbers are not equal');
1647
+ *
1648
+ * @name notEqual
1649
+ * @param {Mixed} actual
1650
+ * @param {Mixed} expected
1651
+ * @param {String} message
1652
+ * @api public
1653
+ */
1654
+
1655
+ assert.notEqual = function (act, exp, msg) {
1656
+ var test = new Assertion(act, msg);
1657
+
1658
+ test.assert(
1659
+ exp != flag(test, 'object')
1660
+ , 'expected #{this} to not equal #{exp}'
1661
+ , 'expected #{this} to equal #{act}'
1662
+ , exp
1663
+ , act
1664
+ );
1665
+ };
1666
+
1667
+ /**
1668
+ * ### .strictEqual(actual, expected, [message])
1669
+ *
1670
+ * Asserts strict equality (`===`) of `actual` and `expected`.
1671
+ *
1672
+ * assert.strictEqual(true, true, 'these booleans are strictly equal');
1673
+ *
1674
+ * @name strictEqual
1675
+ * @param {Mixed} actual
1676
+ * @param {Mixed} expected
1677
+ * @param {String} message
1678
+ * @api public
1679
+ */
1680
+
1681
+ assert.strictEqual = function (act, exp, msg) {
1682
+ new Assertion(act, msg).to.equal(exp);
1683
+ };
1684
+
1685
+ /**
1686
+ * ### .notStrictEqual(actual, expected, [message])
1687
+ *
1688
+ * Asserts strict inequality (`!==`) of `actual` and `expected`.
1689
+ *
1690
+ * assert.notStrictEqual(3, '3', 'no coercion for strict equality');
1691
+ *
1692
+ * @name notStrictEqual
1693
+ * @param {Mixed} actual
1694
+ * @param {Mixed} expected
1695
+ * @param {String} message
1696
+ * @api public
1697
+ */
1698
+
1699
+ assert.notStrictEqual = function (act, exp, msg) {
1700
+ new Assertion(act, msg).to.not.equal(exp);
1701
+ };
1702
+
1703
+ /**
1704
+ * ### .deepEqual(actual, expected, [message])
1705
+ *
1706
+ * Asserts that `actual` is deeply equal to `expected`.
1707
+ *
1708
+ * assert.deepEqual({ tea: 'green' }, { tea: 'green' });
1709
+ *
1710
+ * @name deepEqual
1711
+ * @param {Mixed} actual
1712
+ * @param {Mixed} expected
1713
+ * @param {String} message
1714
+ * @api public
1715
+ */
1716
+
1717
+ assert.deepEqual = function (act, exp, msg) {
1718
+ new Assertion(act, msg).to.eql(exp);
1719
+ };
1720
+
1721
+ /**
1722
+ * ### .notDeepEqual(actual, expected, [message])
1723
+ *
1724
+ * Assert that `actual` is not deeply equal to `expected`.
1725
+ *
1726
+ * assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' });
1727
+ *
1728
+ * @name notDeepEqual
1729
+ * @param {Mixed} actual
1730
+ * @param {Mixed} expected
1731
+ * @param {String} message
1732
+ * @api public
1733
+ */
1734
+
1735
+ assert.notDeepEqual = function (act, exp, msg) {
1736
+ new Assertion(act, msg).to.not.eql(exp);
1737
+ };
1738
+
1739
+ /**
1740
+ * ### .isTrue(value, [message])
1741
+ *
1742
+ * Asserts that `value` is true.
1743
+ *
1744
+ * var teaServed = true;
1745
+ * assert.isTrue(teaServed, 'the tea has been served');
1746
+ *
1747
+ * @name isTrue
1748
+ * @param {Mixed} value
1749
+ * @param {String} message
1750
+ * @api public
1751
+ */
1752
+
1753
+ assert.isTrue = function (val, msg) {
1754
+ new Assertion(val, msg).is['true'];
1755
+ };
1756
+
1757
+ /**
1758
+ * ### .isFalse(value, [message])
1759
+ *
1760
+ * Asserts that `value` is false.
1761
+ *
1762
+ * var teaServed = false;
1763
+ * assert.isFalse(teaServed, 'no tea yet? hmm...');
1764
+ *
1765
+ * @name isFalse
1766
+ * @param {Mixed} value
1767
+ * @param {String} message
1768
+ * @api public
1769
+ */
1770
+
1771
+ assert.isFalse = function (val, msg) {
1772
+ new Assertion(val, msg).is['false'];
1773
+ };
1774
+
1775
+ /**
1776
+ * ### .isNull(value, [message])
1777
+ *
1778
+ * Asserts that `value` is null.
1779
+ *
1780
+ * assert.isNull(err, 'there was no error');
1781
+ *
1782
+ * @name isNull
1783
+ * @param {Mixed} value
1784
+ * @param {String} message
1785
+ * @api public
1786
+ */
1787
+
1788
+ assert.isNull = function (val, msg) {
1789
+ new Assertion(val, msg).to.equal(null);
1790
+ };
1791
+
1792
+ /**
1793
+ * ### .isNotNull(value, [message])
1794
+ *
1795
+ * Asserts that `value` is not null.
1796
+ *
1797
+ * var tea = 'tasty chai';
1798
+ * assert.isNotNull(tea, 'great, time for tea!');
1799
+ *
1800
+ * @name isNotNull
1801
+ * @param {Mixed} value
1802
+ * @param {String} message
1803
+ * @api public
1804
+ */
1805
+
1806
+ assert.isNotNull = function (val, msg) {
1807
+ new Assertion(val, msg).to.not.equal(null);
1808
+ };
1809
+
1810
+ /**
1811
+ * ### .isUndefined(value, [message])
1812
+ *
1813
+ * Asserts that `value` is `undefined`.
1814
+ *
1815
+ * var tea;
1816
+ * assert.isUndefined(tea, 'no tea defined');
1817
+ *
1818
+ * @name isUndefined
1819
+ * @param {Mixed} value
1820
+ * @param {String} message
1821
+ * @api public
1822
+ */
1823
+
1824
+ assert.isUndefined = function (val, msg) {
1825
+ new Assertion(val, msg).to.equal(undefined);
1826
+ };
1827
+
1828
+ /**
1829
+ * ### .isDefined(value, [message])
1830
+ *
1831
+ * Asserts that `value` is not `undefined`.
1832
+ *
1833
+ * var tea = 'cup of chai';
1834
+ * assert.isDefined(tea, 'tea has been defined');
1835
+ *
1836
+ * @name isUndefined
1837
+ * @param {Mixed} value
1838
+ * @param {String} message
1839
+ * @api public
1840
+ */
1841
+
1842
+ assert.isDefined = function (val, msg) {
1843
+ new Assertion(val, msg).to.not.equal(undefined);
1844
+ };
1845
+
1846
+ /**
1847
+ * ### .isFunction(value, [message])
1848
+ *
1849
+ * Asserts that `value` is a function.
1850
+ *
1851
+ * function serveTea() { return 'cup of tea'; };
1852
+ * assert.isFunction(serveTea, 'great, we can have tea now');
1853
+ *
1854
+ * @name isFunction
1855
+ * @param {Mixed} value
1856
+ * @param {String} message
1857
+ * @api public
1858
+ */
1859
+
1860
+ assert.isFunction = function (val, msg) {
1861
+ new Assertion(val, msg).to.be.a('function');
1862
+ };
1863
+
1864
+ /**
1865
+ * ### .isNotFunction(value, [message])
1866
+ *
1867
+ * Asserts that `value` is _not_ a function.
1868
+ *
1869
+ * var serveTea = [ 'heat', 'pour', 'sip' ];
1870
+ * assert.isNotFunction(serveTea, 'great, we have listed the steps');
1871
+ *
1872
+ * @name isNotFunction
1873
+ * @param {Mixed} value
1874
+ * @param {String} message
1875
+ * @api public
1876
+ */
1877
+
1878
+ assert.isNotFunction = function (val, msg) {
1879
+ new Assertion(val, msg).to.not.be.a('function');
1880
+ };
1881
+
1882
+ /**
1883
+ * ### .isObject(value, [message])
1884
+ *
1885
+ * Asserts that `value` is an object (as revealed by
1886
+ * `Object.prototype.toString`).
1887
+ *
1888
+ * var selection = { name: 'Chai', serve: 'with spices' };
1889
+ * assert.isObject(selection, 'tea selection is an object');
1890
+ *
1891
+ * @name isObject
1892
+ * @param {Mixed} value
1893
+ * @param {String} message
1894
+ * @api public
1895
+ */
1896
+
1897
+ assert.isObject = function (val, msg) {
1898
+ new Assertion(val, msg).to.be.a('object');
1899
+ };
1900
+
1901
+ /**
1902
+ * ### .isNotObject(value, [message])
1903
+ *
1904
+ * Asserts that `value` is _not_ an object.
1905
+ *
1906
+ * var selection = 'chai'
1907
+ * assert.isObject(selection, 'tea selection is not an object');
1908
+ * assert.isObject(null, 'null is not an object');
1909
+ *
1910
+ * @name isNotObject
1911
+ * @param {Mixed} value
1912
+ * @param {String} message
1913
+ * @api public
1914
+ */
1915
+
1916
+ assert.isNotObject = function (val, msg) {
1917
+ new Assertion(val, msg).to.not.be.a('object');
1918
+ };
1919
+
1920
+ /**
1921
+ * ### .isArray(value, [message])
1922
+ *
1923
+ * Asserts that `value` is an array.
1924
+ *
1925
+ * var menu = [ 'green', 'chai', 'oolong' ];
1926
+ * assert.isArray(menu, 'what kind of tea do we want?');
1927
+ *
1928
+ * @name isArray
1929
+ * @param {Mixed} value
1930
+ * @param {String} message
1931
+ * @api public
1932
+ */
1933
+
1934
+ assert.isArray = function (val, msg) {
1935
+ new Assertion(val, msg).to.be.an('array');
1936
+ };
1937
+
1938
+ /**
1939
+ * ### .isNotArray(value, [message])
1940
+ *
1941
+ * Asserts that `value` is _not_ an array.
1942
+ *
1943
+ * var menu = 'green|chai|oolong';
1944
+ * assert.isNotArray(menu, 'what kind of tea do we want?');
1945
+ *
1946
+ * @name isNotArray
1947
+ * @param {Mixed} value
1948
+ * @param {String} message
1949
+ * @api public
1950
+ */
1951
+
1952
+ assert.isNotArray = function (val, msg) {
1953
+ new Assertion(val, msg).to.not.be.an('array');
1954
+ };
1955
+
1956
+ /**
1957
+ * ### .isString(value, [message])
1958
+ *
1959
+ * Asserts that `value` is a string.
1960
+ *
1961
+ * var teaOrder = 'chai';
1962
+ * assert.isString(teaOrder, 'order placed');
1963
+ *
1964
+ * @name isString
1965
+ * @param {Mixed} value
1966
+ * @param {String} message
1967
+ * @api public
1968
+ */
1969
+
1970
+ assert.isString = function (val, msg) {
1971
+ new Assertion(val, msg).to.be.a('string');
1972
+ };
1973
+
1974
+ /**
1975
+ * ### .isNotString(value, [message])
1976
+ *
1977
+ * Asserts that `value` is _not_ a string.
1978
+ *
1979
+ * var teaOrder = 4;
1980
+ * assert.isNotString(teaOrder, 'order placed');
1981
+ *
1982
+ * @name isNotString
1983
+ * @param {Mixed} value
1984
+ * @param {String} message
1985
+ * @api public
1986
+ */
1987
+
1988
+ assert.isNotString = function (val, msg) {
1989
+ new Assertion(val, msg).to.not.be.a('string');
1990
+ };
1991
+
1992
+ /**
1993
+ * ### .isNumber(value, [message])
1994
+ *
1995
+ * Asserts that `value` is a number.
1996
+ *
1997
+ * var cups = 2;
1998
+ * assert.isNumber(cups, 'how many cups');
1999
+ *
2000
+ * @name isNumber
2001
+ * @param {Number} value
2002
+ * @param {String} message
2003
+ * @api public
2004
+ */
2005
+
2006
+ assert.isNumber = function (val, msg) {
2007
+ new Assertion(val, msg).to.be.a('number');
2008
+ };
2009
+
2010
+ /**
2011
+ * ### .isNotNumber(value, [message])
2012
+ *
2013
+ * Asserts that `value` is _not_ a number.
2014
+ *
2015
+ * var cups = '2 cups please';
2016
+ * assert.isNotNumber(cups, 'how many cups');
2017
+ *
2018
+ * @name isNotNumber
2019
+ * @param {Mixed} value
2020
+ * @param {String} message
2021
+ * @api public
2022
+ */
2023
+
2024
+ assert.isNotNumber = function (val, msg) {
2025
+ new Assertion(val, msg).to.not.be.a('number');
2026
+ };
2027
+
2028
+ /**
2029
+ * ### .isBoolean(value, [message])
2030
+ *
2031
+ * Asserts that `value` is a boolean.
2032
+ *
2033
+ * var teaReady = true
2034
+ * , teaServed = false;
2035
+ *
2036
+ * assert.isBoolean(teaReady, 'is the tea ready');
2037
+ * assert.isBoolean(teaServed, 'has tea been served');
2038
+ *
2039
+ * @name isBoolean
2040
+ * @param {Mixed} value
2041
+ * @param {String} message
2042
+ * @api public
2043
+ */
2044
+
2045
+ assert.isBoolean = function (val, msg) {
2046
+ new Assertion(val, msg).to.be.a('boolean');
2047
+ };
2048
+
2049
+ /**
2050
+ * ### .isNotBoolean(value, [message])
2051
+ *
2052
+ * Asserts that `value` is _not_ a boolean.
2053
+ *
2054
+ * var teaReady = 'yep'
2055
+ * , teaServed = 'nope';
2056
+ *
2057
+ * assert.isNotBoolean(teaReady, 'is the tea ready');
2058
+ * assert.isNotBoolean(teaServed, 'has tea been served');
2059
+ *
2060
+ * @name isNotBoolean
2061
+ * @param {Mixed} value
2062
+ * @param {String} message
2063
+ * @api public
2064
+ */
2065
+
2066
+ assert.isNotBoolean = function (val, msg) {
2067
+ new Assertion(val, msg).to.not.be.a('boolean');
2068
+ };
2069
+
2070
+ /**
2071
+ * ### .typeOf(value, name, [message])
2072
+ *
2073
+ * Asserts that `value`'s type is `name`, as determined by
2074
+ * `Object.prototype.toString`.
2075
+ *
2076
+ * assert.typeOf({ tea: 'chai' }, 'object', 'we have an object');
2077
+ * assert.typeOf(['chai', 'jasmine'], 'array', 'we have an array');
2078
+ * assert.typeOf('tea', 'string', 'we have a string');
2079
+ * assert.typeOf(/tea/, 'regexp', 'we have a regular expression');
2080
+ * assert.typeOf(null, 'null', 'we have a null');
2081
+ * assert.typeOf(undefined, 'undefined', 'we have an undefined');
2082
+ *
2083
+ * @name typeOf
2084
+ * @param {Mixed} value
2085
+ * @param {String} name
2086
+ * @param {String} message
2087
+ * @api public
2088
+ */
2089
+
2090
+ assert.typeOf = function (val, type, msg) {
2091
+ new Assertion(val, msg).to.be.a(type);
2092
+ };
2093
+
2094
+ /**
2095
+ * ### .notTypeOf(value, name, [message])
2096
+ *
2097
+ * Asserts that `value`'s type is _not_ `name`, as determined by
2098
+ * `Object.prototype.toString`.
2099
+ *
2100
+ * assert.notTypeOf('tea', 'number', 'strings are not numbers');
2101
+ *
2102
+ * @name notTypeOf
2103
+ * @param {Mixed} value
2104
+ * @param {String} typeof name
2105
+ * @param {String} message
2106
+ * @api public
2107
+ */
2108
+
2109
+ assert.notTypeOf = function (val, type, msg) {
2110
+ new Assertion(val, msg).to.not.be.a(type);
2111
+ };
2112
+
2113
+ /**
2114
+ * ### .instanceOf(object, constructor, [message])
2115
+ *
2116
+ * Asserts that `value` is an instance of `constructor`.
2117
+ *
2118
+ * var Tea = function (name) { this.name = name; }
2119
+ * , chai = new Tea('chai');
2120
+ *
2121
+ * assert.instanceOf(chai, Tea, 'chai is an instance of tea');
2122
+ *
2123
+ * @name instanceOf
2124
+ * @param {Object} object
2125
+ * @param {Constructor} constructor
2126
+ * @param {String} message
2127
+ * @api public
2128
+ */
2129
+
2130
+ assert.instanceOf = function (val, type, msg) {
2131
+ new Assertion(val, msg).to.be.instanceOf(type);
2132
+ };
2133
+
2134
+ /**
2135
+ * ### .notInstanceOf(object, constructor, [message])
2136
+ *
2137
+ * Asserts `value` is not an instance of `constructor`.
2138
+ *
2139
+ * var Tea = function (name) { this.name = name; }
2140
+ * , chai = new String('chai');
2141
+ *
2142
+ * assert.notInstanceOf(chai, Tea, 'chai is not an instance of tea');
2143
+ *
2144
+ * @name notInstanceOf
2145
+ * @param {Object} object
2146
+ * @param {Constructor} constructor
2147
+ * @param {String} message
2148
+ * @api public
2149
+ */
2150
+
2151
+ assert.notInstanceOf = function (val, type, msg) {
2152
+ new Assertion(val, msg).to.not.be.instanceOf(type);
2153
+ };
2154
+
2155
+ /**
2156
+ * ### .include(haystack, needle, [message])
2157
+ *
2158
+ * Asserts that `haystack` includes `needle`. Works
2159
+ * for strings and arrays.
2160
+ *
2161
+ * assert.include('foobar', 'bar', 'foobar contains string "bar"');
2162
+ * assert.include([ 1, 2, 3 ], 3, 'array contains value');
2163
+ *
2164
+ * @name include
2165
+ * @param {Array|String} haystack
2166
+ * @param {Mixed} needle
2167
+ * @param {String} message
2168
+ * @api public
2169
+ */
2170
+
2171
+ assert.include = function (exp, inc, msg) {
2172
+ var obj = new Assertion(exp, msg);
2173
+
2174
+ if (Array.isArray(exp)) {
2175
+ obj.to.include(inc);
2176
+ } else if ('string' === typeof exp) {
2177
+ obj.to.contain.string(inc);
2178
+ }
2179
+ };
2180
+
2181
+ /**
2182
+ * ### .match(value, regexp, [message])
2183
+ *
2184
+ * Asserts that `value` matches the regular expression `regexp`.
2185
+ *
2186
+ * assert.match('foobar', /^foo/, 'regexp matches');
2187
+ *
2188
+ * @name match
2189
+ * @param {Mixed} value
2190
+ * @param {RegExp} regexp
2191
+ * @param {String} message
2192
+ * @api public
2193
+ */
2194
+
2195
+ assert.match = function (exp, re, msg) {
2196
+ new Assertion(exp, msg).to.match(re);
2197
+ };
2198
+
2199
+ /**
2200
+ * ### .notMatch(value, regexp, [message])
2201
+ *
2202
+ * Asserts that `value` does not match the regular expression `regexp`.
2203
+ *
2204
+ * assert.notMatch('foobar', /^foo/, 'regexp does not match');
2205
+ *
2206
+ * @name notMatch
2207
+ * @param {Mixed} value
2208
+ * @param {RegExp} regexp
2209
+ * @param {String} message
2210
+ * @api public
2211
+ */
2212
+
2213
+ assert.notMatch = function (exp, re, msg) {
2214
+ new Assertion(exp, msg).to.not.match(re);
2215
+ };
2216
+
2217
+ /**
2218
+ * ### .property(object, property, [message])
2219
+ *
2220
+ * Asserts that `object` has a property named by `property`.
2221
+ *
2222
+ * assert.property({ tea: { green: 'matcha' }}, 'tea');
2223
+ *
2224
+ * @name property
2225
+ * @param {Object} object
2226
+ * @param {String} property
2227
+ * @param {String} message
2228
+ * @api public
2229
+ */
2230
+
2231
+ assert.property = function (obj, prop, msg) {
2232
+ new Assertion(obj, msg).to.have.property(prop);
2233
+ };
2234
+
2235
+ /**
2236
+ * ### .notProperty(object, property, [message])
2237
+ *
2238
+ * Asserts that `object` does _not_ have a property named by `property`.
2239
+ *
2240
+ * assert.notProperty({ tea: { green: 'matcha' }}, 'coffee');
2241
+ *
2242
+ * @name notProperty
2243
+ * @param {Object} object
2244
+ * @param {String} property
2245
+ * @param {String} message
2246
+ * @api public
2247
+ */
2248
+
2249
+ assert.notProperty = function (obj, prop, msg) {
2250
+ new Assertion(obj, msg).to.not.have.property(prop);
2251
+ };
2252
+
2253
+ /**
2254
+ * ### .deepProperty(object, property, [message])
2255
+ *
2256
+ * Asserts that `object` has a property named by `property`, which can be a
2257
+ * string using dot- and bracket-notation for deep reference.
2258
+ *
2259
+ * assert.deepProperty({ tea: { green: 'matcha' }}, 'tea.green');
2260
+ *
2261
+ * @name deepProperty
2262
+ * @param {Object} object
2263
+ * @param {String} property
2264
+ * @param {String} message
2265
+ * @api public
2266
+ */
2267
+
2268
+ assert.deepProperty = function (obj, prop, msg) {
2269
+ new Assertion(obj, msg).to.have.deep.property(prop);
2270
+ };
2271
+
2272
+ /**
2273
+ * ### .notDeepProperty(object, property, [message])
2274
+ *
2275
+ * Asserts that `object` does _not_ have a property named by `property`, which
2276
+ * can be a string using dot- and bracket-notation for deep reference.
2277
+ *
2278
+ * assert.notDeepProperty({ tea: { green: 'matcha' }}, 'tea.oolong');
2279
+ *
2280
+ * @name notDeepProperty
2281
+ * @param {Object} object
2282
+ * @param {String} property
2283
+ * @param {String} message
2284
+ * @api public
2285
+ */
2286
+
2287
+ assert.notDeepProperty = function (obj, prop, msg) {
2288
+ new Assertion(obj, msg).to.not.have.deep.property(prop);
2289
+ };
2290
+
2291
+ /**
2292
+ * ### .propertyVal(object, property, value, [message])
2293
+ *
2294
+ * Asserts that `object` has a property named by `property` with value given
2295
+ * by `value`.
2296
+ *
2297
+ * assert.propertyVal({ tea: 'is good' }, 'tea', 'is good');
2298
+ *
2299
+ * @name propertyVal
2300
+ * @param {Object} object
2301
+ * @param {String} property
2302
+ * @param {Mixed} value
2303
+ * @param {String} message
2304
+ * @api public
2305
+ */
2306
+
2307
+ assert.propertyVal = function (obj, prop, val, msg) {
2308
+ new Assertion(obj, msg).to.have.property(prop, val);
2309
+ };
2310
+
2311
+ /**
2312
+ * ### .propertyNotVal(object, property, value, [message])
2313
+ *
2314
+ * Asserts that `object` has a property named by `property`, but with a value
2315
+ * different from that given by `value`.
2316
+ *
2317
+ * assert.propertyNotVal({ tea: 'is good' }, 'tea', 'is bad');
2318
+ *
2319
+ * @name propertyNotVal
2320
+ * @param {Object} object
2321
+ * @param {String} property
2322
+ * @param {Mixed} value
2323
+ * @param {String} message
2324
+ * @api public
2325
+ */
2326
+
2327
+ assert.propertyNotVal = function (obj, prop, val, msg) {
2328
+ new Assertion(obj, msg).to.not.have.property(prop, val);
2329
+ };
2330
+
2331
+ /**
2332
+ * ### .deepPropertyVal(object, property, value, [message])
2333
+ *
2334
+ * Asserts that `object` has a property named by `property` with value given
2335
+ * by `value`. `property` can use dot- and bracket-notation for deep
2336
+ * reference.
2337
+ *
2338
+ * assert.deepPropertyVal({ tea: { green: 'matcha' }}, 'tea.green', 'matcha');
2339
+ *
2340
+ * @name deepPropertyVal
2341
+ * @param {Object} object
2342
+ * @param {String} property
2343
+ * @param {Mixed} value
2344
+ * @param {String} message
2345
+ * @api public
2346
+ */
2347
+
2348
+ assert.deepPropertyVal = function (obj, prop, val, msg) {
2349
+ new Assertion(obj, msg).to.have.deep.property(prop, val);
2350
+ };
2351
+
2352
+ /**
2353
+ * ### .deepPropertyNotVal(object, property, value, [message])
2354
+ *
2355
+ * Asserts that `object` has a property named by `property`, but with a value
2356
+ * different from that given by `value`. `property` can use dot- and
2357
+ * bracket-notation for deep reference.
2358
+ *
2359
+ * assert.deepPropertyNotVal({ tea: { green: 'matcha' }}, 'tea.green', 'konacha');
2360
+ *
2361
+ * @name deepPropertyNotVal
2362
+ * @param {Object} object
2363
+ * @param {String} property
2364
+ * @param {Mixed} value
2365
+ * @param {String} message
2366
+ * @api public
2367
+ */
2368
+
2369
+ assert.deepPropertyNotVal = function (obj, prop, val, msg) {
2370
+ new Assertion(obj, msg).to.not.have.deep.property(prop, val);
2371
+ };
2372
+
2373
+ /**
2374
+ * ### .lengthOf(object, length, [message])
2375
+ *
2376
+ * Asserts that `object` has a `length` property with the expected value.
2377
+ *
2378
+ * assert.lengthOf([1,2,3], 3, 'array has length of 3');
2379
+ * assert.lengthOf('foobar', 5, 'string has length of 6');
2380
+ *
2381
+ * @name lengthOf
2382
+ * @param {Mixed} object
2383
+ * @param {Number} length
2384
+ * @param {String} message
2385
+ * @api public
2386
+ */
2387
+
2388
+ assert.lengthOf = function (exp, len, msg) {
2389
+ new Assertion(exp, msg).to.have.length(len);
2390
+ };
2391
+
2392
+ /**
2393
+ * ### .throws(function, [constructor/string/regexp], [string/regexp], [message])
2394
+ *
2395
+ * Asserts that `function` will throw an error that is an instance of
2396
+ * `constructor`, or alternately that it will throw an error with message
2397
+ * matching `regexp`.
2398
+ *
2399
+ * assert.throw(fn, 'function throws a reference error');
2400
+ * assert.throw(fn, /function throws a reference error/);
2401
+ * assert.throw(fn, ReferenceError);
2402
+ * assert.throw(fn, ReferenceError, 'function throws a reference error');
2403
+ * assert.throw(fn, ReferenceError, /function throws a reference error/);
2404
+ *
2405
+ * @name throws
2406
+ * @alias throw
2407
+ * @alias Throw
2408
+ * @param {Function} function
2409
+ * @param {ErrorConstructor} constructor
2410
+ * @param {RegExp} regexp
2411
+ * @param {String} message
2412
+ * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
2413
+ * @api public
2414
+ */
2415
+
2416
+ assert.Throw = function (fn, errt, errs, msg) {
2417
+ if ('string' === typeof errt || errt instanceof RegExp) {
2418
+ errs = errt;
2419
+ errt = null;
2420
+ }
2421
+
2422
+ new Assertion(fn, msg).to.Throw(errt, errs);
2423
+ };
2424
+
2425
+ /**
2426
+ * ### .doesNotThrow(function, [constructor/regexp], [message])
2427
+ *
2428
+ * Asserts that `function` will _not_ throw an error that is an instance of
2429
+ * `constructor`, or alternately that it will not throw an error with message
2430
+ * matching `regexp`.
2431
+ *
2432
+ * assert.doesNotThrow(fn, Error, 'function does not throw');
2433
+ *
2434
+ * @name doesNotThrow
2435
+ * @param {Function} function
2436
+ * @param {ErrorConstructor} constructor
2437
+ * @param {RegExp} regexp
2438
+ * @param {String} message
2439
+ * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
2440
+ * @api public
2441
+ */
2442
+
2443
+ assert.doesNotThrow = function (fn, type, msg) {
2444
+ if ('string' === typeof type) {
2445
+ msg = type;
2446
+ type = null;
2447
+ }
2448
+
2449
+ new Assertion(fn, msg).to.not.Throw(type);
2450
+ };
2451
+
2452
+ /**
2453
+ * ### .operator(val1, operator, val2, [message])
2454
+ *
2455
+ * Compares two values using `operator`.
2456
+ *
2457
+ * assert.operator(1, '<', 2, 'everything is ok');
2458
+ * assert.operator(1, '>', 2, 'this will fail');
2459
+ *
2460
+ * @name operator
2461
+ * @param {Mixed} val1
2462
+ * @param {String} operator
2463
+ * @param {Mixed} val2
2464
+ * @param {String} message
2465
+ * @api public
2466
+ */
2467
+
2468
+ assert.operator = function (val, operator, val2, msg) {
2469
+ if (!~['==', '===', '>', '>=', '<', '<=', '!=', '!=='].indexOf(operator)) {
2470
+ throw new Error('Invalid operator "' + operator + '"');
2471
+ }
2472
+ var test = new Assertion(eval(val + operator + val2), msg);
2473
+ test.assert(
2474
+ true === flag(test, 'object')
2475
+ , 'expected ' + util.inspect(val) + ' to be ' + operator + ' ' + util.inspect(val2)
2476
+ , 'expected ' + util.inspect(val) + ' to not be ' + operator + ' ' + util.inspect(val2) );
2477
+ };
2478
+
2479
+ /**
2480
+ * ### .closeTo(actual, expected, delta, [message])
2481
+ *
2482
+ * Asserts that the target is equal `expected`, to within a +/- `delta` range.
2483
+ *
2484
+ * assert.closeTo(1.5, 1, 0.5, 'numbers are close');
2485
+ *
2486
+ * @name closeTo
2487
+ * @param {Number} actual
2488
+ * @param {Number} expected
2489
+ * @param {Number} delta
2490
+ * @param {String} message
2491
+ * @api public
2492
+ */
2493
+
2494
+ assert.closeTo = function (act, exp, delta, msg) {
2495
+ new Assertion(act, msg).to.be.closeTo(exp, delta);
2496
+ };
2497
+
2498
+ /*!
2499
+ * Undocumented / untested
2500
+ */
2501
+
2502
+ assert.ifError = function (val, msg) {
2503
+ new Assertion(val, msg).to.not.be.ok;
2504
+ };
2505
+
2506
+ /*!
2507
+ * Aliases.
2508
+ */
2509
+
2510
+ (function alias(name, as){
2511
+ assert[as] = assert[name];
2512
+ return alias;
2513
+ })
2514
+ ('Throw', 'throw')
2515
+ ('Throw', 'throws');
2516
+ };
2517
+
2518
+ }); // module: chai/interface/assert.js
2519
+
2520
+ require.register("chai/interface/expect.js", function(module, exports, require){
2521
+ /*!
2522
+ * chai
2523
+ * Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>
2524
+ * MIT Licensed
2525
+ */
2526
+
2527
+ module.exports = function (chai, util) {
2528
+ chai.expect = function (val, message) {
2529
+ return new chai.Assertion(val, message);
2530
+ };
2531
+ };
2532
+
2533
+
2534
+ }); // module: chai/interface/expect.js
2535
+
2536
+ require.register("chai/interface/should.js", function(module, exports, require){
2537
+ /*!
2538
+ * chai
2539
+ * Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>
2540
+ * MIT Licensed
2541
+ */
2542
+
2543
+ module.exports = function (chai, util) {
2544
+ var Assertion = chai.Assertion;
2545
+
2546
+ function loadShould () {
2547
+ // modify Object.prototype to have `should`
2548
+ Object.defineProperty(Object.prototype, 'should',
2549
+ {
2550
+ set: function (value) {
2551
+ // See https://github.com/chaijs/chai/issues/86: this makes
2552
+ // `whatever.should = someValue` actually set `someValue`, which is
2553
+ // especially useful for `global.should = require('chai').should()`.
2554
+ //
2555
+ // Note that we have to use [[DefineProperty]] instead of [[Put]]
2556
+ // since otherwise we would trigger this very setter!
2557
+ Object.defineProperty(this, 'should', {
2558
+ value: value,
2559
+ enumerable: true,
2560
+ configurable: true,
2561
+ writable: true
2562
+ });
2563
+ }
2564
+ , get: function(){
2565
+ if (this instanceof String || this instanceof Number) {
2566
+ return new Assertion(this.constructor(this));
2567
+ } else if (this instanceof Boolean) {
2568
+ return new Assertion(this == true);
2569
+ }
2570
+ return new Assertion(this);
2571
+ }
2572
+ , configurable: true
2573
+ });
2574
+
2575
+ var should = {};
2576
+
2577
+ should.equal = function (val1, val2, msg) {
2578
+ new Assertion(val1, msg).to.equal(val2);
2579
+ };
2580
+
2581
+ should.Throw = function (fn, errt, errs, msg) {
2582
+ new Assertion(fn, msg).to.Throw(errt, errs);
2583
+ };
2584
+
2585
+ should.exist = function (val, msg) {
2586
+ new Assertion(val, msg).to.exist;
2587
+ }
2588
+
2589
+ // negation
2590
+ should.not = {}
2591
+
2592
+ should.not.equal = function (val1, val2, msg) {
2593
+ new Assertion(val1, msg).to.not.equal(val2);
2594
+ };
2595
+
2596
+ should.not.Throw = function (fn, errt, errs, msg) {
2597
+ new Assertion(fn, msg).to.not.Throw(errt, errs);
2598
+ };
2599
+
2600
+ should.not.exist = function (val, msg) {
2601
+ new Assertion(val, msg).to.not.exist;
2602
+ }
2603
+
2604
+ should['throw'] = should['Throw'];
2605
+ should.not['throw'] = should.not['Throw'];
2606
+
2607
+ return should;
2608
+ };
2609
+
2610
+ chai.should = loadShould;
2611
+ chai.Should = loadShould;
2612
+ };
2613
+
2614
+ }); // module: chai/interface/should.js
2615
+
2616
+ require.register("chai/utils/addChainableMethod.js", function(module, exports, require){
2617
+ /*!
2618
+ * Chai - addChainingMethod utility
2619
+ * Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
2620
+ * MIT Licensed
2621
+ */
2622
+
2623
+ /*!
2624
+ * Module dependencies
2625
+ */
2626
+
2627
+ var transferFlags = require('./transferFlags');
2628
+
2629
+ /**
2630
+ * ### addChainableMethod (ctx, name, method, chainingBehavior)
2631
+ *
2632
+ * Adds a method to an object, such that the method can also be chained.
2633
+ *
2634
+ * utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) {
2635
+ * var obj = utils.flag(this, 'object');
2636
+ * new chai.Assertion(obj).to.be.equal(str);
2637
+ * });
2638
+ *
2639
+ * Can also be accessed directly from `chai.Assertion`.
2640
+ *
2641
+ * chai.Assertion.addChainableMethod('foo', fn, chainingBehavior);
2642
+ *
2643
+ * The result can then be used as both a method assertion, executing both `method` and
2644
+ * `chainingBehavior`, or as a language chain, which only executes `chainingBehavior`.
2645
+ *
2646
+ * expect(fooStr).to.be.foo('bar');
2647
+ * expect(fooStr).to.be.foo.equal('foo');
2648
+ *
2649
+ * @param {Object} ctx object to which the method is added
2650
+ * @param {String} name of method to add
2651
+ * @param {Function} method function to be used for `name`, when called
2652
+ * @param {Function} chainingBehavior function to be called every time the property is accessed
2653
+ * @name addChainableMethod
2654
+ * @api public
2655
+ */
2656
+
2657
+ module.exports = function (ctx, name, method, chainingBehavior) {
2658
+ if (typeof chainingBehavior !== 'function')
2659
+ chainingBehavior = function () { };
2660
+
2661
+ Object.defineProperty(ctx, name,
2662
+ { get: function () {
2663
+ chainingBehavior.call(this);
2664
+
2665
+ var assert = function () {
2666
+ var result = method.apply(this, arguments);
2667
+ return result === undefined ? this : result;
2668
+ };
2669
+
2670
+ // Re-enumerate every time to better accomodate plugins.
2671
+ var asserterNames = Object.getOwnPropertyNames(ctx);
2672
+ asserterNames.forEach(function (asserterName) {
2673
+ var pd = Object.getOwnPropertyDescriptor(ctx, asserterName)
2674
+ , functionProtoPD = Object.getOwnPropertyDescriptor(Function.prototype, asserterName);
2675
+ // Avoid trying to overwrite things that we can't, like `length` and `arguments`.
2676
+ if (functionProtoPD && !functionProtoPD.configurable) return;
2677
+ if (asserterName === 'arguments') return; // @see chaijs/chai/issues/69
2678
+ Object.defineProperty(assert, asserterName, pd);
2679
+ });
2680
+
2681
+ transferFlags(this, assert);
2682
+ return assert;
2683
+ }
2684
+ , configurable: true
2685
+ });
2686
+ };
2687
+
2688
+ }); // module: chai/utils/addChainableMethod.js
2689
+
2690
+ require.register("chai/utils/addMethod.js", function(module, exports, require){
2691
+ /*!
2692
+ * Chai - addMethod utility
2693
+ * Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
2694
+ * MIT Licensed
2695
+ */
2696
+
2697
+ /**
2698
+ * ### .addMethod (ctx, name, method)
2699
+ *
2700
+ * Adds a method to the prototype of an object.
2701
+ *
2702
+ * utils.addMethod(chai.Assertion.prototype, 'foo', function (str) {
2703
+ * var obj = utils.flag(this, 'object');
2704
+ * new chai.Assertion(obj).to.be.equal(str);
2705
+ * });
2706
+ *
2707
+ * Can also be accessed directly from `chai.Assertion`.
2708
+ *
2709
+ * chai.Assertion.addMethod('foo', fn);
2710
+ *
2711
+ * Then can be used as any other assertion.
2712
+ *
2713
+ * expect(fooStr).to.be.foo('bar');
2714
+ *
2715
+ * @param {Object} ctx object to which the method is added
2716
+ * @param {String} name of method to add
2717
+ * @param {Function} method function to be used for name
2718
+ * @name addMethod
2719
+ * @api public
2720
+ */
2721
+
2722
+ module.exports = function (ctx, name, method) {
2723
+ ctx[name] = function () {
2724
+ var result = method.apply(this, arguments);
2725
+ return result === undefined ? this : result;
2726
+ };
2727
+ };
2728
+
2729
+ }); // module: chai/utils/addMethod.js
2730
+
2731
+ require.register("chai/utils/addProperty.js", function(module, exports, require){
2732
+ /*!
2733
+ * Chai - addProperty utility
2734
+ * Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
2735
+ * MIT Licensed
2736
+ */
2737
+
2738
+ /**
2739
+ * ### addProperty (ctx, name, getter)
2740
+ *
2741
+ * Adds a property to the prototype of an object.
2742
+ *
2743
+ * utils.addProperty(chai.Assertion.prototype, 'foo', function () {
2744
+ * var obj = utils.flag(this, 'object');
2745
+ * new chai.Assertion(obj).to.be.instanceof(Foo);
2746
+ * });
2747
+ *
2748
+ * Can also be accessed directly from `chai.Assertion`.
2749
+ *
2750
+ * chai.Assertion.addProperty('foo', fn);
2751
+ *
2752
+ * Then can be used as any other assertion.
2753
+ *
2754
+ * expect(myFoo).to.be.foo;
2755
+ *
2756
+ * @param {Object} ctx object to which the property is added
2757
+ * @param {String} name of property to add
2758
+ * @param {Function} getter function to be used for name
2759
+ * @name addProperty
2760
+ * @api public
2761
+ */
2762
+
2763
+ module.exports = function (ctx, name, getter) {
2764
+ Object.defineProperty(ctx, name,
2765
+ { get: function () {
2766
+ var result = getter.call(this);
2767
+ return result === undefined ? this : result;
2768
+ }
2769
+ , configurable: true
2770
+ });
2771
+ };
2772
+
2773
+ }); // module: chai/utils/addProperty.js
2774
+
2775
+ require.register("chai/utils/eql.js", function(module, exports, require){
2776
+ // This is (almost) directly from Node.js assert
2777
+ // https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/assert.js
2778
+
2779
+ module.exports = _deepEqual;
2780
+
2781
+ // for the browser
2782
+ var Buffer;
2783
+ try {
2784
+ Buffer = require('buffer').Buffer;
2785
+ } catch (ex) {
2786
+ Buffer = {
2787
+ isBuffer: function () { return false; }
2788
+ };
2789
+ }
2790
+
2791
+ function _deepEqual(actual, expected, memos) {
2792
+
2793
+ // 7.1. All identical values are equivalent, as determined by ===.
2794
+ if (actual === expected) {
2795
+ return true;
2796
+
2797
+ } else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) {
2798
+ if (actual.length != expected.length) return false;
2799
+
2800
+ for (var i = 0; i < actual.length; i++) {
2801
+ if (actual[i] !== expected[i]) return false;
2802
+ }
2803
+
2804
+ return true;
2805
+
2806
+ // 7.2. If the expected value is a Date object, the actual value is
2807
+ // equivalent if it is also a Date object that refers to the same time.
2808
+ } else if (actual instanceof Date && expected instanceof Date) {
2809
+ return actual.getTime() === expected.getTime();
2810
+
2811
+ // 7.3. Other pairs that do not both pass typeof value == 'object',
2812
+ // equivalence is determined by ==.
2813
+ } else if (typeof actual != 'object' && typeof expected != 'object') {
2814
+ return actual === expected;
2815
+
2816
+ // 7.4. For all other Object pairs, including Array objects, equivalence is
2817
+ // determined by having the same number of owned properties (as verified
2818
+ // with Object.prototype.hasOwnProperty.call), the same set of keys
2819
+ // (although not necessarily the same order), equivalent values for every
2820
+ // corresponding key, and an identical 'prototype' property. Note: this
2821
+ // accounts for both named and indexed properties on Arrays.
2822
+ } else {
2823
+ return objEquiv(actual, expected, memos);
2824
+ }
2825
+ }
2826
+
2827
+ function isUndefinedOrNull(value) {
2828
+ return value === null || value === undefined;
2829
+ }
2830
+
2831
+ function isArguments(object) {
2832
+ return Object.prototype.toString.call(object) == '[object Arguments]';
2833
+ }
2834
+
2835
+ function objEquiv(a, b, memos) {
2836
+ if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
2837
+ return false;
2838
+
2839
+ // an identical 'prototype' property.
2840
+ if (a.prototype !== b.prototype) return false;
2841
+
2842
+ // check if we have already compared a and b
2843
+ var i;
2844
+ if (memos) {
2845
+ for(i = 0; i < memos.length; i++) {
2846
+ if ((memos[i][0] === a && memos[i][1] === b) ||
2847
+ (memos[i][0] === b && memos[i][1] === a))
2848
+ return true;
2849
+ }
2850
+ } else {
2851
+ memos = [];
2852
+ }
2853
+
2854
+ //~~~I've managed to break Object.keys through screwy arguments passing.
2855
+ // Converting to array solves the problem.
2856
+ if (isArguments(a)) {
2857
+ if (!isArguments(b)) {
2858
+ return false;
2859
+ }
2860
+ a = pSlice.call(a);
2861
+ b = pSlice.call(b);
2862
+ return _deepEqual(a, b, memos);
2863
+ }
2864
+ try {
2865
+ var ka = Object.keys(a),
2866
+ kb = Object.keys(b),
2867
+ key;
2868
+ } catch (e) {//happens when one is a string literal and the other isn't
2869
+ return false;
2870
+ }
2871
+
2872
+ // having the same number of owned properties (keys incorporates
2873
+ // hasOwnProperty)
2874
+ if (ka.length != kb.length)
2875
+ return false;
2876
+
2877
+ //the same set of keys (although not necessarily the same order),
2878
+ ka.sort();
2879
+ kb.sort();
2880
+ //~~~cheap key test
2881
+ for (i = ka.length - 1; i >= 0; i--) {
2882
+ if (ka[i] != kb[i])
2883
+ return false;
2884
+ }
2885
+
2886
+ // remember objects we have compared to guard against circular references
2887
+ memos.push([ a, b ]);
2888
+
2889
+ //equivalent values for every corresponding key, and
2890
+ //~~~possibly expensive deep test
2891
+ for (i = ka.length - 1; i >= 0; i--) {
2892
+ key = ka[i];
2893
+ if (!_deepEqual(a[key], b[key], memos)) return false;
2894
+ }
2895
+
2896
+ return true;
2897
+ }
2898
+
2899
+ }); // module: chai/utils/eql.js
2900
+
2901
+ require.register("chai/utils/flag.js", function(module, exports, require){
2902
+ /*!
2903
+ * Chai - flag utility
2904
+ * Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
2905
+ * MIT Licensed
2906
+ */
2907
+
2908
+ /**
2909
+ * ### flag(object ,key, [value])
2910
+ *
2911
+ * Get or set a flag value on an object. If a
2912
+ * value is provided it will be set, else it will
2913
+ * return the currently set value or `undefined` if
2914
+ * the value is not set.
2915
+ *
2916
+ * utils.flag(this, 'foo', 'bar'); // setter
2917
+ * utils.flag(this, 'foo'); // getter, returns `bar`
2918
+ *
2919
+ * @param {Object} object (constructed Assertion
2920
+ * @param {String} key
2921
+ * @param {Mixed} value (optional)
2922
+ * @name flag
2923
+ * @api private
2924
+ */
2925
+
2926
+ module.exports = function (obj, key, value) {
2927
+ var flags = obj.__flags || (obj.__flags = Object.create(null));
2928
+ if (arguments.length === 3) {
2929
+ flags[key] = value;
2930
+ } else {
2931
+ return flags[key];
2932
+ }
2933
+ };
2934
+
2935
+ }); // module: chai/utils/flag.js
2936
+
2937
+ require.register("chai/utils/getActual.js", function(module, exports, require){
2938
+ /*!
2939
+ * Chai - getActual utility
2940
+ * Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
2941
+ * MIT Licensed
2942
+ */
2943
+
2944
+ /**
2945
+ * # getActual(object, [actual])
2946
+ *
2947
+ * Returns the `actual` value for an Assertion
2948
+ *
2949
+ * @param {Object} object (constructed Assertion)
2950
+ * @param {Arguments} chai.Assertion.prototype.assert arguments
2951
+ */
2952
+
2953
+ module.exports = function (obj, args) {
2954
+ var actual = args[4];
2955
+ return 'undefined' !== typeof actual ? actual : obj._obj;
2956
+ };
2957
+
2958
+ }); // module: chai/utils/getActual.js
2959
+
2960
+ require.register("chai/utils/getMessage.js", function(module, exports, require){
2961
+ /*!
2962
+ * Chai - message composition utility
2963
+ * Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
2964
+ * MIT Licensed
2965
+ */
2966
+
2967
+ /*!
2968
+ * Module dependancies
2969
+ */
2970
+
2971
+ var flag = require('./flag')
2972
+ , getActual = require('./getActual')
2973
+ , inspect = require('./inspect')
2974
+ , objDisplay = require('./objDisplay');
2975
+
2976
+ /**
2977
+ * ### .getMessage(object, message, negateMessage)
2978
+ *
2979
+ * Construct the error message based on flags
2980
+ * and template tags. Template tags will return
2981
+ * a stringified inspection of the object referenced.
2982
+ *
2983
+ * Messsage template tags:
2984
+ * - `#{this}` current asserted object
2985
+ * - `#{act}` actual value
2986
+ * - `#{exp}` expected value
2987
+ *
2988
+ * @param {Object} object (constructed Assertion)
2989
+ * @param {Arguments} chai.Assertion.prototype.assert arguments
2990
+ * @name getMessage
2991
+ * @api public
2992
+ */
2993
+
2994
+ module.exports = function (obj, args) {
2995
+ var negate = flag(obj, 'negate')
2996
+ , val = flag(obj, 'object')
2997
+ , expected = args[3]
2998
+ , actual = getActual(obj, args)
2999
+ , msg = negate ? args[2] : args[1]
3000
+ , flagMsg = flag(obj, 'message');
3001
+
3002
+ msg = msg || '';
3003
+ msg = msg
3004
+ .replace(/#{this}/g, objDisplay(val))
3005
+ .replace(/#{act}/g, objDisplay(actual))
3006
+ .replace(/#{exp}/g, objDisplay(expected));
3007
+
3008
+ return flagMsg ? flagMsg + ': ' + msg : msg;
3009
+ };
3010
+
3011
+ }); // module: chai/utils/getMessage.js
3012
+
3013
+ require.register("chai/utils/getName.js", function(module, exports, require){
3014
+ /*!
3015
+ * Chai - getName utility
3016
+ * Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
3017
+ * MIT Licensed
3018
+ */
3019
+
3020
+ /**
3021
+ * # getName(func)
3022
+ *
3023
+ * Gets the name of a function, in a cross-browser way.
3024
+ *
3025
+ * @param {Function} a function (usually a constructor)
3026
+ */
3027
+
3028
+ module.exports = function (func) {
3029
+ if (func.name) return func.name;
3030
+
3031
+ var match = /^\s?function ([^(]*)\(/.exec(func);
3032
+ return match && match[1] ? match[1] : "";
3033
+ };
3034
+
3035
+ }); // module: chai/utils/getName.js
3036
+
3037
+ require.register("chai/utils/getPathValue.js", function(module, exports, require){
3038
+ /*!
3039
+ * Chai - getPathValue utility
3040
+ * Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
3041
+ * @see https://github.com/logicalparadox/filtr
3042
+ * MIT Licensed
3043
+ */
3044
+
3045
+ /**
3046
+ * ### .getPathValue(path, object)
3047
+ *
3048
+ * This allows the retrieval of values in an
3049
+ * object given a string path.
3050
+ *
3051
+ * var obj = {
3052
+ * prop1: {
3053
+ * arr: ['a', 'b', 'c']
3054
+ * , str: 'Hello'
3055
+ * }
3056
+ * , prop2: {
3057
+ * arr: [ { nested: 'Universe' } ]
3058
+ * , str: 'Hello again!'
3059
+ * }
3060
+ * }
3061
+ *
3062
+ * The following would be the results.
3063
+ *
3064
+ * getPathValue('prop1.str', obj); // Hello
3065
+ * getPathValue('prop1.att[2]', obj); // b
3066
+ * getPathValue('prop2.arr[0].nested', obj); // Universe
3067
+ *
3068
+ * @param {String} path
3069
+ * @param {Object} object
3070
+ * @returns {Object} value or `undefined`
3071
+ * @name getPathValue
3072
+ * @api public
3073
+ */
3074
+
3075
+ var getPathValue = module.exports = function (path, obj) {
3076
+ var parsed = parsePath(path);
3077
+ return _getPathValue(parsed, obj);
3078
+ };
3079
+
3080
+ /*!
3081
+ * ## parsePath(path)
3082
+ *
3083
+ * Helper function used to parse string object
3084
+ * paths. Use in conjunction with `_getPathValue`.
3085
+ *
3086
+ * var parsed = parsePath('myobject.property.subprop');
3087
+ *
3088
+ * ### Paths:
3089
+ *
3090
+ * * Can be as near infinitely deep and nested
3091
+ * * Arrays are also valid using the formal `myobject.document[3].property`.
3092
+ *
3093
+ * @param {String} path
3094
+ * @returns {Object} parsed
3095
+ * @api private
3096
+ */
3097
+
3098
+ function parsePath (path) {
3099
+ var str = path.replace(/\[/g, '.[')
3100
+ , parts = str.match(/(\\\.|[^.]+?)+/g);
3101
+ return parts.map(function (value) {
3102
+ var re = /\[(\d+)\]$/
3103
+ , mArr = re.exec(value)
3104
+ if (mArr) return { i: parseFloat(mArr[1]) };
3105
+ else return { p: value };
3106
+ });
3107
+ };
3108
+
3109
+ /*!
3110
+ * ## _getPathValue(parsed, obj)
3111
+ *
3112
+ * Helper companion function for `.parsePath` that returns
3113
+ * the value located at the parsed address.
3114
+ *
3115
+ * var value = getPathValue(parsed, obj);
3116
+ *
3117
+ * @param {Object} parsed definition from `parsePath`.
3118
+ * @param {Object} object to search against
3119
+ * @returns {Object|Undefined} value
3120
+ * @api private
3121
+ */
3122
+
3123
+ function _getPathValue (parsed, obj) {
3124
+ var tmp = obj
3125
+ , res;
3126
+ for (var i = 0, l = parsed.length; i < l; i++) {
3127
+ var part = parsed[i];
3128
+ if (tmp) {
3129
+ if ('undefined' !== typeof part.p)
3130
+ tmp = tmp[part.p];
3131
+ else if ('undefined' !== typeof part.i)
3132
+ tmp = tmp[part.i];
3133
+ if (i == (l - 1)) res = tmp;
3134
+ } else {
3135
+ res = undefined;
3136
+ }
3137
+ }
3138
+ return res;
3139
+ };
3140
+
3141
+ }); // module: chai/utils/getPathValue.js
3142
+
3143
+ require.register("chai/utils/index.js", function(module, exports, require){
3144
+ /*!
3145
+ * chai
3146
+ * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
3147
+ * MIT Licensed
3148
+ */
3149
+
3150
+ /*!
3151
+ * Main exports
3152
+ */
3153
+
3154
+ var exports = module.exports = {};
3155
+
3156
+ /*!
3157
+ * test utility
3158
+ */
3159
+
3160
+ exports.test = require('./test');
3161
+
3162
+ /*!
3163
+ * message utility
3164
+ */
3165
+
3166
+ exports.getMessage = require('./getMessage');
3167
+
3168
+ /*!
3169
+ * actual utility
3170
+ */
3171
+
3172
+ exports.getActual = require('./getActual');
3173
+
3174
+ /*!
3175
+ * Inspect util
3176
+ */
3177
+
3178
+ exports.inspect = require('./inspect');
3179
+
3180
+ /*!
3181
+ * Object Display util
3182
+ */
3183
+
3184
+ exports.objDisplay = require('./objDisplay');
3185
+
3186
+ /*!
3187
+ * Flag utility
3188
+ */
3189
+
3190
+ exports.flag = require('./flag');
3191
+
3192
+ /*!
3193
+ * Flag transferring utility
3194
+ */
3195
+
3196
+ exports.transferFlags = require('./transferFlags');
3197
+
3198
+ /*!
3199
+ * Deep equal utility
3200
+ */
3201
+
3202
+ exports.eql = require('./eql');
3203
+
3204
+ /*!
3205
+ * Deep path value
3206
+ */
3207
+
3208
+ exports.getPathValue = require('./getPathValue');
3209
+
3210
+ /*!
3211
+ * Function name
3212
+ */
3213
+
3214
+ exports.getName = require('./getName');
3215
+
3216
+ /*!
3217
+ * add Property
3218
+ */
3219
+
3220
+ exports.addProperty = require('./addProperty');
3221
+
3222
+ /*!
3223
+ * add Method
3224
+ */
3225
+
3226
+ exports.addMethod = require('./addMethod');
3227
+
3228
+ /*!
3229
+ * overwrite Property
3230
+ */
3231
+
3232
+ exports.overwriteProperty = require('./overwriteProperty');
3233
+
3234
+ /*!
3235
+ * overwrite Method
3236
+ */
3237
+
3238
+ exports.overwriteMethod = require('./overwriteMethod');
3239
+
3240
+ /*!
3241
+ * Add a chainable method
3242
+ */
3243
+
3244
+ exports.addChainableMethod = require('./addChainableMethod');
3245
+
3246
+
3247
+ }); // module: chai/utils/index.js
3248
+
3249
+ require.register("chai/utils/inspect.js", function(module, exports, require){
3250
+ // This is (almost) directly from Node.js utils
3251
+ // https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js
3252
+
3253
+ var getName = require('./getName');
3254
+
3255
+ module.exports = inspect;
3256
+
3257
+ /**
3258
+ * Echos the value of a value. Trys to print the value out
3259
+ * in the best way possible given the different types.
3260
+ *
3261
+ * @param {Object} obj The object to print out.
3262
+ * @param {Boolean} showHidden Flag that shows hidden (not enumerable)
3263
+ * properties of objects.
3264
+ * @param {Number} depth Depth in which to descend in object. Default is 2.
3265
+ * @param {Boolean} colors Flag to turn on ANSI escape codes to color the
3266
+ * output. Default is false (no coloring).
3267
+ */
3268
+ function inspect(obj, showHidden, depth, colors) {
3269
+ var ctx = {
3270
+ showHidden: showHidden,
3271
+ seen: [],
3272
+ stylize: function (str) { return str; }
3273
+ };
3274
+ return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
3275
+ }
3276
+
3277
+ // https://gist.github.com/1044128/
3278
+ var getOuterHTML = function(element) {
3279
+ if ('outerHTML' in element) return element.outerHTML;
3280
+ var ns = "http://www.w3.org/1999/xhtml";
3281
+ var container = document.createElementNS(ns, '_');
3282
+ var elemProto = (window.HTMLElement || window.Element).prototype;
3283
+ var xmlSerializer = new XMLSerializer();
3284
+ var html;
3285
+ if (document.xmlVersion) {
3286
+ return xmlSerializer.serializeToString(element);
3287
+ } else {
3288
+ container.appendChild(element.cloneNode(false));
3289
+ html = container.innerHTML.replace('><', '>' + element.innerHTML + '<');
3290
+ container.innerHTML = '';
3291
+ return html;
3292
+ }
3293
+ };
3294
+
3295
+ // Returns true if object is a DOM element.
3296
+ var isDOMElement = function (object) {
3297
+ if (typeof HTMLElement === 'object') {
3298
+ return object instanceof HTMLElement;
3299
+ } else {
3300
+ return object &&
3301
+ typeof object === 'object' &&
3302
+ object.nodeType === 1 &&
3303
+ typeof object.nodeName === 'string';
3304
+ }
3305
+ };
3306
+
3307
+ function formatValue(ctx, value, recurseTimes) {
3308
+ // Provide a hook for user-specified inspect functions.
3309
+ // Check that value is an object with an inspect function on it
3310
+ if (value && typeof value.inspect === 'function' &&
3311
+ // Filter out the util module, it's inspect function is special
3312
+ value.inspect !== exports.inspect &&
3313
+ // Also filter out any prototype objects using the circular check.
3314
+ !(value.constructor && value.constructor.prototype === value)) {
3315
+ return value.inspect(recurseTimes);
3316
+ }
3317
+
3318
+ // Primitive types cannot have properties
3319
+ var primitive = formatPrimitive(ctx, value);
3320
+ if (primitive) {
3321
+ return primitive;
3322
+ }
3323
+
3324
+ // If it's DOM elem, get outer HTML.
3325
+ if (isDOMElement(value)) {
3326
+ return getOuterHTML(value);
3327
+ }
3328
+
3329
+ // Look up the keys of the object.
3330
+ var visibleKeys = Object.keys(value);
3331
+ var keys = ctx.showHidden ? Object.getOwnPropertyNames(value) : visibleKeys;
3332
+
3333
+ // Some type of object without properties can be shortcutted.
3334
+ // In IE, errors have a single `stack` property, or if they are vanilla `Error`,
3335
+ // a `stack` plus `description` property; ignore those for consistency.
3336
+ if (keys.length === 0 || (isError(value) && (
3337
+ (keys.length === 1 && keys[0] === 'stack') ||
3338
+ (keys.length === 2 && keys[0] === 'description' && keys[1] === 'stack')
3339
+ ))) {
3340
+ if (typeof value === 'function') {
3341
+ var name = getName(value);
3342
+ var nameSuffix = name ? ': ' + name : '';
3343
+ return ctx.stylize('[Function' + nameSuffix + ']', 'special');
3344
+ }
3345
+ if (isRegExp(value)) {
3346
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
3347
+ }
3348
+ if (isDate(value)) {
3349
+ return ctx.stylize(Date.prototype.toUTCString.call(value), 'date');
3350
+ }
3351
+ if (isError(value)) {
3352
+ return formatError(value);
3353
+ }
3354
+ }
3355
+
3356
+ var base = '', array = false, braces = ['{', '}'];
3357
+
3358
+ // Make Array say that they are Array
3359
+ if (isArray(value)) {
3360
+ array = true;
3361
+ braces = ['[', ']'];
3362
+ }
3363
+
3364
+ // Make functions say that they are functions
3365
+ if (typeof value === 'function') {
3366
+ var name = getName(value);
3367
+ var nameSuffix = name ? ': ' + name : '';
3368
+ base = ' [Function' + nameSuffix + ']';
3369
+ }
3370
+
3371
+ // Make RegExps say that they are RegExps
3372
+ if (isRegExp(value)) {
3373
+ base = ' ' + RegExp.prototype.toString.call(value);
3374
+ }
3375
+
3376
+ // Make dates with properties first say the date
3377
+ if (isDate(value)) {
3378
+ base = ' ' + Date.prototype.toUTCString.call(value);
3379
+ }
3380
+
3381
+ // Make error with message first say the error
3382
+ if (isError(value)) {
3383
+ return formatError(value);
3384
+ }
3385
+
3386
+ if (keys.length === 0 && (!array || value.length == 0)) {
3387
+ return braces[0] + base + braces[1];
3388
+ }
3389
+
3390
+ if (recurseTimes < 0) {
3391
+ if (isRegExp(value)) {
3392
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
3393
+ } else {
3394
+ return ctx.stylize('[Object]', 'special');
3395
+ }
3396
+ }
3397
+
3398
+ ctx.seen.push(value);
3399
+
3400
+ var output;
3401
+ if (array) {
3402
+ output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
3403
+ } else {
3404
+ output = keys.map(function(key) {
3405
+ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
3406
+ });
3407
+ }
3408
+
3409
+ ctx.seen.pop();
3410
+
3411
+ return reduceToSingleString(output, base, braces);
3412
+ }
3413
+
3414
+
3415
+ function formatPrimitive(ctx, value) {
3416
+ switch (typeof value) {
3417
+ case 'undefined':
3418
+ return ctx.stylize('undefined', 'undefined');
3419
+
3420
+ case 'string':
3421
+ var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
3422
+ .replace(/'/g, "\\'")
3423
+ .replace(/\\"/g, '"') + '\'';
3424
+ return ctx.stylize(simple, 'string');
3425
+
3426
+ case 'number':
3427
+ return ctx.stylize('' + value, 'number');
3428
+
3429
+ case 'boolean':
3430
+ return ctx.stylize('' + value, 'boolean');
3431
+ }
3432
+ // For some reason typeof null is "object", so special case here.
3433
+ if (value === null) {
3434
+ return ctx.stylize('null', 'null');
3435
+ }
3436
+ }
3437
+
3438
+
3439
+ function formatError(value) {
3440
+ return '[' + Error.prototype.toString.call(value) + ']';
3441
+ }
3442
+
3443
+
3444
+ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
3445
+ var output = [];
3446
+ for (var i = 0, l = value.length; i < l; ++i) {
3447
+ if (Object.prototype.hasOwnProperty.call(value, String(i))) {
3448
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
3449
+ String(i), true));
3450
+ } else {
3451
+ output.push('');
3452
+ }
3453
+ }
3454
+ keys.forEach(function(key) {
3455
+ if (!key.match(/^\d+$/)) {
3456
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
3457
+ key, true));
3458
+ }
3459
+ });
3460
+ return output;
3461
+ }
3462
+
3463
+
3464
+ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
3465
+ var name, str;
3466
+ if (value.__lookupGetter__) {
3467
+ if (value.__lookupGetter__(key)) {
3468
+ if (value.__lookupSetter__(key)) {
3469
+ str = ctx.stylize('[Getter/Setter]', 'special');
3470
+ } else {
3471
+ str = ctx.stylize('[Getter]', 'special');
3472
+ }
3473
+ } else {
3474
+ if (value.__lookupSetter__(key)) {
3475
+ str = ctx.stylize('[Setter]', 'special');
3476
+ }
3477
+ }
3478
+ }
3479
+ if (visibleKeys.indexOf(key) < 0) {
3480
+ name = '[' + key + ']';
3481
+ }
3482
+ if (!str) {
3483
+ if (ctx.seen.indexOf(value[key]) < 0) {
3484
+ if (recurseTimes === null) {
3485
+ str = formatValue(ctx, value[key], null);
3486
+ } else {
3487
+ str = formatValue(ctx, value[key], recurseTimes - 1);
3488
+ }
3489
+ if (str.indexOf('\n') > -1) {
3490
+ if (array) {
3491
+ str = str.split('\n').map(function(line) {
3492
+ return ' ' + line;
3493
+ }).join('\n').substr(2);
3494
+ } else {
3495
+ str = '\n' + str.split('\n').map(function(line) {
3496
+ return ' ' + line;
3497
+ }).join('\n');
3498
+ }
3499
+ }
3500
+ } else {
3501
+ str = ctx.stylize('[Circular]', 'special');
3502
+ }
3503
+ }
3504
+ if (typeof name === 'undefined') {
3505
+ if (array && key.match(/^\d+$/)) {
3506
+ return str;
3507
+ }
3508
+ name = JSON.stringify('' + key);
3509
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
3510
+ name = name.substr(1, name.length - 2);
3511
+ name = ctx.stylize(name, 'name');
3512
+ } else {
3513
+ name = name.replace(/'/g, "\\'")
3514
+ .replace(/\\"/g, '"')
3515
+ .replace(/(^"|"$)/g, "'");
3516
+ name = ctx.stylize(name, 'string');
3517
+ }
3518
+ }
3519
+
3520
+ return name + ': ' + str;
3521
+ }
3522
+
3523
+
3524
+ function reduceToSingleString(output, base, braces) {
3525
+ var numLinesEst = 0;
3526
+ var length = output.reduce(function(prev, cur) {
3527
+ numLinesEst++;
3528
+ if (cur.indexOf('\n') >= 0) numLinesEst++;
3529
+ return prev + cur.length + 1;
3530
+ }, 0);
3531
+
3532
+ if (length > 60) {
3533
+ return braces[0] +
3534
+ (base === '' ? '' : base + '\n ') +
3535
+ ' ' +
3536
+ output.join(',\n ') +
3537
+ ' ' +
3538
+ braces[1];
3539
+ }
3540
+
3541
+ return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
3542
+ }
3543
+
3544
+ function isArray(ar) {
3545
+ return Array.isArray(ar) ||
3546
+ (typeof ar === 'object' && objectToString(ar) === '[object Array]');
3547
+ }
3548
+
3549
+ function isRegExp(re) {
3550
+ return typeof re === 'object' && objectToString(re) === '[object RegExp]';
3551
+ }
3552
+
3553
+ function isDate(d) {
3554
+ return typeof d === 'object' && objectToString(d) === '[object Date]';
3555
+ }
3556
+
3557
+ function isError(e) {
3558
+ return typeof e === 'object' && objectToString(e) === '[object Error]';
3559
+ }
3560
+
3561
+ function objectToString(o) {
3562
+ return Object.prototype.toString.call(o);
3563
+ }
3564
+
3565
+ }); // module: chai/utils/inspect.js
3566
+
3567
+ require.register("chai/utils/objDisplay.js", function(module, exports, require){
3568
+ /*!
3569
+ * Chai - flag utility
3570
+ * Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
3571
+ * MIT Licensed
3572
+ */
3573
+
3574
+ /*!
3575
+ * Module dependancies
3576
+ */
3577
+
3578
+ var inspect = require('./inspect');
3579
+
3580
+ /**
3581
+ * ### .objDisplay (object)
3582
+ *
3583
+ * Determines if an object or an array matches
3584
+ * criteria to be inspected in-line for error
3585
+ * messages or should be truncated.
3586
+ *
3587
+ * @param {Mixed} javascript object to inspect
3588
+ * @name objDisplay
3589
+ * @api public
3590
+ */
3591
+
3592
+ module.exports = function (obj) {
3593
+ var str = inspect(obj)
3594
+ , type = Object.prototype.toString.call(obj);
3595
+
3596
+ if (str.length >= 40) {
3597
+ if (type === '[object Array]') {
3598
+ return '[ Array(' + obj.length + ') ]';
3599
+ } else if (type === '[object Object]') {
3600
+ var keys = Object.keys(obj)
3601
+ , kstr = keys.length > 2
3602
+ ? keys.splice(0, 2).join(', ') + ', ...'
3603
+ : keys.join(', ');
3604
+ return '{ Object (' + kstr + ') }';
3605
+ } else {
3606
+ return str;
3607
+ }
3608
+ } else {
3609
+ return str;
3610
+ }
3611
+ };
3612
+
3613
+ }); // module: chai/utils/objDisplay.js
3614
+
3615
+ require.register("chai/utils/overwriteMethod.js", function(module, exports, require){
3616
+ /*!
3617
+ * Chai - overwriteMethod utility
3618
+ * Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
3619
+ * MIT Licensed
3620
+ */
3621
+
3622
+ /**
3623
+ * ### overwriteMethod (ctx, name, fn)
3624
+ *
3625
+ * Overwites an already existing method and provides
3626
+ * access to previous function. Must return function
3627
+ * to be used for name.
3628
+ *
3629
+ * utils.overwriteMethod(chai.Assertion.prototype, 'equal', function (_super) {
3630
+ * return function (str) {
3631
+ * var obj = utils.flag(this, 'object');
3632
+ * if (obj instanceof Foo) {
3633
+ * new chai.Assertion(obj.value).to.equal(str);
3634
+ * } else {
3635
+ * _super.apply(this, arguments);
3636
+ * }
3637
+ * }
3638
+ * });
3639
+ *
3640
+ * Can also be accessed directly from `chai.Assertion`.
3641
+ *
3642
+ * chai.Assertion.overwriteMethod('foo', fn);
3643
+ *
3644
+ * Then can be used as any other assertion.
3645
+ *
3646
+ * expect(myFoo).to.equal('bar');
3647
+ *
3648
+ * @param {Object} ctx object whose method is to be overwritten
3649
+ * @param {String} name of method to overwrite
3650
+ * @param {Function} method function that returns a function to be used for name
3651
+ * @name overwriteMethod
3652
+ * @api public
3653
+ */
3654
+
3655
+ module.exports = function (ctx, name, method) {
3656
+ var _method = ctx[name]
3657
+ , _super = function () { return this; };
3658
+
3659
+ if (_method && 'function' === typeof _method)
3660
+ _super = _method;
3661
+
3662
+ ctx[name] = function () {
3663
+ var result = method(_super).apply(this, arguments);
3664
+ return result === undefined ? this : result;
3665
+ }
3666
+ };
3667
+
3668
+ }); // module: chai/utils/overwriteMethod.js
3669
+
3670
+ require.register("chai/utils/overwriteProperty.js", function(module, exports, require){
3671
+ /*!
3672
+ * Chai - overwriteProperty utility
3673
+ * Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
3674
+ * MIT Licensed
3675
+ */
3676
+
3677
+ /**
3678
+ * ### overwriteProperty (ctx, name, fn)
3679
+ *
3680
+ * Overwites an already existing property getter and provides
3681
+ * access to previous value. Must return function to use as getter.
3682
+ *
3683
+ * utils.overwriteProperty(chai.Assertion.prototype, 'ok', function (_super) {
3684
+ * return function () {
3685
+ * var obj = utils.flag(this, 'object');
3686
+ * if (obj instanceof Foo) {
3687
+ * new chai.Assertion(obj.name).to.equal('bar');
3688
+ * } else {
3689
+ * _super.call(this);
3690
+ * }
3691
+ * }
3692
+ * });
3693
+ *
3694
+ *
3695
+ * Can also be accessed directly from `chai.Assertion`.
3696
+ *
3697
+ * chai.Assertion.overwriteProperty('foo', fn);
3698
+ *
3699
+ * Then can be used as any other assertion.
3700
+ *
3701
+ * expect(myFoo).to.be.ok;
3702
+ *
3703
+ * @param {Object} ctx object whose property is to be overwritten
3704
+ * @param {String} name of property to overwrite
3705
+ * @param {Function} getter function that returns a getter function to be used for name
3706
+ * @name overwriteProperty
3707
+ * @api public
3708
+ */
3709
+
3710
+ module.exports = function (ctx, name, getter) {
3711
+ var _get = Object.getOwnPropertyDescriptor(ctx, name)
3712
+ , _super = function () {};
3713
+
3714
+ if (_get && 'function' === typeof _get.get)
3715
+ _super = _get.get
3716
+
3717
+ Object.defineProperty(ctx, name,
3718
+ { get: function () {
3719
+ var result = getter(_super).call(this);
3720
+ return result === undefined ? this : result;
3721
+ }
3722
+ , configurable: true
3723
+ });
3724
+ };
3725
+
3726
+ }); // module: chai/utils/overwriteProperty.js
3727
+
3728
+ require.register("chai/utils/test.js", function(module, exports, require){
3729
+ /*!
3730
+ * Chai - test utility
3731
+ * Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
3732
+ * MIT Licensed
3733
+ */
3734
+
3735
+ /*!
3736
+ * Module dependancies
3737
+ */
3738
+
3739
+ var flag = require('./flag');
3740
+
3741
+ /**
3742
+ * # test(object, expression)
3743
+ *
3744
+ * Test and object for expression.
3745
+ *
3746
+ * @param {Object} object (constructed Assertion)
3747
+ * @param {Arguments} chai.Assertion.prototype.assert arguments
3748
+ */
3749
+
3750
+ module.exports = function (obj, args) {
3751
+ var negate = flag(obj, 'negate')
3752
+ , expr = args[0];
3753
+ return negate ? !expr : expr;
3754
+ };
3755
+
3756
+ }); // module: chai/utils/test.js
3757
+
3758
+ require.register("chai/utils/transferFlags.js", function(module, exports, require){
3759
+ /*!
3760
+ * Chai - transferFlags utility
3761
+ * Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
3762
+ * MIT Licensed
3763
+ */
3764
+
3765
+ /**
3766
+ * ### transferFlags(assertion, object, includeAll = true)
3767
+ *
3768
+ * Transfer all the flags for `assertion` to `object`. If
3769
+ * `includeAll` is set to `false`, then the base Chai
3770
+ * assertion flags (namely `object`, `ssfi`, and `message`)
3771
+ * will not be transferred.
3772
+ *
3773
+ *
3774
+ * var newAssertion = new Assertion();
3775
+ * utils.transferFlags(assertion, newAssertion);
3776
+ *
3777
+ * var anotherAsseriton = new Assertion(myObj);
3778
+ * utils.transferFlags(assertion, anotherAssertion, false);
3779
+ *
3780
+ * @param {Assertion} assertion the assertion to transfer the flags from
3781
+ * @param {Object} object the object to transfer the flags too; usually a new assertion
3782
+ * @param {Boolean} includeAll
3783
+ * @name getAllFlags
3784
+ * @api private
3785
+ */
3786
+
3787
+ module.exports = function (assertion, object, includeAll) {
3788
+ var flags = assertion.__flags || (assertion.__flags = Object.create(null));
3789
+
3790
+ if (!object.__flags) {
3791
+ object.__flags = Object.create(null);
3792
+ }
3793
+
3794
+ includeAll = arguments.length === 3 ? includeAll : true;
3795
+
3796
+ for (var flag in flags) {
3797
+ if (includeAll ||
3798
+ (flag !== 'object' && flag !== 'ssfi' && flag != 'message')) {
3799
+ object.__flags[flag] = flags[flag];
3800
+ }
3801
+ }
3802
+ };
3803
+
3804
+ }); // module: chai/utils/transferFlags.js
3805
+
3806
+ require.alias("./chai.js", "chai");
3807
+
3808
+ return require('chai');
3809
+ });