multi_mocha_rails 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. data/MIT-LICENSE +22 -0
  2. data/Rakefile +38 -0
  3. data/Readme.md +7 -0
  4. data/app/assets/javascripts/mocha_rails/application.js +4 -0
  5. data/app/assets/javascripts/mocha_rails/mocha-rails.js +7 -0
  6. data/app/assets/stylesheets/mocha_rails/application.css +13 -0
  7. data/app/controllers/mocha_rails/application_controller.rb +4 -0
  8. data/app/controllers/mocha_rails/tests_controller.rb +52 -0
  9. data/app/helpers/mocha_rails/application_helper.rb +4 -0
  10. data/app/views/layouts/mocha.html.erb +14 -0
  11. data/app/views/mocha_rails/tests/index.html.erb +10 -0
  12. data/app/views/mocha_rails/tests/list.html.erb +11 -0
  13. data/config/initializers/mocha_rails.rb +4 -0
  14. data/config/routes.rb +8 -0
  15. data/lib/generators/mocha_rails/install_generator.rb +15 -0
  16. data/lib/generators/mocha_rails/templates/mocha-suite.js +12 -0
  17. data/lib/mocha_rails.rb +4 -0
  18. data/lib/mocha_rails/engine.rb +5 -0
  19. data/lib/mocha_rails/version.rb +3 -0
  20. data/lib/tasks/mocha_rails_tasks.rake +4 -0
  21. data/test/dummy/README.rdoc +261 -0
  22. data/test/dummy/Rakefile +7 -0
  23. data/test/dummy/app/assets/javascripts/application.js +15 -0
  24. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  25. data/test/dummy/app/controllers/application_controller.rb +3 -0
  26. data/test/dummy/app/helpers/application_helper.rb +2 -0
  27. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  28. data/test/dummy/config.ru +4 -0
  29. data/test/dummy/config/application.rb +62 -0
  30. data/test/dummy/config/boot.rb +10 -0
  31. data/test/dummy/config/environment.rb +5 -0
  32. data/test/dummy/config/environments/development.rb +31 -0
  33. data/test/dummy/config/environments/production.rb +64 -0
  34. data/test/dummy/config/environments/test.rb +35 -0
  35. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  36. data/test/dummy/config/initializers/inflections.rb +15 -0
  37. data/test/dummy/config/initializers/mime_types.rb +5 -0
  38. data/test/dummy/config/initializers/secret_token.rb +7 -0
  39. data/test/dummy/config/initializers/session_store.rb +8 -0
  40. data/test/dummy/config/initializers/wrap_parameters.rb +10 -0
  41. data/test/dummy/config/locales/en.yml +5 -0
  42. data/test/dummy/config/routes.rb +4 -0
  43. data/test/dummy/log/test.log +0 -0
  44. data/test/dummy/public/404.html +26 -0
  45. data/test/dummy/public/422.html +26 -0
  46. data/test/dummy/public/500.html +25 -0
  47. data/test/dummy/public/favicon.ico +0 -0
  48. data/test/dummy/script/rails +6 -0
  49. data/test/integration/navigation_test.rb +9 -0
  50. data/test/mocha_rails_test.rb +7 -0
  51. data/test/test_helper.rb +10 -0
  52. data/vendor/assets/javascripts/chai.js +2223 -0
  53. data/vendor/assets/javascripts/mocha.js +4068 -0
  54. data/vendor/assets/stylesheets/mocha.css +137 -0
  55. metadata +141 -0
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ class NavigationTest < ActionDispatch::IntegrationTest
4
+
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class MochaRailsTest < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, MochaRails
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
8
+
9
+ # Load support files
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
@@ -0,0 +1,2223 @@
1
+ !function (name, definition) {
2
+ if (typeof define == 'function' && typeof define.amd == 'object') define(definition);
3
+ else this[name] = definition();
4
+ }('chai', function () {
5
+
6
+ // CommonJS require()
7
+
8
+ function require(p){
9
+ var path = require.resolve(p)
10
+ , mod = require.modules[path];
11
+ if (!mod) throw new Error('failed to require "' + p + '"');
12
+ if (!mod.exports) {
13
+ mod.exports = {};
14
+ mod.call(mod.exports, mod, mod.exports, require.relative(path));
15
+ }
16
+ return mod.exports;
17
+ }
18
+
19
+ require.modules = {};
20
+
21
+ require.resolve = function (path){
22
+ var orig = path
23
+ , reg = path + '.js'
24
+ , index = path + '/index.js';
25
+ return require.modules[reg] && reg
26
+ || require.modules[index] && index
27
+ || orig;
28
+ };
29
+
30
+ require.register = function (path, fn){
31
+ require.modules[path] = fn;
32
+ };
33
+
34
+ require.relative = function (parent) {
35
+ return function(p){
36
+ if ('.' != p[0]) return require(p);
37
+
38
+ var path = parent.split('/')
39
+ , segs = p.split('/');
40
+ path.pop();
41
+
42
+ for (var i = 0; i < segs.length; i++) {
43
+ var seg = segs[i];
44
+ if ('..' == seg) path.pop();
45
+ else if ('.' != seg) path.push(seg);
46
+ }
47
+
48
+ return require(path.join('/'));
49
+ };
50
+ };
51
+
52
+
53
+ require.register("assertion.js", function(module, exports, require){
54
+ /*!
55
+ * chai
56
+ * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
57
+ * MIT Licensed
58
+ *
59
+ * Primarily a refactor of: should.js
60
+ * https://github.com/visionmedia/should.js
61
+ * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
62
+ * MIT Licensed
63
+ */
64
+
65
+ /**
66
+ * ### BDD Style Introduction
67
+ *
68
+ * The BDD style is exposed through `expect` or `should` interfaces. In both
69
+ * scenarios, you chain together natural language assertions.
70
+ *
71
+ * // expect
72
+ * var expect = require('chai').expect;
73
+ * expect(foo).to.equal('bar');
74
+ *
75
+ * // should
76
+ * var should = require('chai').should();
77
+ * foo.should.equal('bar');
78
+ *
79
+ * #### Differences
80
+ *
81
+ * The `expect` interface provides a function as a starting point for chaining
82
+ * your language assertions. It works on node.js and in all browsers.
83
+ *
84
+ * The `should` interface extends `Object.prototype` to provide a single getter as
85
+ * the starting point for your language assertions. It works on node.js and in
86
+ * all browsers except Internet Explorer.
87
+ *
88
+ * #### Configuration
89
+ *
90
+ * By default, Chai does not show stack traces upon an AssertionError. This can
91
+ * be changed by modifying the `includeStack` parameter for chai.Assertion. For example:
92
+ *
93
+ * var chai = require('chai');
94
+ * chai.Assertion.includeStack = true; // defaults to false
95
+ */
96
+
97
+ /*!
98
+ * Module dependencies.
99
+ */
100
+
101
+ var AssertionError = require('./error')
102
+ , eql = require('./utils/eql')
103
+ , toString = Object.prototype.toString
104
+ , inspect = require('./utils/inspect');
105
+
106
+ /*!
107
+ * Module export.
108
+ */
109
+
110
+ module.exports = Assertion;
111
+
112
+
113
+ /*!
114
+ * # Assertion Constructor
115
+ *
116
+ * Creates object for chaining.
117
+ *
118
+ * @api private
119
+ */
120
+
121
+ function Assertion (obj, msg, stack) {
122
+ this.ssfi = stack || arguments.callee;
123
+ this.obj = obj;
124
+ this.msg = msg;
125
+ }
126
+
127
+ /*!
128
+ * ## Assertion.includeStack
129
+ * , toString = Object.prototype.toString
130
+ *
131
+ * User configurable property, influences whether stack trace
132
+ * is included in Assertion error message. Default of false
133
+ * suppresses stack trace in the error message
134
+ *
135
+ * Assertion.includeStack = true; // enable stack on error
136
+ *
137
+ * @api public
138
+ */
139
+
140
+ Assertion.includeStack = false;
141
+
142
+ /*!
143
+ * # .assert(expression, message, negateMessage, expected, actual)
144
+ *
145
+ * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
146
+ *
147
+ * @name assert
148
+ * @param {Philosophical} expression to be tested
149
+ * @param {String} message to display if fails
150
+ * @param {String} negatedMessage to display if negated expression fails
151
+ * @param {*} expected value (remember to check for negation)
152
+ * @param {*} actual (optional) will default to `this.obj`
153
+ * @api private
154
+ */
155
+
156
+ Assertion.prototype.assert = function (expr, msg, negateMsg, expected, actual) {
157
+ actual = actual || this.obj;
158
+ var msg = (this.negate ? negateMsg : msg)
159
+ , ok = this.negate ? !expr : expr;
160
+
161
+ if (!ok) {
162
+ throw new AssertionError({
163
+ message: this.msg ? this.msg + ': ' + msg : msg // include custom message if available
164
+ , actual: actual
165
+ , expected: expected
166
+ , stackStartFunction: (Assertion.includeStack) ? this.assert : this.ssfi
167
+ });
168
+ }
169
+ };
170
+
171
+ /*!
172
+ * # inspect
173
+ *
174
+ * Returns the current object stringified.
175
+ *
176
+ * @name inspect
177
+ * @api private
178
+ */
179
+
180
+ Object.defineProperty(Assertion.prototype, 'inspect',
181
+ { get: function () {
182
+ return inspect(this.obj);
183
+ }
184
+ , configurable: true
185
+ });
186
+
187
+ /**
188
+ * # to
189
+ *
190
+ * Language chain.
191
+ *
192
+ * @name to
193
+ * @api public
194
+ */
195
+
196
+ Object.defineProperty(Assertion.prototype, 'to',
197
+ { get: function () {
198
+ return this;
199
+ }
200
+ , configurable: true
201
+ });
202
+
203
+ /**
204
+ * # be
205
+ *
206
+ * Language chain.
207
+ *
208
+ * @name be
209
+ * @api public
210
+ */
211
+
212
+ Object.defineProperty(Assertion.prototype, 'be',
213
+ { get: function () {
214
+ return this;
215
+ }
216
+ , configurable: true
217
+ });
218
+
219
+ /**
220
+ * # been
221
+ *
222
+ * Language chain. Also tests `tense` to past for addon
223
+ * modules that use the tense feature.
224
+ *
225
+ * @name been
226
+ * @api public
227
+ */
228
+
229
+ Object.defineProperty(Assertion.prototype, 'been',
230
+ { get: function () {
231
+ this.tense = 'past';
232
+ return this;
233
+ }
234
+ , configurable: true
235
+ });
236
+
237
+ /**
238
+ * # an
239
+ *
240
+ * Language chain.
241
+ *
242
+ * @name an
243
+ * @api public
244
+ */
245
+
246
+ Object.defineProperty(Assertion.prototype, 'an',
247
+ { get: function () {
248
+ return this;
249
+ }
250
+ , configurable: true
251
+ });
252
+ /**
253
+ * # is
254
+ *
255
+ * Language chain.
256
+ *
257
+ * @name is
258
+ * @api public
259
+ */
260
+
261
+ Object.defineProperty(Assertion.prototype, 'is',
262
+ { get: function () {
263
+ return this;
264
+ }
265
+ , configurable: true
266
+ });
267
+
268
+ /**
269
+ * # and
270
+ *
271
+ * Language chain.
272
+ *
273
+ * @name and
274
+ * @api public
275
+ */
276
+
277
+ Object.defineProperty(Assertion.prototype, 'and',
278
+ { get: function () {
279
+ return this;
280
+ }
281
+ , configurable: true
282
+ });
283
+
284
+ /**
285
+ * # have
286
+ *
287
+ * Language chain.
288
+ *
289
+ * @name have
290
+ * @api public
291
+ */
292
+
293
+ Object.defineProperty(Assertion.prototype, 'have',
294
+ { get: function () {
295
+ return this;
296
+ }
297
+ , configurable: true
298
+ });
299
+
300
+ /**
301
+ * # with
302
+ *
303
+ * Language chain.
304
+ *
305
+ * @name with
306
+ * @api public
307
+ */
308
+
309
+ Object.defineProperty(Assertion.prototype, 'with',
310
+ { get: function () {
311
+ return this;
312
+ }
313
+ , configurable: true
314
+ });
315
+
316
+ /**
317
+ * # .not
318
+ *
319
+ * Negates any of assertions following in the chain.
320
+ *
321
+ * @name not
322
+ * @api public
323
+ */
324
+
325
+ Object.defineProperty(Assertion.prototype, 'not',
326
+ { get: function () {
327
+ this.negate = true;
328
+ return this;
329
+ }
330
+ , configurable: true
331
+ });
332
+
333
+ /**
334
+ * # .ok
335
+ *
336
+ * Assert object truthiness.
337
+ *
338
+ * expect('everthing').to.be.ok;
339
+ * expect(false).to.not.be.ok;
340
+ * expect(undefined).to.not.be.ok;
341
+ * expect(null).to.not.be.ok;
342
+ *
343
+ * @name ok
344
+ * @api public
345
+ */
346
+
347
+ Object.defineProperty(Assertion.prototype, 'ok',
348
+ { get: function () {
349
+ this.assert(
350
+ this.obj
351
+ , 'expected ' + this.inspect + ' to be truthy'
352
+ , 'expected ' + this.inspect + ' to be falsy');
353
+
354
+ return this;
355
+ }
356
+ , configurable: true
357
+ });
358
+
359
+ /**
360
+ * # .true
361
+ *
362
+ * Assert object is true
363
+ *
364
+ * @name true
365
+ * @api public
366
+ */
367
+
368
+ Object.defineProperty(Assertion.prototype, 'true',
369
+ { get: function () {
370
+ this.assert(
371
+ true === this.obj
372
+ , 'expected ' + this.inspect + ' to be true'
373
+ , 'expected ' + this.inspect + ' to be false'
374
+ , this.negate ? false : true
375
+ );
376
+
377
+ return this;
378
+ }
379
+ , configurable: true
380
+ });
381
+
382
+ /**
383
+ * # .false
384
+ *
385
+ * Assert object is false
386
+ *
387
+ * @name false
388
+ * @api public
389
+ */
390
+
391
+ Object.defineProperty(Assertion.prototype, 'false',
392
+ { get: function () {
393
+ this.assert(
394
+ false === this.obj
395
+ , 'expected ' + this.inspect + ' to be false'
396
+ , 'expected ' + this.inspect + ' to be true'
397
+ , this.negate ? true : false
398
+ );
399
+
400
+ return this;
401
+ }
402
+ , configurable: true
403
+ });
404
+
405
+ /**
406
+ * # .exist
407
+ *
408
+ * Assert object exists (null).
409
+ *
410
+ * var foo = 'hi'
411
+ * , bar;
412
+ * expect(foo).to.exist;
413
+ * expect(bar).to.not.exist;
414
+ *
415
+ * @name exist
416
+ * @api public
417
+ */
418
+
419
+ Object.defineProperty(Assertion.prototype, 'exist',
420
+ { get: function () {
421
+ this.assert(
422
+ null != this.obj
423
+ , 'expected ' + this.inspect + ' to exist'
424
+ , 'expected ' + this.inspect + ' to not exist'
425
+ );
426
+
427
+ return this;
428
+ }
429
+ , configurable: true
430
+ });
431
+
432
+ /**
433
+ * # .empty
434
+ *
435
+ * Assert object's length to be 0.
436
+ *
437
+ * expect([]).to.be.empty;
438
+ *
439
+ * @name empty
440
+ * @api public
441
+ */
442
+
443
+ Object.defineProperty(Assertion.prototype, 'empty',
444
+ { get: function () {
445
+ var expected = this.obj;
446
+
447
+ if (Array.isArray(this.obj)) {
448
+ expected = this.obj.length;
449
+ } else if (typeof this.obj === 'object') {
450
+ expected = Object.keys(this.obj).length;
451
+ }
452
+
453
+ this.assert(
454
+ !expected
455
+ , 'expected ' + this.inspect + ' to be empty'
456
+ , 'expected ' + this.inspect + ' not to be empty');
457
+
458
+ return this;
459
+ }
460
+ , configurable: true
461
+ });
462
+
463
+ /**
464
+ * # .arguments
465
+ *
466
+ * Assert object is an instanceof arguments.
467
+ *
468
+ * function test () {
469
+ * expect(arguments).to.be.arguments;
470
+ * }
471
+ *
472
+ * @name arguments
473
+ * @api public
474
+ */
475
+
476
+ Object.defineProperty(Assertion.prototype, 'arguments',
477
+ { get: function () {
478
+ this.assert(
479
+ '[object Arguments]' == Object.prototype.toString.call(this.obj)
480
+ , 'expected ' + this.inspect + ' to be arguments'
481
+ , 'expected ' + this.inspect + ' to not be arguments'
482
+ , '[object Arguments]'
483
+ , Object.prototype.toString.call(this.obj)
484
+ );
485
+
486
+ return this;
487
+ }
488
+ , configurable: true
489
+ });
490
+
491
+ /**
492
+ * # .equal(value)
493
+ *
494
+ * Assert strict equality.
495
+ *
496
+ * expect('hello').to.equal('hello');
497
+ *
498
+ * @name equal
499
+ * @param {*} value
500
+ * @api public
501
+ */
502
+
503
+ Assertion.prototype.equal = function (val) {
504
+ this.assert(
505
+ val === this.obj
506
+ , 'expected ' + this.inspect + ' to equal ' + inspect(val)
507
+ , 'expected ' + this.inspect + ' to not equal ' + inspect(val)
508
+ , val );
509
+
510
+ return this;
511
+ };
512
+
513
+ /**
514
+ * # .eql(value)
515
+ *
516
+ * Assert deep equality.
517
+ *
518
+ * expect({ foo: 'bar' }).to.eql({ foo: 'bar' });
519
+ *
520
+ * @name eql
521
+ * @param {*} value
522
+ * @api public
523
+ */
524
+
525
+ Assertion.prototype.eql = function (obj) {
526
+ this.assert(
527
+ eql(obj, this.obj)
528
+ , 'expected ' + this.inspect + ' to equal ' + inspect(obj)
529
+ , 'expected ' + this.inspect + ' to not equal ' + inspect(obj)
530
+ , obj );
531
+
532
+ return this;
533
+ };
534
+
535
+ /**
536
+ * # .above(value)
537
+ *
538
+ * Assert greater than `value`.
539
+ *
540
+ * expect(10).to.be.above(5);
541
+ *
542
+ * @name above
543
+ * @param {Number} value
544
+ * @api public
545
+ */
546
+
547
+ Assertion.prototype.above = function (val) {
548
+ this.assert(
549
+ this.obj > val
550
+ , 'expected ' + this.inspect + ' to be above ' + val
551
+ , 'expected ' + this.inspect + ' to be below ' + val);
552
+
553
+ return this;
554
+ };
555
+
556
+ /**
557
+ * # .below(value)
558
+ *
559
+ * Assert less than `value`.
560
+ *
561
+ * expect(5).to.be.below(10);
562
+ *
563
+ * @name below
564
+ * @param {Number} value
565
+ * @api public
566
+ */
567
+
568
+ Assertion.prototype.below = function (val) {
569
+ this.assert(
570
+ this.obj < val
571
+ , 'expected ' + this.inspect + ' to be below ' + val
572
+ , 'expected ' + this.inspect + ' to be above ' + val);
573
+
574
+ return this;
575
+ };
576
+
577
+ /**
578
+ * # .within(start, finish)
579
+ *
580
+ * Assert that a number is within a range.
581
+ *
582
+ * expect(7).to.be.within(5,10);
583
+ *
584
+ * @name within
585
+ * @param {Number} start lowerbound inclusive
586
+ * @param {Number} finish upperbound inclusive
587
+ * @api public
588
+ */
589
+
590
+ Assertion.prototype.within = function (start, finish) {
591
+ var range = start + '..' + finish;
592
+
593
+ this.assert(
594
+ this.obj >= start && this.obj <= finish
595
+ , 'expected ' + this.inspect + ' to be within ' + range
596
+ , 'expected ' + this.inspect + ' to not be within ' + range);
597
+
598
+ return this;
599
+ };
600
+
601
+ /**
602
+ * # .a(type)
603
+ *
604
+ * Assert typeof.
605
+ *
606
+ * expect('test').to.be.a('string');
607
+ *
608
+ * @name a
609
+ * @param {String} type
610
+ * @api public
611
+ */
612
+
613
+ Assertion.prototype.a = function (type) {
614
+ var klass = type.charAt(0).toUpperCase() + type.slice(1);
615
+
616
+ this.assert(
617
+ '[object ' + klass + ']' === toString.call(this.obj)
618
+ , 'expected ' + this.inspect + ' to be a ' + type
619
+ , 'expected ' + this.inspect + ' not to be a ' + type
620
+ , '[object ' + klass + ']'
621
+ , toString.call(this.obj)
622
+ );
623
+
624
+ return this;
625
+ };
626
+
627
+ /**
628
+ * # .instanceof(constructor)
629
+ *
630
+ * Assert instanceof.
631
+ *
632
+ * var Tea = function (name) { this.name = name; }
633
+ * , Chai = new Tea('chai');
634
+ *
635
+ * expect(Chai).to.be.an.instanceOf(Tea);
636
+ *
637
+ * @name instanceof
638
+ * @param {Constructor}
639
+ * @alias instanceOf
640
+ * @api public
641
+ */
642
+
643
+ Assertion.prototype.instanceof = function (constructor) {
644
+ var name = constructor.name;
645
+ this.assert(
646
+ this.obj instanceof constructor
647
+ , 'expected ' + this.inspect + ' to be an instance of ' + name
648
+ , 'expected ' + this.inspect + ' to not be an instance of ' + name);
649
+
650
+ return this;
651
+ };
652
+
653
+ /**
654
+ * # .property(name, [value])
655
+ *
656
+ * Assert that property of `name` exists, optionally with `value`.
657
+ *
658
+ * var obj = { foo: 'bar' }
659
+ * expect(obj).to.have.property('foo');
660
+ * expect(obj).to.have.property('foo', 'bar');
661
+ * expect(obj).to.have.property('foo').to.be.a('string');
662
+ *
663
+ * @name property
664
+ * @param {String} name
665
+ * @param {*} value (optional)
666
+ * @returns value of property for chaining
667
+ * @api public
668
+ */
669
+
670
+ Assertion.prototype.property = function (name, val) {
671
+ if (this.negate && undefined !== val) {
672
+ if (undefined === this.obj[name]) {
673
+ throw new Error(this.inspect + ' has no property ' + inspect(name));
674
+ }
675
+ } else {
676
+ this.assert(
677
+ undefined !== this.obj[name]
678
+ , 'expected ' + this.inspect + ' to have a property ' + inspect(name)
679
+ , 'expected ' + this.inspect + ' to not have property ' + inspect(name));
680
+ }
681
+
682
+ if (undefined !== val) {
683
+ this.assert(
684
+ val === this.obj[name]
685
+ , 'expected ' + this.inspect + ' to have a property ' + inspect(name) + ' of ' +
686
+ inspect(val) + ', but got ' + inspect(this.obj[name])
687
+ , 'expected ' + this.inspect + ' to not have a property ' + inspect(name) + ' of ' + inspect(val)
688
+ , val
689
+ , this.obj[val]
690
+ );
691
+ }
692
+
693
+ this.obj = this.obj[name];
694
+ return this;
695
+ };
696
+
697
+ /**
698
+ * # .ownProperty(name)
699
+ *
700
+ * Assert that has own property by `name`.
701
+ *
702
+ * expect('test').to.have.ownProperty('length');
703
+ *
704
+ * @name ownProperty
705
+ * @alias haveOwnProperty
706
+ * @param {String} name
707
+ * @api public
708
+ */
709
+
710
+ Assertion.prototype.ownProperty = function (name) {
711
+ this.assert(
712
+ this.obj.hasOwnProperty(name)
713
+ , 'expected ' + this.inspect + ' to have own property ' + inspect(name)
714
+ , 'expected ' + this.inspect + ' to not have own property ' + inspect(name));
715
+ return this;
716
+ };
717
+
718
+ /**
719
+ * # .length(val)
720
+ *
721
+ * Assert that object has expected length.
722
+ *
723
+ * expect([1,2,3]).to.have.length(3);
724
+ * expect('foobar').to.have.length(6);
725
+ *
726
+ * @name length
727
+ * @alias lengthOf
728
+ * @param {Number} length
729
+ * @api public
730
+ */
731
+
732
+ Assertion.prototype.length = function (n) {
733
+ new Assertion(this.obj).to.have.property('length');
734
+ var len = this.obj.length;
735
+
736
+ this.assert(
737
+ len == n
738
+ , 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len
739
+ , 'expected ' + this.inspect + ' to not have a length of ' + len
740
+ , n
741
+ , len
742
+ );
743
+
744
+ return this;
745
+ };
746
+
747
+ /**
748
+ * # .match(regexp)
749
+ *
750
+ * Assert that matches regular expression.
751
+ *
752
+ * expect('foobar').to.match(/^foo/);
753
+ *
754
+ * @name match
755
+ * @param {RegExp} RegularExpression
756
+ * @api public
757
+ */
758
+
759
+ Assertion.prototype.match = function (re) {
760
+ this.assert(
761
+ re.exec(this.obj)
762
+ , 'expected ' + this.inspect + ' to match ' + re
763
+ , 'expected ' + this.inspect + ' not to match ' + re);
764
+
765
+ return this;
766
+ };
767
+
768
+ /**
769
+ * # .include(obj)
770
+ *
771
+ * Assert the inclusion of an object in an Array or substring in string.
772
+ *
773
+ * expect([1,2,3]).to.include(2);
774
+ *
775
+ * @name include
776
+ * @param {Object|String|Number} obj
777
+ * @api public
778
+ */
779
+
780
+ Assertion.prototype.include = function (obj) {
781
+ this.assert(
782
+ ~this.obj.indexOf(obj)
783
+ , 'expected ' + this.inspect + ' to include ' + inspect(obj)
784
+ , 'expected ' + this.inspect + ' to not include ' + inspect(obj));
785
+
786
+ return this;
787
+ };
788
+
789
+ /**
790
+ * # .string(string)
791
+ *
792
+ * Assert inclusion of string in string.
793
+ *
794
+ * expect('foobar').to.have.string('bar');
795
+ *
796
+ * @name string
797
+ * @param {String} string
798
+ * @api public
799
+ */
800
+
801
+ Assertion.prototype.string = function (str) {
802
+ new Assertion(this.obj).is.a('string');
803
+
804
+ this.assert(
805
+ ~this.obj.indexOf(str)
806
+ , 'expected ' + this.inspect + ' to contain ' + inspect(str)
807
+ , 'expected ' + this.inspect + ' to not contain ' + inspect(str));
808
+
809
+ return this;
810
+ };
811
+
812
+
813
+
814
+ /**
815
+ * # contain
816
+ *
817
+ * Toggles the `contain` flag for the `keys` assertion.
818
+ *
819
+ * @name contain
820
+ * @api public
821
+ */
822
+
823
+ Object.defineProperty(Assertion.prototype, 'contain',
824
+ { get: function () {
825
+ this.contains = true;
826
+ return this;
827
+ },
828
+ configurable: true
829
+ });
830
+
831
+ /**
832
+ * # .keys(key1, [key2], [...])
833
+ *
834
+ * Assert exact keys or the inclusing of keys using the `contain` modifier.
835
+ *
836
+ * expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']);
837
+ * expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar');
838
+ *
839
+ * @name keys
840
+ * @alias key
841
+ * @param {String|Array} Keys
842
+ * @api public
843
+ */
844
+
845
+ Assertion.prototype.keys = function(keys) {
846
+ var str
847
+ , ok = true;
848
+
849
+ keys = keys instanceof Array
850
+ ? keys
851
+ : Array.prototype.slice.call(arguments);
852
+
853
+ if (!keys.length) throw new Error('keys required');
854
+
855
+ var actual = Object.keys(this.obj)
856
+ , len = keys.length;
857
+
858
+ // Inclusion
859
+ ok = keys.every(function(key){
860
+ return ~actual.indexOf(key);
861
+ });
862
+
863
+ // Strict
864
+ if (!this.negate && !this.contains) {
865
+ ok = ok && keys.length == actual.length;
866
+ }
867
+
868
+ // Key string
869
+ if (len > 1) {
870
+ keys = keys.map(function(key){
871
+ return inspect(key);
872
+ });
873
+ var last = keys.pop();
874
+ str = keys.join(', ') + ', and ' + last;
875
+ } else {
876
+ str = inspect(keys[0]);
877
+ }
878
+
879
+ // Form
880
+ str = (len > 1 ? 'keys ' : 'key ') + str;
881
+
882
+ // Have / include
883
+ str = (this.contains ? 'contain ' : 'have ') + str;
884
+
885
+ // Assertion
886
+ this.assert(
887
+ ok
888
+ , 'expected ' + this.inspect + ' to ' + str
889
+ , 'expected ' + this.inspect + ' to not ' + str
890
+ , keys
891
+ , Object.keys(this.obj)
892
+ );
893
+
894
+ return this;
895
+ }
896
+
897
+ /**
898
+ * # .throw(constructor)
899
+ *
900
+ * Assert that a function will throw a specific type of error or that error
901
+ * thrown will match a RegExp or include a string.
902
+ *
903
+ * var fn = function () { throw new ReferenceError('This is a bad function.'); }
904
+ * expect(fn).to.throw(ReferenceError);
905
+ * expect(fn).to.throw(/bad function/);
906
+ * expect(fn).to.not.throw('good function');
907
+ * expect(fn).to.throw(ReferenceError, /bad function/);
908
+ *
909
+ * Please note that when a throw expectation is negated, it will check each
910
+ * parameter independently, starting with Error constructor type. The appropriate way
911
+ * to check for the existence of a type of error but for a message that does not match
912
+ * is to use `and`.
913
+ *
914
+ * expect(fn).to.throw(ReferenceError).and.not.throw(/good function/);
915
+ *
916
+ * @name throw
917
+ * @alias throws
918
+ * @alias Throw
919
+ * @param {ErrorConstructor} constructor
920
+ * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
921
+ * @api public
922
+ */
923
+
924
+ Assertion.prototype.throw = function (constructor, msg) {
925
+ new Assertion(this.obj).is.a('function');
926
+
927
+ var thrown = false;
928
+
929
+ if (arguments.length === 0) {
930
+ msg = null;
931
+ constructor = null;
932
+ } else if (constructor && (constructor instanceof RegExp || 'string' === typeof constructor)) {
933
+ msg = constructor;
934
+ constructor = null;
935
+ }
936
+
937
+ try {
938
+ this.obj();
939
+ } catch (err) {
940
+ // first, check constructor
941
+ if (constructor && 'function' === typeof constructor) {
942
+ this.assert(
943
+ err instanceof constructor && err.name == constructor.name
944
+ , 'expected ' + this.inspect + ' to throw ' + constructor.name + ' but a ' + err.name + ' was thrown'
945
+ , 'expected ' + this.inspect + ' to not throw ' + constructor.name );
946
+ if (!msg) return this;
947
+ }
948
+ // next, check message
949
+ if (err.message && msg && msg instanceof RegExp) {
950
+ this.assert(
951
+ msg.exec(err.message)
952
+ , 'expected ' + this.inspect + ' to throw error matching ' + msg + ' but got ' + inspect(err.message)
953
+ , 'expected ' + this.inspect + ' to throw error not matching ' + msg
954
+ );
955
+ return this;
956
+ } else if (err.message && msg && 'string' === typeof msg) {
957
+ this.assert(
958
+ ~err.message.indexOf(msg)
959
+ , 'expected ' + this.inspect + ' to throw error including ' + inspect(msg) + ' but got ' + inspect(err.message)
960
+ , 'expected ' + this.inspect + ' to throw error not including ' + inspect(msg)
961
+ );
962
+ return this;
963
+ } else {
964
+ thrown = true;
965
+ }
966
+ }
967
+
968
+ var name = (constructor ? constructor.name : 'an error');
969
+
970
+ this.assert(
971
+ thrown === true
972
+ , 'expected ' + this.inspect + ' to throw ' + name
973
+ , 'expected ' + this.inspect + ' to not throw ' + name);
974
+
975
+ return this;
976
+ };
977
+
978
+ /**
979
+ * # .respondTo(method)
980
+ *
981
+ * Assert that object/class will respond to a method.
982
+ *
983
+ * expect(Klass).to.respondTo('bar');
984
+ * expect(obj).to.respondTo('bar');
985
+ *
986
+ * @name respondTo
987
+ * @param {String} method
988
+ * @api public
989
+ */
990
+
991
+ Assertion.prototype.respondTo = function (method) {
992
+ var context = ('function' === typeof this.obj)
993
+ ? this.obj.prototype[method]
994
+ : this.obj[method];
995
+
996
+ this.assert(
997
+ 'function' === typeof context
998
+ , 'expected ' + this.inspect + ' to respond to ' + inspect(method)
999
+ , 'expected ' + this.inspect + ' to not respond to ' + inspect(method)
1000
+ , 'function'
1001
+ , typeof context
1002
+ );
1003
+
1004
+ return this;
1005
+ };
1006
+
1007
+ /**
1008
+ * # .satisfy(method)
1009
+ *
1010
+ * Assert that passes a truth test.
1011
+ *
1012
+ * expect(1).to.satisfy(function(num) { return num > 0; });
1013
+ *
1014
+ * @name satisfy
1015
+ * @param {Function} matcher
1016
+ * @api public
1017
+ */
1018
+
1019
+ Assertion.prototype.satisfy = function (matcher) {
1020
+ this.assert(
1021
+ matcher(this.obj)
1022
+ , 'expected ' + this.inspect + ' to satisfy ' + inspect(matcher)
1023
+ , 'expected ' + this.inspect + ' to not satisfy' + inspect(matcher)
1024
+ , this.negate ? false : true
1025
+ , matcher(this.obj)
1026
+ );
1027
+
1028
+ return this;
1029
+ };
1030
+
1031
+ /**
1032
+ * # .closeTo(expected, delta)
1033
+ *
1034
+ * Assert that actual is equal to +/- delta.
1035
+ *
1036
+ * expect(1.5).to.be.closeTo(1, 0.5);
1037
+ *
1038
+ * @name closeTo
1039
+ * @param {Number} expected
1040
+ * @param {Number} delta
1041
+ * @api public
1042
+ */
1043
+
1044
+ Assertion.prototype.closeTo = function (expected, delta) {
1045
+ this.assert(
1046
+ (this.obj - delta === expected) || (this.obj + delta === expected)
1047
+ , 'expected ' + this.inspect + ' to be close to ' + expected + ' +/- ' + delta
1048
+ , 'expected ' + this.inspect + ' not to be close to ' + expected + ' +/- ' + delta);
1049
+
1050
+ return this;
1051
+ };
1052
+
1053
+ /*!
1054
+ * Aliases.
1055
+ */
1056
+
1057
+ (function alias(name, as){
1058
+ Assertion.prototype[as] = Assertion.prototype[name];
1059
+ return alias;
1060
+ })
1061
+ ('length', 'lengthOf')
1062
+ ('keys', 'key')
1063
+ ('ownProperty', 'haveOwnProperty')
1064
+ ('above', 'greaterThan')
1065
+ ('below', 'lessThan')
1066
+ ('throw', 'throws')
1067
+ ('throw', 'Throw') // for troublesome browsers
1068
+ ('instanceof', 'instanceOf');
1069
+
1070
+ }); // module: assertion.js
1071
+
1072
+ require.register("chai.js", function(module, exports, require){
1073
+ /*!
1074
+ * chai
1075
+ * Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>
1076
+ * MIT Licensed
1077
+ */
1078
+
1079
+ var used = [];
1080
+ var exports = module.exports = {};
1081
+
1082
+ exports.version = '0.5.2';
1083
+
1084
+ exports.Assertion = require('./assertion');
1085
+ exports.AssertionError = require('./error');
1086
+
1087
+ exports.inspect = require('./utils/inspect');
1088
+
1089
+ exports.use = function (fn) {
1090
+ if (!~used.indexOf(fn)) {
1091
+ fn(this);
1092
+ used.push(fn);
1093
+ }
1094
+
1095
+ return this;
1096
+ };
1097
+
1098
+ var expect = require('./interface/expect');
1099
+ exports.use(expect);
1100
+
1101
+ var should = require('./interface/should');
1102
+ exports.use(should);
1103
+
1104
+ var assert = require('./interface/assert');
1105
+ exports.use(assert);
1106
+
1107
+ }); // module: chai.js
1108
+
1109
+ require.register("error.js", function(module, exports, require){
1110
+ /*!
1111
+ * chai
1112
+ * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
1113
+ * MIT Licensed
1114
+ */
1115
+
1116
+ var fail = require('./chai').fail;
1117
+
1118
+ module.exports = AssertionError;
1119
+
1120
+ /*!
1121
+ * Inspired by node.js assert module
1122
+ * https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/assert.js
1123
+ */
1124
+ function AssertionError (options) {
1125
+ options = options || {};
1126
+ this.name = 'AssertionError';
1127
+ this.message = options.message;
1128
+ this.actual = options.actual;
1129
+ this.expected = options.expected;
1130
+ this.operator = options.operator;
1131
+ var stackStartFunction = options.stackStartFunction || fail;
1132
+
1133
+ if (Error.captureStackTrace) {
1134
+ Error.captureStackTrace(this, stackStartFunction);
1135
+ }
1136
+ }
1137
+
1138
+ AssertionError.prototype.__proto__ = Error.prototype;
1139
+
1140
+ AssertionError.prototype.toString = function() {
1141
+ return this.message;
1142
+ };
1143
+
1144
+ }); // module: error.js
1145
+
1146
+ require.register("interface/assert.js", function(module, exports, require){
1147
+ /*!
1148
+ * chai
1149
+ * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
1150
+ * MIT Licensed
1151
+ */
1152
+
1153
+ /**
1154
+ * ### TDD Style Introduction
1155
+ *
1156
+ * The TDD style is exposed through `assert` interfaces. This provides
1157
+ * the classic assert.`test` notation, similiar to that packaged with
1158
+ * node.js. This assert module, however, provides several additional
1159
+ * tests and is browser compatible.
1160
+ *
1161
+ * // assert
1162
+ * var assert = require('chai').assert;
1163
+ * , foo = 'bar';
1164
+ *
1165
+ * assert.typeOf(foo, 'string');
1166
+ * assert.equal(foo, 'bar');
1167
+ *
1168
+ * #### Configuration
1169
+ *
1170
+ * By default, Chai does not show stack traces upon an AssertionError. This can
1171
+ * be changed by modifying the `includeStack` parameter for chai.Assertion. For example:
1172
+ *
1173
+ * var chai = require('chai');
1174
+ * chai.Assertion.includeStack = true; // defaults to false
1175
+ */
1176
+
1177
+ module.exports = function (chai) {
1178
+ /*!
1179
+ * Chai dependencies.
1180
+ */
1181
+ var Assertion = chai.Assertion
1182
+ , inspect = chai.inspect;
1183
+
1184
+ /*!
1185
+ * Module export.
1186
+ */
1187
+
1188
+ var assert = chai.assert = {};
1189
+
1190
+ /**
1191
+ * # .fail(actual, expect, msg, operator)
1192
+ *
1193
+ * Throw a failure. Node.js compatible.
1194
+ *
1195
+ * @name fail
1196
+ * @param {*} actual value
1197
+ * @param {*} expected value
1198
+ * @param {String} message
1199
+ * @param {String} operator
1200
+ * @api public
1201
+ */
1202
+
1203
+ assert.fail = function (actual, expected, message, operator) {
1204
+ throw new chai.AssertionError({
1205
+ actual: actual
1206
+ , expected: expected
1207
+ , message: message
1208
+ , operator: operator
1209
+ , stackStartFunction: assert.fail
1210
+ });
1211
+ }
1212
+
1213
+ /**
1214
+ * # .ok(object, [message])
1215
+ *
1216
+ * Assert object is truthy.
1217
+ *
1218
+ * assert.ok('everthing', 'everything is ok');
1219
+ * assert.ok(false, 'this will fail');
1220
+ *
1221
+ * @name ok
1222
+ * @param {*} object to test
1223
+ * @param {String} message
1224
+ * @api public
1225
+ */
1226
+
1227
+ assert.ok = function (val, msg) {
1228
+ new Assertion(val, msg).is.ok;
1229
+ };
1230
+
1231
+ /**
1232
+ * # .equal(actual, expected, [message])
1233
+ *
1234
+ * Assert strict equality.
1235
+ *
1236
+ * assert.equal(3, 3, 'these numbers are equal');
1237
+ *
1238
+ * @name equal
1239
+ * @param {*} actual
1240
+ * @param {*} expected
1241
+ * @param {String} message
1242
+ * @api public
1243
+ */
1244
+
1245
+ assert.equal = function (act, exp, msg) {
1246
+ var test = new Assertion(act, msg);
1247
+
1248
+ test.assert(
1249
+ exp == test.obj
1250
+ , 'expected ' + test.inspect + ' to equal ' + inspect(exp)
1251
+ , 'expected ' + test.inspect + ' to not equal ' + inspect(exp));
1252
+ };
1253
+
1254
+ /**
1255
+ * # .notEqual(actual, expected, [message])
1256
+ *
1257
+ * Assert not equal.
1258
+ *
1259
+ * assert.notEqual(3, 4, 'these numbers are not equal');
1260
+ *
1261
+ * @name notEqual
1262
+ * @param {*} actual
1263
+ * @param {*} expected
1264
+ * @param {String} message
1265
+ * @api public
1266
+ */
1267
+
1268
+ assert.notEqual = function (act, exp, msg) {
1269
+ var test = new Assertion(act, msg);
1270
+
1271
+ test.assert(
1272
+ exp != test.obj
1273
+ , 'expected ' + test.inspect + ' to equal ' + inspect(exp)
1274
+ , 'expected ' + test.inspect + ' to not equal ' + inspect(exp));
1275
+ };
1276
+
1277
+ /**
1278
+ * # .strictEqual(actual, expected, [message])
1279
+ *
1280
+ * Assert strict equality.
1281
+ *
1282
+ * assert.strictEqual(true, true, 'these booleans are strictly equal');
1283
+ *
1284
+ * @name strictEqual
1285
+ * @param {*} actual
1286
+ * @param {*} expected
1287
+ * @param {String} message
1288
+ * @api public
1289
+ */
1290
+
1291
+ assert.strictEqual = function (act, exp, msg) {
1292
+ new Assertion(act, msg).to.equal(exp);
1293
+ };
1294
+
1295
+ /**
1296
+ * # .notStrictEqual(actual, expected, [message])
1297
+ *
1298
+ * Assert strict equality.
1299
+ *
1300
+ * assert.notStrictEqual(1, true, 'these booleans are not strictly equal');
1301
+ *
1302
+ * @name notStrictEqual
1303
+ * @param {*} actual
1304
+ * @param {*} expected
1305
+ * @param {String} message
1306
+ * @api public
1307
+ */
1308
+
1309
+ assert.notStrictEqual = function (act, exp, msg) {
1310
+ new Assertion(act, msg).to.not.equal(exp);
1311
+ };
1312
+
1313
+ /**
1314
+ * # .deepEqual(actual, expected, [message])
1315
+ *
1316
+ * Assert not deep equality.
1317
+ *
1318
+ * assert.deepEqual({ tea: 'green' }, { tea: 'green' });
1319
+ *
1320
+ * @name deepEqual
1321
+ * @param {*} actual
1322
+ * @param {*} expected
1323
+ * @param {String} message
1324
+ * @api public
1325
+ */
1326
+
1327
+ assert.deepEqual = function (act, exp, msg) {
1328
+ new Assertion(act, msg).to.eql(exp);
1329
+ };
1330
+
1331
+ /**
1332
+ * # .notDeepEqual(actual, expected, [message])
1333
+ *
1334
+ * Assert not deep equality.
1335
+ *
1336
+ * assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' });
1337
+ *
1338
+ * @name notDeepEqual
1339
+ * @param {*} actual
1340
+ * @param {*} expected
1341
+ * @param {String} message
1342
+ * @api public
1343
+ */
1344
+
1345
+ assert.notDeepEqual = function (act, exp, msg) {
1346
+ new Assertion(act, msg).to.not.eql(exp);
1347
+ };
1348
+
1349
+ /**
1350
+ * # .isTrue(value, [message])
1351
+ *
1352
+ * Assert `value` is true.
1353
+ *
1354
+ * var tea_served = true;
1355
+ * assert.isTrue(tea_served, 'the tea has been served');
1356
+ *
1357
+ * @name isTrue
1358
+ * @param {Boolean} value
1359
+ * @param {String} message
1360
+ * @api public
1361
+ */
1362
+
1363
+ assert.isTrue = function (val, msg) {
1364
+ new Assertion(val, msg).is.true;
1365
+ };
1366
+
1367
+ /**
1368
+ * # .isFalse(value, [message])
1369
+ *
1370
+ * Assert `value` is false.
1371
+ *
1372
+ * var tea_served = false;
1373
+ * assert.isFalse(tea_served, 'no tea yet? hmm...');
1374
+ *
1375
+ * @name isFalse
1376
+ * @param {Boolean} value
1377
+ * @param {String} message
1378
+ * @api public
1379
+ */
1380
+
1381
+ assert.isFalse = function (val, msg) {
1382
+ new Assertion(val, msg).is.false;
1383
+ };
1384
+
1385
+ /**
1386
+ * # .isNull(value, [message])
1387
+ *
1388
+ * Assert `value` is null.
1389
+ *
1390
+ * assert.isNull(err, 'no errors');
1391
+ *
1392
+ * @name isNull
1393
+ * @param {*} value
1394
+ * @param {String} message
1395
+ * @api public
1396
+ */
1397
+
1398
+ assert.isNull = function (val, msg) {
1399
+ new Assertion(val, msg).to.equal(null);
1400
+ };
1401
+
1402
+ /**
1403
+ * # .isNotNull(value, [message])
1404
+ *
1405
+ * Assert `value` is not null.
1406
+ *
1407
+ * var tea = 'tasty chai';
1408
+ * assert.isNotNull(tea, 'great, time for tea!');
1409
+ *
1410
+ * @name isNotNull
1411
+ * @param {*} value
1412
+ * @param {String} message
1413
+ * @api public
1414
+ */
1415
+
1416
+ assert.isNotNull = function (val, msg) {
1417
+ new Assertion(val, msg).to.not.equal(null);
1418
+ };
1419
+
1420
+ /**
1421
+ * # .isUndefined(value, [message])
1422
+ *
1423
+ * Assert `value` is undefined.
1424
+ *
1425
+ * assert.isUndefined(tea, 'no tea defined');
1426
+ *
1427
+ * @name isUndefined
1428
+ * @param {*} value
1429
+ * @param {String} message
1430
+ * @api public
1431
+ */
1432
+
1433
+ assert.isUndefined = function (val, msg) {
1434
+ new Assertion(val, msg).to.equal(undefined);
1435
+ };
1436
+
1437
+ /**
1438
+ * # .isDefined(value, [message])
1439
+ *
1440
+ * Assert `value` is not undefined.
1441
+ *
1442
+ * var tea = 'cup of chai';
1443
+ * assert.isDefined(tea, 'no tea defined');
1444
+ *
1445
+ * @name isUndefined
1446
+ * @param {*} value
1447
+ * @param {String} message
1448
+ * @api public
1449
+ */
1450
+
1451
+ assert.isDefined = function (val, msg) {
1452
+ new Assertion(val, msg).to.not.equal(undefined);
1453
+ };
1454
+
1455
+ /**
1456
+ * # .isFunction(value, [message])
1457
+ *
1458
+ * Assert `value` is a function.
1459
+ *
1460
+ * var serve_tea = function () { return 'cup of tea'; };
1461
+ * assert.isFunction(serve_tea, 'great, we can have tea now');
1462
+ *
1463
+ * @name isFunction
1464
+ * @param {Function} value
1465
+ * @param {String} message
1466
+ * @api public
1467
+ */
1468
+
1469
+ assert.isFunction = function (val, msg) {
1470
+ new Assertion(val, msg).to.be.a('function');
1471
+ };
1472
+
1473
+ /**
1474
+ * # .isObject(value, [message])
1475
+ *
1476
+ * Assert `value` is an object.
1477
+ *
1478
+ * var selection = { name: 'Chai', serve: 'with spices' };
1479
+ * assert.isObject(selection, 'tea selection is an object');
1480
+ *
1481
+ * @name isObject
1482
+ * @param {Object} value
1483
+ * @param {String} message
1484
+ * @api public
1485
+ */
1486
+
1487
+ assert.isObject = function (val, msg) {
1488
+ new Assertion(val, msg).to.be.a('object');
1489
+ };
1490
+
1491
+ /**
1492
+ * # .isArray(value, [message])
1493
+ *
1494
+ * Assert `value` is an instance of Array.
1495
+ *
1496
+ * var menu = [ 'green', 'chai', 'oolong' ];
1497
+ * assert.isArray(menu, 'what kind of tea do we want?');
1498
+ *
1499
+ * @name isArray
1500
+ * @param {*} value
1501
+ * @param {String} message
1502
+ * @api public
1503
+ */
1504
+
1505
+ assert.isArray = function (val, msg) {
1506
+ new Assertion(val, msg).to.be.instanceof(Array);
1507
+ };
1508
+
1509
+ /**
1510
+ * # .isString(value, [message])
1511
+ *
1512
+ * Assert `value` is a string.
1513
+ *
1514
+ * var teaorder = 'chai';
1515
+ * assert.isString(tea_order, 'order placed');
1516
+ *
1517
+ * @name isString
1518
+ * @param {String} value
1519
+ * @param {String} message
1520
+ * @api public
1521
+ */
1522
+
1523
+ assert.isString = function (val, msg) {
1524
+ new Assertion(val, msg).to.be.a('string');
1525
+ };
1526
+
1527
+ /**
1528
+ * # .isNumber(value, [message])
1529
+ *
1530
+ * Assert `value` is a number
1531
+ *
1532
+ * var cups = 2;
1533
+ * assert.isNumber(cups, 'how many cups');
1534
+ *
1535
+ * @name isNumber
1536
+ * @param {Number} value
1537
+ * @param {String} message
1538
+ * @api public
1539
+ */
1540
+
1541
+ assert.isNumber = function (val, msg) {
1542
+ new Assertion(val, msg).to.be.a('number');
1543
+ };
1544
+
1545
+ /**
1546
+ * # .isBoolean(value, [message])
1547
+ *
1548
+ * Assert `value` is a boolean
1549
+ *
1550
+ * var teaready = true
1551
+ * , teaserved = false;
1552
+ *
1553
+ * assert.isBoolean(tea_ready, 'is the tea ready');
1554
+ * assert.isBoolean(tea_served, 'has tea been served');
1555
+ *
1556
+ * @name isBoolean
1557
+ * @param {*} value
1558
+ * @param {String} message
1559
+ * @api public
1560
+ */
1561
+
1562
+ assert.isBoolean = function (val, msg) {
1563
+ new Assertion(val, msg).to.be.a('boolean');
1564
+ };
1565
+
1566
+ /**
1567
+ * # .typeOf(value, name, [message])
1568
+ *
1569
+ * Assert typeof `value` is `name`.
1570
+ *
1571
+ * assert.typeOf('tea', 'string', 'we have a string');
1572
+ *
1573
+ * @name typeOf
1574
+ * @param {*} value
1575
+ * @param {String} typeof name
1576
+ * @param {String} message
1577
+ * @api public
1578
+ */
1579
+
1580
+ assert.typeOf = function (val, type, msg) {
1581
+ new Assertion(val, msg).to.be.a(type);
1582
+ };
1583
+
1584
+ /**
1585
+ * # .instanceOf(object, constructor, [message])
1586
+ *
1587
+ * Assert `value` is instanceof `constructor`.
1588
+ *
1589
+ * var Tea = function (name) { this.name = name; }
1590
+ * , Chai = new Tea('chai');
1591
+ *
1592
+ * assert.instanceOf(Chai, Tea, 'chai is an instance of tea');
1593
+ *
1594
+ * @name instanceOf
1595
+ * @param {Object} object
1596
+ * @param {Constructor} constructor
1597
+ * @param {String} message
1598
+ * @api public
1599
+ */
1600
+
1601
+ assert.instanceOf = function (val, type, msg) {
1602
+ new Assertion(val, msg).to.be.instanceof(type);
1603
+ };
1604
+
1605
+ /**
1606
+ * # .include(value, includes, [message])
1607
+ *
1608
+ * Assert the inclusion of an object in another. Works
1609
+ * for strings and arrays.
1610
+ *
1611
+ * assert.include('foobar', 'bar', 'foobar contains string `var`);
1612
+ * assert.include([ 1, 2, 3], 3, 'array contains value);
1613
+ *
1614
+ * @name include
1615
+ * @param {Array|String} value
1616
+ * @param {*} includes
1617
+ * @param {String} message
1618
+ * @api public
1619
+ */
1620
+
1621
+ assert.include = function (exp, inc, msg) {
1622
+ var obj = new Assertion(exp, msg);
1623
+
1624
+ if (Array.isArray(exp)) {
1625
+ obj.to.include(inc);
1626
+ } else if ('string' === typeof exp) {
1627
+ obj.to.contain.string(inc);
1628
+ }
1629
+ };
1630
+
1631
+ /**
1632
+ * # .match(value, regex, [message])
1633
+ *
1634
+ * Assert that `value` matches regular expression.
1635
+ *
1636
+ * assert.match('foobar', /^foo/, 'Regexp matches');
1637
+ *
1638
+ * @name match
1639
+ * @param {*} value
1640
+ * @param {RegExp} RegularExpression
1641
+ * @param {String} message
1642
+ * @api public
1643
+ */
1644
+
1645
+ assert.match = function (exp, re, msg) {
1646
+ new Assertion(exp, msg).to.match(re);
1647
+ };
1648
+
1649
+ /**
1650
+ * # .length(value, constructor, [message])
1651
+ *
1652
+ * Assert that object has expected length.
1653
+ *
1654
+ * assert.length([1,2,3], 3, 'Array has length of 3');
1655
+ * assert.length('foobar', 5, 'String has length of 6');
1656
+ *
1657
+ * @name length
1658
+ * @param {*} value
1659
+ * @param {Number} length
1660
+ * @param {String} message
1661
+ * @api public
1662
+ */
1663
+
1664
+ assert.length = function (exp, len, msg) {
1665
+ new Assertion(exp, msg).to.have.length(len);
1666
+ };
1667
+
1668
+ /**
1669
+ * # .throws(function, [constructor/regexp], [message])
1670
+ *
1671
+ * Assert that a function will throw a specific
1672
+ * type of error.
1673
+ *
1674
+ * assert.throw(fn, ReferenceError, 'function throw reference error');
1675
+ *
1676
+ * @name throws
1677
+ * @alias throw
1678
+ * @param {Function} function to test
1679
+ * @param {ErrorConstructor} constructor
1680
+ * @param {String} message
1681
+ * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
1682
+ * @api public
1683
+ */
1684
+
1685
+ assert.throws = function (fn, type, msg) {
1686
+ if ('string' === typeof type) {
1687
+ msg = type;
1688
+ type = null;
1689
+ }
1690
+
1691
+ new Assertion(fn, msg).to.throw(type);
1692
+ };
1693
+
1694
+ /**
1695
+ * # .doesNotThrow(function, [constructor/regexp], [message])
1696
+ *
1697
+ * Assert that a function will throw a specific
1698
+ * type of error.
1699
+ *
1700
+ * var fn = function (err) { if (err) throw Error(err) };
1701
+ * assert.doesNotThrow(fn, Error, 'function throw reference error');
1702
+ *
1703
+ * @name doesNotThrow
1704
+ * @param {Function} function to test
1705
+ * @param {ErrorConstructor} constructor
1706
+ * @param {String} message
1707
+ * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
1708
+ * @api public
1709
+ */
1710
+
1711
+ assert.doesNotThrow = function (fn, type, msg) {
1712
+ if ('string' === typeof type) {
1713
+ msg = type;
1714
+ type = null;
1715
+ }
1716
+
1717
+ new Assertion(fn, msg).to.not.throw(type);
1718
+ };
1719
+
1720
+ /**
1721
+ * # .operator(val, operator, val2, [message])
1722
+ *
1723
+ * Compare two values using operator.
1724
+ *
1725
+ * assert.operator(1, '<', 2, 'everything is ok');
1726
+ * assert.operator(1, '>', 2, 'this will fail');
1727
+ *
1728
+ * @name operator
1729
+ * @param {*} object to test
1730
+ * @param {String} operator
1731
+ * @param {*} second object
1732
+ * @param {String} message
1733
+ * @api public
1734
+ */
1735
+
1736
+ assert.operator = function (val, operator, val2, msg) {
1737
+ if (!~['==', '===', '>', '>=', '<', '<=', '!=', '!=='].indexOf(operator)) {
1738
+ throw new Error('Invalid operator "' + operator + '"');
1739
+ }
1740
+ var test = new Assertion(eval(val + operator + val2), msg);
1741
+ test.assert(
1742
+ true === test.obj
1743
+ , 'expected ' + inspect(val) + ' to be ' + operator + ' ' + inspect(val2)
1744
+ , 'expected ' + inspect(val) + ' to not be ' + operator + ' ' + inspect(val2) );
1745
+ };
1746
+
1747
+ /*!
1748
+ * Undocumented / untested
1749
+ */
1750
+
1751
+ assert.ifError = function (val, msg) {
1752
+ new Assertion(val, msg).to.not.be.ok;
1753
+ };
1754
+
1755
+ /*!
1756
+ * Aliases.
1757
+ */
1758
+
1759
+ (function alias(name, as){
1760
+ assert[as] = assert[name];
1761
+ return alias;
1762
+ })
1763
+ ('length', 'lengthOf')
1764
+ ('throws', 'throw');
1765
+ };
1766
+
1767
+ }); // module: interface/assert.js
1768
+
1769
+ require.register("interface/expect.js", function(module, exports, require){
1770
+ /*!
1771
+ * chai
1772
+ * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
1773
+ * MIT Licensed
1774
+ */
1775
+
1776
+ module.exports = function (chai) {
1777
+ chai.expect = function (val, message) {
1778
+ return new chai.Assertion(val, message);
1779
+ };
1780
+ };
1781
+
1782
+
1783
+ }); // module: interface/expect.js
1784
+
1785
+ require.register("interface/should.js", function(module, exports, require){
1786
+ /*!
1787
+ * chai
1788
+ * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
1789
+ * MIT Licensed
1790
+ */
1791
+
1792
+ module.exports = function (chai) {
1793
+ var Assertion = chai.Assertion;
1794
+
1795
+ chai.should = function () {
1796
+ // modify Object.prototype to have `should`
1797
+ Object.defineProperty(Object.prototype, 'should', {
1798
+ set: function(){},
1799
+ get: function(){
1800
+ if (this instanceof String || this instanceof Number) {
1801
+ return new Assertion(this.constructor(this));
1802
+ } else if (this instanceof Boolean) {
1803
+ return new Assertion(this == true);
1804
+ }
1805
+ return new Assertion(this);
1806
+ },
1807
+ configurable: true
1808
+ });
1809
+
1810
+ var should = {};
1811
+
1812
+ should.equal = function (val1, val2) {
1813
+ new Assertion(val1).to.equal(val2);
1814
+ };
1815
+
1816
+ should.throw = function (fn, errt, errs) {
1817
+ new Assertion(fn).to.throw(errt, errs);
1818
+ };
1819
+
1820
+ should.exist = function (val) {
1821
+ new Assertion(val).to.exist;
1822
+ }
1823
+
1824
+ // negation
1825
+ should.not = {}
1826
+
1827
+ should.not.equal = function (val1, val2) {
1828
+ new Assertion(val1).to.not.equal(val2);
1829
+ };
1830
+
1831
+ should.not.throw = function (fn, errt, errs) {
1832
+ new Assertion(fn).to.not.throw(errt, errs);
1833
+ };
1834
+
1835
+ should.not.exist = function (val) {
1836
+ new Assertion(val).to.not.exist;
1837
+ }
1838
+
1839
+ return should;
1840
+ };
1841
+ };
1842
+
1843
+ }); // module: interface/should.js
1844
+
1845
+ require.register("utils/eql.js", function(module, exports, require){
1846
+ // This is directly from Node.js assert
1847
+ // https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/assert.js
1848
+
1849
+
1850
+ module.exports = _deepEqual;
1851
+
1852
+ // For browser implementation
1853
+ if (!Buffer) {
1854
+ var Buffer = {
1855
+ isBuffer: function () {
1856
+ return false;
1857
+ }
1858
+ };
1859
+ }
1860
+
1861
+ function _deepEqual(actual, expected) {
1862
+ // 7.1. All identical values are equivalent, as determined by ===.
1863
+ if (actual === expected) {
1864
+ return true;
1865
+
1866
+ } else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) {
1867
+ if (actual.length != expected.length) return false;
1868
+
1869
+ for (var i = 0; i < actual.length; i++) {
1870
+ if (actual[i] !== expected[i]) return false;
1871
+ }
1872
+
1873
+ return true;
1874
+
1875
+ // 7.2. If the expected value is a Date object, the actual value is
1876
+ // equivalent if it is also a Date object that refers to the same time.
1877
+ } else if (actual instanceof Date && expected instanceof Date) {
1878
+ return actual.getTime() === expected.getTime();
1879
+
1880
+ // 7.3. Other pairs that do not both pass typeof value == 'object',
1881
+ // equivalence is determined by ==.
1882
+ } else if (typeof actual != 'object' && typeof expected != 'object') {
1883
+ return actual === expected;
1884
+
1885
+ // 7.4. For all other Object pairs, including Array objects, equivalence is
1886
+ // determined by having the same number of owned properties (as verified
1887
+ // with Object.prototype.hasOwnProperty.call), the same set of keys
1888
+ // (although not necessarily the same order), equivalent values for every
1889
+ // corresponding key, and an identical 'prototype' property. Note: this
1890
+ // accounts for both named and indexed properties on Arrays.
1891
+ } else {
1892
+ return objEquiv(actual, expected);
1893
+ }
1894
+ }
1895
+
1896
+ function isUndefinedOrNull(value) {
1897
+ return value === null || value === undefined;
1898
+ }
1899
+
1900
+ function isArguments(object) {
1901
+ return Object.prototype.toString.call(object) == '[object Arguments]';
1902
+ }
1903
+
1904
+ function objEquiv(a, b) {
1905
+ if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
1906
+ return false;
1907
+ // an identical 'prototype' property.
1908
+ if (a.prototype !== b.prototype) return false;
1909
+ //~~~I've managed to break Object.keys through screwy arguments passing.
1910
+ // Converting to array solves the problem.
1911
+ if (isArguments(a)) {
1912
+ if (!isArguments(b)) {
1913
+ return false;
1914
+ }
1915
+ a = pSlice.call(a);
1916
+ b = pSlice.call(b);
1917
+ return _deepEqual(a, b);
1918
+ }
1919
+ try {
1920
+ var ka = Object.keys(a),
1921
+ kb = Object.keys(b),
1922
+ key, i;
1923
+ } catch (e) {//happens when one is a string literal and the other isn't
1924
+ return false;
1925
+ }
1926
+ // having the same number of owned properties (keys incorporates
1927
+ // hasOwnProperty)
1928
+ if (ka.length != kb.length)
1929
+ return false;
1930
+ //the same set of keys (although not necessarily the same order),
1931
+ ka.sort();
1932
+ kb.sort();
1933
+ //~~~cheap key test
1934
+ for (i = ka.length - 1; i >= 0; i--) {
1935
+ if (ka[i] != kb[i])
1936
+ return false;
1937
+ }
1938
+ //equivalent values for every corresponding key, and
1939
+ //~~~possibly expensive deep test
1940
+ for (i = ka.length - 1; i >= 0; i--) {
1941
+ key = ka[i];
1942
+ if (!_deepEqual(a[key], b[key])) return false;
1943
+ }
1944
+ return true;
1945
+ }
1946
+ }); // module: utils/eql.js
1947
+
1948
+ require.register("utils/inspect.js", function(module, exports, require){
1949
+ // This is (almost) directly from Node.js utils
1950
+ // https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js
1951
+
1952
+ module.exports = inspect;
1953
+
1954
+ /**
1955
+ * Echos the value of a value. Trys to print the value out
1956
+ * in the best way possible given the different types.
1957
+ *
1958
+ * @param {Object} obj The object to print out.
1959
+ * @param {Boolean} showHidden Flag that shows hidden (not enumerable)
1960
+ * properties of objects.
1961
+ * @param {Number} depth Depth in which to descend in object. Default is 2.
1962
+ * @param {Boolean} colors Flag to turn on ANSI escape codes to color the
1963
+ * output. Default is false (no coloring).
1964
+ */
1965
+ function inspect(obj, showHidden, depth, colors) {
1966
+ var ctx = {
1967
+ showHidden: showHidden,
1968
+ seen: [],
1969
+ stylize: function (str) { return str; }
1970
+ };
1971
+ return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
1972
+ }
1973
+
1974
+ function formatValue(ctx, value, recurseTimes) {
1975
+ // Provide a hook for user-specified inspect functions.
1976
+ // Check that value is an object with an inspect function on it
1977
+ if (value && typeof value.inspect === 'function' &&
1978
+ // Filter out the util module, it's inspect function is special
1979
+ value.inspect !== exports.inspect &&
1980
+ // Also filter out any prototype objects using the circular check.
1981
+ !(value.constructor && value.constructor.prototype === value)) {
1982
+ return value.inspect(recurseTimes);
1983
+ }
1984
+
1985
+ // Primitive types cannot have properties
1986
+ var primitive = formatPrimitive(ctx, value);
1987
+ if (primitive) {
1988
+ return primitive;
1989
+ }
1990
+
1991
+ // Look up the keys of the object.
1992
+ var visibleKeys = Object.keys(value);
1993
+ var keys = ctx.showHidden ? Object.getOwnPropertyNames(value) : visibleKeys;
1994
+
1995
+ // Some type of object without properties can be shortcutted.
1996
+ if (keys.length === 0) {
1997
+ if (typeof value === 'function') {
1998
+ var name = value.name ? ': ' + value.name : '';
1999
+ return ctx.stylize('[Function' + name + ']', 'special');
2000
+ }
2001
+ if (isRegExp(value)) {
2002
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
2003
+ }
2004
+ if (isDate(value)) {
2005
+ return ctx.stylize(Date.prototype.toUTCString.call(value), 'date');
2006
+ }
2007
+ if (isError(value)) {
2008
+ return formatError(value);
2009
+ }
2010
+ }
2011
+
2012
+ var base = '', array = false, braces = ['{', '}'];
2013
+
2014
+ // Make Array say that they are Array
2015
+ if (isArray(value)) {
2016
+ array = true;
2017
+ braces = ['[', ']'];
2018
+ }
2019
+
2020
+ // Make functions say that they are functions
2021
+ if (typeof value === 'function') {
2022
+ var n = value.name ? ': ' + value.name : '';
2023
+ base = ' [Function' + n + ']';
2024
+ }
2025
+
2026
+ // Make RegExps say that they are RegExps
2027
+ if (isRegExp(value)) {
2028
+ base = ' ' + RegExp.prototype.toString.call(value);
2029
+ }
2030
+
2031
+ // Make dates with properties first say the date
2032
+ if (isDate(value)) {
2033
+ base = ' ' + Date.prototype.toUTCString.call(value);
2034
+ }
2035
+
2036
+ // Make error with message first say the error
2037
+ if (isError(value)) {
2038
+ base = ' ' + formatError(value);
2039
+ }
2040
+
2041
+ if (keys.length === 0 && (!array || value.length == 0)) {
2042
+ return braces[0] + base + braces[1];
2043
+ }
2044
+
2045
+ if (recurseTimes < 0) {
2046
+ if (isRegExp(value)) {
2047
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
2048
+ } else {
2049
+ return ctx.stylize('[Object]', 'special');
2050
+ }
2051
+ }
2052
+
2053
+ ctx.seen.push(value);
2054
+
2055
+ var output;
2056
+ if (array) {
2057
+ output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
2058
+ } else {
2059
+ output = keys.map(function(key) {
2060
+ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
2061
+ });
2062
+ }
2063
+
2064
+ ctx.seen.pop();
2065
+
2066
+ return reduceToSingleString(output, base, braces);
2067
+ }
2068
+
2069
+
2070
+ function formatPrimitive(ctx, value) {
2071
+ switch (typeof value) {
2072
+ case 'undefined':
2073
+ return ctx.stylize('undefined', 'undefined');
2074
+
2075
+ case 'string':
2076
+ var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
2077
+ .replace(/'/g, "\\'")
2078
+ .replace(/\\"/g, '"') + '\'';
2079
+ return ctx.stylize(simple, 'string');
2080
+
2081
+ case 'number':
2082
+ return ctx.stylize('' + value, 'number');
2083
+
2084
+ case 'boolean':
2085
+ return ctx.stylize('' + value, 'boolean');
2086
+ }
2087
+ // For some reason typeof null is "object", so special case here.
2088
+ if (value === null) {
2089
+ return ctx.stylize('null', 'null');
2090
+ }
2091
+ }
2092
+
2093
+
2094
+ function formatError(value) {
2095
+ return '[' + Error.prototype.toString.call(value) + ']';
2096
+ }
2097
+
2098
+
2099
+ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
2100
+ var output = [];
2101
+ for (var i = 0, l = value.length; i < l; ++i) {
2102
+ if (Object.prototype.hasOwnProperty.call(value, String(i))) {
2103
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
2104
+ String(i), true));
2105
+ } else {
2106
+ output.push('');
2107
+ }
2108
+ }
2109
+ keys.forEach(function(key) {
2110
+ if (!key.match(/^\d+$/)) {
2111
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
2112
+ key, true));
2113
+ }
2114
+ });
2115
+ return output;
2116
+ }
2117
+
2118
+
2119
+ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
2120
+ var name, str;
2121
+ if (value.__lookupGetter__) {
2122
+ if (value.__lookupGetter__(key)) {
2123
+ if (value.__lookupSetter__(key)) {
2124
+ str = ctx.stylize('[Getter/Setter]', 'special');
2125
+ } else {
2126
+ str = ctx.stylize('[Getter]', 'special');
2127
+ }
2128
+ } else {
2129
+ if (value.__lookupSetter__(key)) {
2130
+ str = ctx.stylize('[Setter]', 'special');
2131
+ }
2132
+ }
2133
+ }
2134
+ if (visibleKeys.indexOf(key) < 0) {
2135
+ name = '[' + key + ']';
2136
+ }
2137
+ if (!str) {
2138
+ if (ctx.seen.indexOf(value[key]) < 0) {
2139
+ if (recurseTimes === null) {
2140
+ str = formatValue(ctx, value[key], null);
2141
+ } else {
2142
+ str = formatValue(ctx, value[key], recurseTimes - 1);
2143
+ }
2144
+ if (str.indexOf('\n') > -1) {
2145
+ if (array) {
2146
+ str = str.split('\n').map(function(line) {
2147
+ return ' ' + line;
2148
+ }).join('\n').substr(2);
2149
+ } else {
2150
+ str = '\n' + str.split('\n').map(function(line) {
2151
+ return ' ' + line;
2152
+ }).join('\n');
2153
+ }
2154
+ }
2155
+ } else {
2156
+ str = ctx.stylize('[Circular]', 'special');
2157
+ }
2158
+ }
2159
+ if (typeof name === 'undefined') {
2160
+ if (array && key.match(/^\d+$/)) {
2161
+ return str;
2162
+ }
2163
+ name = JSON.stringify('' + key);
2164
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
2165
+ name = name.substr(1, name.length - 2);
2166
+ name = ctx.stylize(name, 'name');
2167
+ } else {
2168
+ name = name.replace(/'/g, "\\'")
2169
+ .replace(/\\"/g, '"')
2170
+ .replace(/(^"|"$)/g, "'");
2171
+ name = ctx.stylize(name, 'string');
2172
+ }
2173
+ }
2174
+
2175
+ return name + ': ' + str;
2176
+ }
2177
+
2178
+
2179
+ function reduceToSingleString(output, base, braces) {
2180
+ var numLinesEst = 0;
2181
+ var length = output.reduce(function(prev, cur) {
2182
+ numLinesEst++;
2183
+ if (cur.indexOf('\n') >= 0) numLinesEst++;
2184
+ return prev + cur.length + 1;
2185
+ }, 0);
2186
+
2187
+ if (length > 60) {
2188
+ return braces[0] +
2189
+ (base === '' ? '' : base + '\n ') +
2190
+ ' ' +
2191
+ output.join(',\n ') +
2192
+ ' ' +
2193
+ braces[1];
2194
+ }
2195
+
2196
+ return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
2197
+ }
2198
+
2199
+ function isArray(ar) {
2200
+ return Array.isArray(ar) ||
2201
+ (typeof ar === 'object' && objectToString(ar) === '[object Array]');
2202
+ }
2203
+
2204
+ function isRegExp(re) {
2205
+ return typeof re === 'object' && objectToString(re) === '[object RegExp]';
2206
+ }
2207
+
2208
+ function isDate(d) {
2209
+ return typeof d === 'object' && objectToString(d) === '[object Date]';
2210
+ }
2211
+
2212
+ function isError(e) {
2213
+ return typeof e === 'object' && objectToString(e) === '[object Error]';
2214
+ }
2215
+
2216
+ function objectToString(o) {
2217
+ return Object.prototype.toString.call(o);
2218
+ }
2219
+ }); // module: utils/inspect.js
2220
+
2221
+
2222
+ return require('chai');
2223
+ });