konacha 1.4.2 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +4 -0
- data/README.md +8 -1
- data/konacha.gemspec +1 -1
- data/lib/konacha.rb +1 -1
- data/vendor/assets/javascripts/chai.js +549 -431
- data/vendor/assets/javascripts/mocha.js +230 -59
- data/vendor/assets/stylesheets/mocha.css +18 -1
- metadata +165 -172
data/History.md
CHANGED
data/README.md
CHANGED
@@ -107,7 +107,7 @@ $ bundle exec rake konacha:run SPEC=foo_spec,bar_spec,etc_spec
|
|
107
107
|
|
108
108
|
Since Konacha integrates with the asset pipeline, using setup helpers in your specs is
|
109
109
|
easy. Just create a `spec_helper.js` or `spec_helper.js.coffee` file in `specs/javascripts`
|
110
|
-
and require it in your tests:
|
110
|
+
and require it in your tests, like so:
|
111
111
|
|
112
112
|
```javascript
|
113
113
|
//= require spec_helper
|
@@ -118,6 +118,13 @@ describe("Array#sum", function() {
|
|
118
118
|
});
|
119
119
|
```
|
120
120
|
|
121
|
+
The `spec_helper` is a good place to set Mocha and Chai options as well, for instance:
|
122
|
+
|
123
|
+
```javascript
|
124
|
+
// Show stack trace on failing assertion.
|
125
|
+
chai.Assertion.includeStack = true;
|
126
|
+
```
|
127
|
+
|
121
128
|
## Directives and Asset Bundling
|
122
129
|
|
123
130
|
We suggest that you explicitly require just the assets necessary for each spec. In CI
|
data/konacha.gemspec
CHANGED
@@ -17,7 +17,7 @@ the asset pipeline and engines.}
|
|
17
17
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
gem.name = "konacha"
|
19
19
|
gem.require_paths = ["lib"]
|
20
|
-
gem.version = "1.
|
20
|
+
gem.version = "1.5.0"
|
21
21
|
|
22
22
|
gem.add_dependency "railties", "~> 3.1"
|
23
23
|
gem.add_dependency "actionpack", "~> 3.1"
|
data/lib/konacha.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
!function (name, context, definition) {
|
2
|
-
if (typeof
|
3
|
-
|
4
|
-
else
|
5
|
-
|
6
|
-
|
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 () {
|
7
12
|
|
8
13
|
function require(p) {
|
9
14
|
var path = require.resolve(p)
|
@@ -69,7 +74,7 @@
|
|
69
74
|
* Chai version
|
70
75
|
*/
|
71
76
|
|
72
|
-
exports.version = '1.
|
77
|
+
exports.version = '1.2.0';
|
73
78
|
|
74
79
|
/*!
|
75
80
|
* Primary `Assertion` prototype
|
@@ -224,11 +229,11 @@
|
|
224
229
|
*/
|
225
230
|
|
226
231
|
Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual) {
|
227
|
-
var
|
228
|
-
, actual = util.getActual(this, arguments)
|
229
|
-
, ok = util.test(this, arguments);
|
232
|
+
var ok = util.test(this, arguments);
|
230
233
|
|
231
234
|
if (!ok) {
|
235
|
+
var msg = util.getMessage(this, arguments)
|
236
|
+
, actual = util.getActual(this, arguments);
|
232
237
|
throw new AssertionError({
|
233
238
|
message: msg
|
234
239
|
, actual: actual
|
@@ -913,10 +918,12 @@
|
|
913
918
|
*/
|
914
919
|
|
915
920
|
Assertion.addMethod('property', function (name, val) {
|
916
|
-
var
|
917
|
-
,
|
918
|
-
,
|
919
|
-
,
|
921
|
+
var descriptor = flag(this, 'deep') ? 'deep property ' : 'property '
|
922
|
+
, negate = flag(this, 'negate')
|
923
|
+
, obj = flag(this, 'object')
|
924
|
+
, value = flag(this, 'deep')
|
925
|
+
? _.getPathValue(name, obj)
|
926
|
+
: obj[name];
|
920
927
|
|
921
928
|
if (negate && undefined !== val) {
|
922
929
|
if (undefined === value) {
|
@@ -1342,22 +1349,6 @@
|
|
1342
1349
|
|
1343
1350
|
}); // module: chai/core/assertions.js
|
1344
1351
|
|
1345
|
-
require.register("chai/interface/expect.js", function(module, exports, require){
|
1346
|
-
/*!
|
1347
|
-
* chai
|
1348
|
-
* Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>
|
1349
|
-
* MIT Licensed
|
1350
|
-
*/
|
1351
|
-
|
1352
|
-
module.exports = function (chai, util) {
|
1353
|
-
chai.expect = function (val, message) {
|
1354
|
-
return new chai.Assertion(val, message);
|
1355
|
-
};
|
1356
|
-
};
|
1357
|
-
|
1358
|
-
|
1359
|
-
}); // module: chai/interface/expect.js
|
1360
|
-
|
1361
1352
|
require.register("chai/interface/assert.js", function(module, exports, require){
|
1362
1353
|
/*!
|
1363
1354
|
* chai
|
@@ -2303,6 +2294,25 @@
|
|
2303
2294
|
, 'expected ' + util.inspect(val) + ' to not be ' + operator + ' ' + util.inspect(val2) );
|
2304
2295
|
};
|
2305
2296
|
|
2297
|
+
/**
|
2298
|
+
* ### .closeTo(actual, expected, delta, [message])
|
2299
|
+
*
|
2300
|
+
* Asserts that the target is equal `expected`, to within a +/- `delta` range.
|
2301
|
+
*
|
2302
|
+
* assert.closeTo(1.5, 1, 0.5, 'numbers are close');
|
2303
|
+
*
|
2304
|
+
* @name closeTo
|
2305
|
+
* @param {Number} actual
|
2306
|
+
* @param {Number} expected
|
2307
|
+
* @param {Number} delta
|
2308
|
+
* @param {String} message
|
2309
|
+
* @api public
|
2310
|
+
*/
|
2311
|
+
|
2312
|
+
assert.closeTo = function (act, exp, delta, msg) {
|
2313
|
+
new Assertion(act, msg).to.be.closeTo(exp, delta);
|
2314
|
+
};
|
2315
|
+
|
2306
2316
|
/*!
|
2307
2317
|
* Undocumented / untested
|
2308
2318
|
*/
|
@@ -2325,6 +2335,22 @@
|
|
2325
2335
|
|
2326
2336
|
}); // module: chai/interface/assert.js
|
2327
2337
|
|
2338
|
+
require.register("chai/interface/expect.js", function(module, exports, require){
|
2339
|
+
/*!
|
2340
|
+
* chai
|
2341
|
+
* Copyright(c) 2011-2012 Jake Luer <jake@alogicalparadox.com>
|
2342
|
+
* MIT Licensed
|
2343
|
+
*/
|
2344
|
+
|
2345
|
+
module.exports = function (chai, util) {
|
2346
|
+
chai.expect = function (val, message) {
|
2347
|
+
return new chai.Assertion(val, message);
|
2348
|
+
};
|
2349
|
+
};
|
2350
|
+
|
2351
|
+
|
2352
|
+
}); // module: chai/interface/expect.js
|
2353
|
+
|
2328
2354
|
require.register("chai/interface/should.js", function(module, exports, require){
|
2329
2355
|
/*!
|
2330
2356
|
* chai
|
@@ -2391,178 +2417,79 @@
|
|
2391
2417
|
|
2392
2418
|
}); // module: chai/interface/should.js
|
2393
2419
|
|
2394
|
-
require.register("chai/utils/
|
2395
|
-
/*!
|
2396
|
-
* Chai - getActual utility
|
2397
|
-
* Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
|
2398
|
-
* MIT Licensed
|
2399
|
-
*/
|
2400
|
-
|
2401
|
-
/**
|
2402
|
-
* # getActual(object, [actual])
|
2403
|
-
*
|
2404
|
-
* Returns the `actual` value for an Assertion
|
2405
|
-
*
|
2406
|
-
* @param {Object} object (constructed Assertion)
|
2407
|
-
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
2408
|
-
*/
|
2409
|
-
|
2410
|
-
module.exports = function (obj, args) {
|
2411
|
-
var actual = args[4];
|
2412
|
-
return 'undefined' !== actual ? actual : obj.obj;
|
2413
|
-
};
|
2414
|
-
|
2415
|
-
}); // module: chai/utils/getActual.js
|
2416
|
-
|
2417
|
-
require.register("chai/utils/getMessage.js", function(module, exports, require){
|
2420
|
+
require.register("chai/utils/addChainableMethod.js", function(module, exports, require){
|
2418
2421
|
/*!
|
2419
|
-
* Chai -
|
2422
|
+
* Chai - addChainingMethod utility
|
2420
2423
|
* Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
|
2421
2424
|
* MIT Licensed
|
2422
2425
|
*/
|
2423
2426
|
|
2424
2427
|
/*!
|
2425
|
-
* Module
|
2428
|
+
* Module dependencies
|
2426
2429
|
*/
|
2427
2430
|
|
2428
|
-
var
|
2429
|
-
, getActual = require('./getActual')
|
2430
|
-
, inspect = require('./inspect');
|
2431
|
+
var transferFlags = require('./transferFlags');
|
2431
2432
|
|
2432
2433
|
/**
|
2433
|
-
*
|
2434
|
+
* ### addChainableMethod (ctx, name, method, chainingBehavior)
|
2434
2435
|
*
|
2435
|
-
*
|
2436
|
-
* and template tags. Template tags will return
|
2437
|
-
* a stringified inspection of the object referenced.
|
2436
|
+
* Adds a method to an object, such that the method can also be chained.
|
2438
2437
|
*
|
2439
|
-
*
|
2440
|
-
*
|
2441
|
-
*
|
2442
|
-
*
|
2438
|
+
* utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) {
|
2439
|
+
* var obj = utils.flag(this, 'object');
|
2440
|
+
* new chai.Assertion(obj).to.be.equal(str);
|
2441
|
+
* });
|
2443
2442
|
*
|
2444
|
-
*
|
2445
|
-
*
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2450
|
-
|
2451
|
-
|
2452
|
-
|
2453
|
-
|
2454
|
-
|
2455
|
-
|
2456
|
-
|
2457
|
-
|
2458
|
-
|
2459
|
-
|
2460
|
-
.replace(/#{exp}/g, inspect(expected));
|
2461
|
-
|
2462
|
-
return flagMsg ? flagMsg + ': ' + msg : msg;
|
2463
|
-
};
|
2464
|
-
|
2465
|
-
}); // module: chai/utils/getMessage.js
|
2466
|
-
|
2467
|
-
require.register("chai/utils/index.js", function(module, exports, require){
|
2468
|
-
/*!
|
2469
|
-
* chai
|
2470
|
-
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
|
2471
|
-
* MIT Licensed
|
2472
|
-
*/
|
2473
|
-
|
2474
|
-
/*!
|
2475
|
-
* Main exports
|
2476
|
-
*/
|
2477
|
-
|
2478
|
-
var exports = module.exports = {};
|
2479
|
-
|
2480
|
-
/*!
|
2481
|
-
* test utility
|
2482
|
-
*/
|
2483
|
-
|
2484
|
-
exports.test = require('./test');
|
2485
|
-
|
2486
|
-
/*!
|
2487
|
-
* message utility
|
2488
|
-
*/
|
2489
|
-
|
2490
|
-
exports.getMessage = require('./getMessage');
|
2491
|
-
|
2492
|
-
/*!
|
2493
|
-
* actual utility
|
2494
|
-
*/
|
2495
|
-
|
2496
|
-
exports.getActual = require('./getActual');
|
2497
|
-
|
2498
|
-
/*!
|
2499
|
-
* Inspect util
|
2500
|
-
*/
|
2501
|
-
|
2502
|
-
exports.inspect = require('./inspect');
|
2503
|
-
|
2504
|
-
/*!
|
2505
|
-
* Flag utility
|
2506
|
-
*/
|
2507
|
-
|
2508
|
-
exports.flag = require('./flag');
|
2509
|
-
|
2510
|
-
/*!
|
2511
|
-
* Flag transferring utility
|
2512
|
-
*/
|
2513
|
-
|
2514
|
-
exports.transferFlags = require('./transferFlags');
|
2515
|
-
|
2516
|
-
/*!
|
2517
|
-
* Deep equal utility
|
2518
|
-
*/
|
2519
|
-
|
2520
|
-
exports.eql = require('./eql');
|
2521
|
-
|
2522
|
-
/*!
|
2523
|
-
* Deep path value
|
2524
|
-
*/
|
2525
|
-
|
2526
|
-
exports.getPathValue = require('./getPathValue');
|
2527
|
-
|
2528
|
-
/*!
|
2529
|
-
* Function name
|
2530
|
-
*/
|
2531
|
-
|
2532
|
-
exports.getName = require('./getName');
|
2533
|
-
|
2534
|
-
/*!
|
2535
|
-
* add Property
|
2536
|
-
*/
|
2537
|
-
|
2538
|
-
exports.addProperty = require('./addProperty');
|
2539
|
-
|
2540
|
-
/*!
|
2541
|
-
* add Method
|
2542
|
-
*/
|
2543
|
-
|
2544
|
-
exports.addMethod = require('./addMethod');
|
2545
|
-
|
2546
|
-
/*!
|
2547
|
-
* overwrite Property
|
2443
|
+
* Can also be accessed directly from `chai.Assertion`.
|
2444
|
+
*
|
2445
|
+
* chai.Assertion.addChainableMethod('foo', fn, chainingBehavior);
|
2446
|
+
*
|
2447
|
+
* The result can then be used as both a method assertion, executing both `method` and
|
2448
|
+
* `chainingBehavior`, or as a language chain, which only executes `chainingBehavior`.
|
2449
|
+
*
|
2450
|
+
* expect(fooStr).to.be.foo('bar');
|
2451
|
+
* expect(fooStr).to.be.foo.equal('foo');
|
2452
|
+
*
|
2453
|
+
* @param {Object} ctx object to which the method is added
|
2454
|
+
* @param {String} name of method to add
|
2455
|
+
* @param {Function} method function to be used for `name`, when called
|
2456
|
+
* @param {Function} chainingBehavior function to be called every time the property is accessed
|
2457
|
+
* @name addChainableMethod
|
2458
|
+
* @api public
|
2548
2459
|
*/
|
2549
2460
|
|
2550
|
-
exports
|
2551
|
-
|
2552
|
-
|
2553
|
-
* overwrite Method
|
2554
|
-
*/
|
2461
|
+
module.exports = function (ctx, name, method, chainingBehavior) {
|
2462
|
+
if (typeof chainingBehavior !== 'function')
|
2463
|
+
chainingBehavior = function () { };
|
2555
2464
|
|
2556
|
-
|
2465
|
+
Object.defineProperty(ctx, name,
|
2466
|
+
{ get: function () {
|
2467
|
+
chainingBehavior.call(this);
|
2557
2468
|
|
2558
|
-
|
2559
|
-
|
2560
|
-
|
2469
|
+
var assert = function () {
|
2470
|
+
var result = method.apply(this, arguments);
|
2471
|
+
return result === undefined ? this : result;
|
2472
|
+
};
|
2561
2473
|
|
2562
|
-
|
2474
|
+
// Re-enumerate every time to better accomodate plugins.
|
2475
|
+
var asserterNames = Object.getOwnPropertyNames(ctx);
|
2476
|
+
asserterNames.forEach(function (asserterName) {
|
2477
|
+
var pd = Object.getOwnPropertyDescriptor(ctx, asserterName)
|
2478
|
+
, functionProtoPD = Object.getOwnPropertyDescriptor(Function.prototype, asserterName);
|
2479
|
+
// Avoid trying to overwrite things that we can't, like `length` and `arguments`.
|
2480
|
+
if (functionProtoPD && !functionProtoPD.configurable) return;
|
2481
|
+
if (asserterName === 'arguments') return; // @see chaijs/chai/issues/69
|
2482
|
+
Object.defineProperty(assert, asserterName, pd);
|
2483
|
+
});
|
2563
2484
|
|
2485
|
+
transferFlags(this, assert);
|
2486
|
+
return assert;
|
2487
|
+
}
|
2488
|
+
, configurable: true
|
2489
|
+
});
|
2490
|
+
};
|
2564
2491
|
|
2565
|
-
}); // module: chai/utils/
|
2492
|
+
}); // module: chai/utils/addChainableMethod.js
|
2566
2493
|
|
2567
2494
|
require.register("chai/utils/addMethod.js", function(module, exports, require){
|
2568
2495
|
/*!
|
@@ -2572,7 +2499,7 @@
|
|
2572
2499
|
*/
|
2573
2500
|
|
2574
2501
|
/**
|
2575
|
-
* ### addMethod (ctx, name, method)
|
2502
|
+
* ### .addMethod (ctx, name, method)
|
2576
2503
|
*
|
2577
2504
|
* Adds a method to the prototype of an object.
|
2578
2505
|
*
|
@@ -2605,41 +2532,49 @@
|
|
2605
2532
|
|
2606
2533
|
}); // module: chai/utils/addMethod.js
|
2607
2534
|
|
2608
|
-
require.register("chai/utils/
|
2535
|
+
require.register("chai/utils/addProperty.js", function(module, exports, require){
|
2609
2536
|
/*!
|
2610
|
-
* Chai -
|
2537
|
+
* Chai - addProperty utility
|
2611
2538
|
* Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
|
2612
2539
|
* MIT Licensed
|
2613
2540
|
*/
|
2614
2541
|
|
2615
2542
|
/**
|
2616
|
-
* ###
|
2543
|
+
* ### addProperty (ctx, name, getter)
|
2617
2544
|
*
|
2618
|
-
*
|
2619
|
-
* value is provided it will be set, else it will
|
2620
|
-
* return the currently set value or `undefined` if
|
2621
|
-
* the value is not set.
|
2545
|
+
* Adds a property to the prototype of an object.
|
2622
2546
|
*
|
2623
|
-
* utils.
|
2624
|
-
*
|
2547
|
+
* utils.addProperty(chai.Assertion.prototype, 'foo', function () {
|
2548
|
+
* var obj = utils.flag(this, 'object');
|
2549
|
+
* new chai.Assertion(obj).to.be.instanceof(Foo);
|
2550
|
+
* });
|
2625
2551
|
*
|
2626
|
-
*
|
2627
|
-
*
|
2628
|
-
*
|
2629
|
-
*
|
2630
|
-
*
|
2552
|
+
* Can also be accessed directly from `chai.Assertion`.
|
2553
|
+
*
|
2554
|
+
* chai.Assertion.addProperty('foo', fn);
|
2555
|
+
*
|
2556
|
+
* Then can be used as any other assertion.
|
2557
|
+
*
|
2558
|
+
* expect(myFoo).to.be.foo;
|
2559
|
+
*
|
2560
|
+
* @param {Object} ctx object to which the property is added
|
2561
|
+
* @param {String} name of property to add
|
2562
|
+
* @param {Function} getter function to be used for name
|
2563
|
+
* @name addProperty
|
2564
|
+
* @api public
|
2631
2565
|
*/
|
2632
2566
|
|
2633
|
-
module.exports = function (
|
2634
|
-
|
2635
|
-
|
2636
|
-
|
2637
|
-
|
2638
|
-
|
2639
|
-
|
2567
|
+
module.exports = function (ctx, name, getter) {
|
2568
|
+
Object.defineProperty(ctx, name,
|
2569
|
+
{ get: function () {
|
2570
|
+
var result = getter.call(this);
|
2571
|
+
return result === undefined ? this : result;
|
2572
|
+
}
|
2573
|
+
, configurable: true
|
2574
|
+
});
|
2640
2575
|
};
|
2641
2576
|
|
2642
|
-
}); // module: chai/utils/
|
2577
|
+
}); // module: chai/utils/addProperty.js
|
2643
2578
|
|
2644
2579
|
require.register("chai/utils/eql.js", function(module, exports, require){
|
2645
2580
|
// This is directly from Node.js assert
|
@@ -2744,138 +2679,117 @@
|
|
2744
2679
|
}
|
2745
2680
|
}); // module: chai/utils/eql.js
|
2746
2681
|
|
2747
|
-
require.register("chai/utils/
|
2682
|
+
require.register("chai/utils/flag.js", function(module, exports, require){
|
2748
2683
|
/*!
|
2749
|
-
* Chai -
|
2684
|
+
* Chai - flag utility
|
2750
2685
|
* Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
|
2751
2686
|
* MIT Licensed
|
2752
2687
|
*/
|
2753
2688
|
|
2754
2689
|
/**
|
2755
|
-
* ###
|
2756
|
-
*
|
2757
|
-
* Overwites an already existing method and provides
|
2758
|
-
* access to previous function. Must return function
|
2759
|
-
* to be used for name.
|
2760
|
-
*
|
2761
|
-
* utils.overwriteMethod(chai.Assertion.prototype, 'equal', function (_super) {
|
2762
|
-
* return function (str) {
|
2763
|
-
* var obj = utils.flag(this, 'object');
|
2764
|
-
* if (obj instanceof Foo) {
|
2765
|
-
* new chai.Assertion(obj.value).to.equal(str);
|
2766
|
-
* } else {
|
2767
|
-
* _super.apply(this, arguments);
|
2768
|
-
* }
|
2769
|
-
* }
|
2770
|
-
* });
|
2771
|
-
*
|
2772
|
-
* Can also be accessed directly from `chai.Assertion`.
|
2773
|
-
*
|
2774
|
-
* chai.Assertion.overwriteMethod('foo', fn);
|
2690
|
+
* ### flag(object ,key, [value])
|
2775
2691
|
*
|
2776
|
-
*
|
2692
|
+
* Get or set a flag value on an object. If a
|
2693
|
+
* value is provided it will be set, else it will
|
2694
|
+
* return the currently set value or `undefined` if
|
2695
|
+
* the value is not set.
|
2777
2696
|
*
|
2778
|
-
*
|
2697
|
+
* utils.flag(this, 'foo', 'bar'); // setter
|
2698
|
+
* utils.flag(this, 'foo'); // getter, returns `bar`
|
2779
2699
|
*
|
2780
|
-
* @param {Object}
|
2781
|
-
* @param {String}
|
2782
|
-
* @param {
|
2783
|
-
* @name
|
2784
|
-
* @api
|
2700
|
+
* @param {Object} object (constructed Assertion
|
2701
|
+
* @param {String} key
|
2702
|
+
* @param {Mixed} value (optional)
|
2703
|
+
* @name flag
|
2704
|
+
* @api private
|
2785
2705
|
*/
|
2786
2706
|
|
2787
|
-
module.exports = function (
|
2788
|
-
var
|
2789
|
-
|
2790
|
-
|
2791
|
-
|
2792
|
-
|
2793
|
-
|
2794
|
-
ctx[name] = function () {
|
2795
|
-
var result = method(_super).apply(this, arguments);
|
2796
|
-
return result === undefined ? this : result;
|
2707
|
+
module.exports = function (obj, key, value) {
|
2708
|
+
var flags = obj.__flags || (obj.__flags = Object.create(null));
|
2709
|
+
if (arguments.length === 3) {
|
2710
|
+
flags[key] = value;
|
2711
|
+
} else {
|
2712
|
+
return flags[key];
|
2797
2713
|
}
|
2798
2714
|
};
|
2799
2715
|
|
2800
|
-
}); // module: chai/utils/
|
2716
|
+
}); // module: chai/utils/flag.js
|
2801
2717
|
|
2802
|
-
require.register("chai/utils/
|
2718
|
+
require.register("chai/utils/getActual.js", function(module, exports, require){
|
2803
2719
|
/*!
|
2804
|
-
* Chai -
|
2720
|
+
* Chai - getActual utility
|
2805
2721
|
* Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
|
2806
2722
|
* MIT Licensed
|
2807
2723
|
*/
|
2808
2724
|
|
2809
|
-
/*!
|
2810
|
-
* Module dependancies
|
2811
|
-
*/
|
2812
|
-
|
2813
|
-
var flag = require('./flag');
|
2814
|
-
|
2815
2725
|
/**
|
2816
|
-
* #
|
2726
|
+
* # getActual(object, [actual])
|
2817
2727
|
*
|
2818
|
-
*
|
2728
|
+
* Returns the `actual` value for an Assertion
|
2819
2729
|
*
|
2820
2730
|
* @param {Object} object (constructed Assertion)
|
2821
2731
|
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
2822
2732
|
*/
|
2823
2733
|
|
2824
2734
|
module.exports = function (obj, args) {
|
2825
|
-
var
|
2826
|
-
|
2827
|
-
return negate ? !expr : expr;
|
2735
|
+
var actual = args[4];
|
2736
|
+
return 'undefined' !== actual ? actual : obj._obj;
|
2828
2737
|
};
|
2829
2738
|
|
2830
|
-
}); // module: chai/utils/
|
2739
|
+
}); // module: chai/utils/getActual.js
|
2831
2740
|
|
2832
|
-
require.register("chai/utils/
|
2741
|
+
require.register("chai/utils/getMessage.js", function(module, exports, require){
|
2833
2742
|
/*!
|
2834
|
-
* Chai -
|
2743
|
+
* Chai - message composition utility
|
2835
2744
|
* Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
|
2836
2745
|
* MIT Licensed
|
2837
2746
|
*/
|
2838
2747
|
|
2748
|
+
/*!
|
2749
|
+
* Module dependancies
|
2750
|
+
*/
|
2751
|
+
|
2752
|
+
var flag = require('./flag')
|
2753
|
+
, getActual = require('./getActual')
|
2754
|
+
, inspect = require('./inspect')
|
2755
|
+
, objDisplay = require('./objDisplay');
|
2756
|
+
|
2839
2757
|
/**
|
2840
|
-
* ###
|
2758
|
+
* ### .getMessage(object, message, negateMessage)
|
2841
2759
|
*
|
2842
|
-
*
|
2843
|
-
*
|
2844
|
-
*
|
2845
|
-
* will not be transferred.
|
2846
|
-
*
|
2847
|
-
*
|
2848
|
-
* var newAssertion = new Assertion();
|
2849
|
-
* utils.transferFlags(assertion, newAssertion);
|
2760
|
+
* Construct the error message based on flags
|
2761
|
+
* and template tags. Template tags will return
|
2762
|
+
* a stringified inspection of the object referenced.
|
2850
2763
|
*
|
2851
|
-
*
|
2852
|
-
*
|
2764
|
+
* Messsage template tags:
|
2765
|
+
* - `#{this}` current asserted object
|
2766
|
+
* - `#{act}` actual value
|
2767
|
+
* - `#{exp}` expected value
|
2853
2768
|
*
|
2854
|
-
* @param {
|
2855
|
-
* @param {
|
2856
|
-
* @
|
2857
|
-
* @
|
2858
|
-
* @api private
|
2769
|
+
* @param {Object} object (constructed Assertion)
|
2770
|
+
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
2771
|
+
* @name getMessage
|
2772
|
+
* @api public
|
2859
2773
|
*/
|
2860
2774
|
|
2861
|
-
module.exports = function (
|
2862
|
-
var
|
2863
|
-
|
2864
|
-
|
2865
|
-
|
2866
|
-
|
2775
|
+
module.exports = function (obj, args) {
|
2776
|
+
var negate = flag(obj, 'negate')
|
2777
|
+
, val = flag(obj, 'object')
|
2778
|
+
, expected = args[3]
|
2779
|
+
, actual = getActual(obj, args)
|
2780
|
+
, msg = negate ? args[2] : args[1]
|
2781
|
+
, flagMsg = flag(obj, 'message');
|
2867
2782
|
|
2868
|
-
|
2783
|
+
msg = msg || '';
|
2784
|
+
msg = msg
|
2785
|
+
.replace(/#{this}/g, objDisplay(val))
|
2786
|
+
.replace(/#{act}/g, objDisplay(actual))
|
2787
|
+
.replace(/#{exp}/g, objDisplay(expected));
|
2869
2788
|
|
2870
|
-
|
2871
|
-
if (includeAll ||
|
2872
|
-
(flag !== 'object' && flag !== 'ssfi' && flag != 'message')) {
|
2873
|
-
object.__flags[flag] = flags[flag];
|
2874
|
-
}
|
2875
|
-
}
|
2789
|
+
return flagMsg ? flagMsg + ': ' + msg : msg;
|
2876
2790
|
};
|
2877
2791
|
|
2878
|
-
}); // module: chai/utils/
|
2792
|
+
}); // module: chai/utils/getMessage.js
|
2879
2793
|
|
2880
2794
|
require.register("chai/utils/getName.js", function(module, exports, require){
|
2881
2795
|
/*!
|
@@ -2901,64 +2815,6 @@
|
|
2901
2815
|
|
2902
2816
|
}); // module: chai/utils/getName.js
|
2903
2817
|
|
2904
|
-
require.register("chai/utils/overwriteProperty.js", function(module, exports, require){
|
2905
|
-
/*!
|
2906
|
-
* Chai - overwriteProperty utility
|
2907
|
-
* Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
|
2908
|
-
* MIT Licensed
|
2909
|
-
*/
|
2910
|
-
|
2911
|
-
/**
|
2912
|
-
* ### overwriteProperty (ctx, name, fn)
|
2913
|
-
*
|
2914
|
-
* Overwites an already existing property getter and provides
|
2915
|
-
* access to previous value. Must return function to use as getter.
|
2916
|
-
*
|
2917
|
-
* utils.overwriteProperty(chai.Assertion.prototype, 'ok', function (_super) {
|
2918
|
-
* return function () {
|
2919
|
-
* var obj = utils.flag(this, 'object');
|
2920
|
-
* if (obj instanceof Foo) {
|
2921
|
-
* new chai.Assertion(obj.name).to.equal('bar');
|
2922
|
-
* } else {
|
2923
|
-
* _super.call(this);
|
2924
|
-
* }
|
2925
|
-
* }
|
2926
|
-
* });
|
2927
|
-
*
|
2928
|
-
*
|
2929
|
-
* Can also be accessed directly from `chai.Assertion`.
|
2930
|
-
*
|
2931
|
-
* chai.Assertion.overwriteProperty('foo', fn);
|
2932
|
-
*
|
2933
|
-
* Then can be used as any other assertion.
|
2934
|
-
*
|
2935
|
-
* expect(myFoo).to.be.ok;
|
2936
|
-
*
|
2937
|
-
* @param {Object} ctx object whose property is to be overwritten
|
2938
|
-
* @param {String} name of property to overwrite
|
2939
|
-
* @param {Function} getter function that returns a getter function to be used for name
|
2940
|
-
* @name overwriteProperty
|
2941
|
-
* @api public
|
2942
|
-
*/
|
2943
|
-
|
2944
|
-
module.exports = function (ctx, name, getter) {
|
2945
|
-
var _get = Object.getOwnPropertyDescriptor(ctx, name)
|
2946
|
-
, _super = function () {};
|
2947
|
-
|
2948
|
-
if (_get && 'function' === typeof _get.get)
|
2949
|
-
_super = _get.get
|
2950
|
-
|
2951
|
-
Object.defineProperty(ctx, name,
|
2952
|
-
{ get: function () {
|
2953
|
-
var result = getter(_super).call(this);
|
2954
|
-
return result === undefined ? this : result;
|
2955
|
-
}
|
2956
|
-
, configurable: true
|
2957
|
-
});
|
2958
|
-
};
|
2959
|
-
|
2960
|
-
}); // module: chai/utils/overwriteProperty.js
|
2961
|
-
|
2962
2818
|
require.register("chai/utils/getPathValue.js", function(module, exports, require){
|
2963
2819
|
/*!
|
2964
2820
|
* Chai - getPathValue utility
|
@@ -3045,25 +2901,131 @@
|
|
3045
2901
|
* @api private
|
3046
2902
|
*/
|
3047
2903
|
|
3048
|
-
function _getPathValue (parsed, obj) {
|
3049
|
-
var tmp = obj
|
3050
|
-
, res;
|
3051
|
-
for (var i = 0, l = parsed.length; i < l; i++) {
|
3052
|
-
var part = parsed[i];
|
3053
|
-
if (tmp) {
|
3054
|
-
if ('undefined' !== typeof part.p)
|
3055
|
-
tmp = tmp[part.p];
|
3056
|
-
else if ('undefined' !== typeof part.i)
|
3057
|
-
tmp = tmp[part.i];
|
3058
|
-
if (i == (l - 1)) res = tmp;
|
3059
|
-
} else {
|
3060
|
-
res = undefined;
|
3061
|
-
}
|
3062
|
-
}
|
3063
|
-
return res;
|
3064
|
-
};
|
2904
|
+
function _getPathValue (parsed, obj) {
|
2905
|
+
var tmp = obj
|
2906
|
+
, res;
|
2907
|
+
for (var i = 0, l = parsed.length; i < l; i++) {
|
2908
|
+
var part = parsed[i];
|
2909
|
+
if (tmp) {
|
2910
|
+
if ('undefined' !== typeof part.p)
|
2911
|
+
tmp = tmp[part.p];
|
2912
|
+
else if ('undefined' !== typeof part.i)
|
2913
|
+
tmp = tmp[part.i];
|
2914
|
+
if (i == (l - 1)) res = tmp;
|
2915
|
+
} else {
|
2916
|
+
res = undefined;
|
2917
|
+
}
|
2918
|
+
}
|
2919
|
+
return res;
|
2920
|
+
};
|
2921
|
+
|
2922
|
+
}); // module: chai/utils/getPathValue.js
|
2923
|
+
|
2924
|
+
require.register("chai/utils/index.js", function(module, exports, require){
|
2925
|
+
/*!
|
2926
|
+
* chai
|
2927
|
+
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
|
2928
|
+
* MIT Licensed
|
2929
|
+
*/
|
2930
|
+
|
2931
|
+
/*!
|
2932
|
+
* Main exports
|
2933
|
+
*/
|
2934
|
+
|
2935
|
+
var exports = module.exports = {};
|
2936
|
+
|
2937
|
+
/*!
|
2938
|
+
* test utility
|
2939
|
+
*/
|
2940
|
+
|
2941
|
+
exports.test = require('./test');
|
2942
|
+
|
2943
|
+
/*!
|
2944
|
+
* message utility
|
2945
|
+
*/
|
2946
|
+
|
2947
|
+
exports.getMessage = require('./getMessage');
|
2948
|
+
|
2949
|
+
/*!
|
2950
|
+
* actual utility
|
2951
|
+
*/
|
2952
|
+
|
2953
|
+
exports.getActual = require('./getActual');
|
2954
|
+
|
2955
|
+
/*!
|
2956
|
+
* Inspect util
|
2957
|
+
*/
|
2958
|
+
|
2959
|
+
exports.inspect = require('./inspect');
|
2960
|
+
|
2961
|
+
/*!
|
2962
|
+
* Object Display util
|
2963
|
+
*/
|
2964
|
+
|
2965
|
+
exports.objDisplay = require('./objDisplay');
|
2966
|
+
|
2967
|
+
/*!
|
2968
|
+
* Flag utility
|
2969
|
+
*/
|
2970
|
+
|
2971
|
+
exports.flag = require('./flag');
|
2972
|
+
|
2973
|
+
/*!
|
2974
|
+
* Flag transferring utility
|
2975
|
+
*/
|
2976
|
+
|
2977
|
+
exports.transferFlags = require('./transferFlags');
|
2978
|
+
|
2979
|
+
/*!
|
2980
|
+
* Deep equal utility
|
2981
|
+
*/
|
2982
|
+
|
2983
|
+
exports.eql = require('./eql');
|
2984
|
+
|
2985
|
+
/*!
|
2986
|
+
* Deep path value
|
2987
|
+
*/
|
2988
|
+
|
2989
|
+
exports.getPathValue = require('./getPathValue');
|
2990
|
+
|
2991
|
+
/*!
|
2992
|
+
* Function name
|
2993
|
+
*/
|
2994
|
+
|
2995
|
+
exports.getName = require('./getName');
|
2996
|
+
|
2997
|
+
/*!
|
2998
|
+
* add Property
|
2999
|
+
*/
|
3000
|
+
|
3001
|
+
exports.addProperty = require('./addProperty');
|
3002
|
+
|
3003
|
+
/*!
|
3004
|
+
* add Method
|
3005
|
+
*/
|
3006
|
+
|
3007
|
+
exports.addMethod = require('./addMethod');
|
3008
|
+
|
3009
|
+
/*!
|
3010
|
+
* overwrite Property
|
3011
|
+
*/
|
3012
|
+
|
3013
|
+
exports.overwriteProperty = require('./overwriteProperty');
|
3014
|
+
|
3015
|
+
/*!
|
3016
|
+
* overwrite Method
|
3017
|
+
*/
|
3018
|
+
|
3019
|
+
exports.overwriteMethod = require('./overwriteMethod');
|
3020
|
+
|
3021
|
+
/*!
|
3022
|
+
* Add a chainable method
|
3023
|
+
*/
|
3024
|
+
|
3025
|
+
exports.addChainableMethod = require('./addChainableMethod');
|
3026
|
+
|
3065
3027
|
|
3066
|
-
}); // module: chai/utils/
|
3028
|
+
}); // module: chai/utils/index.js
|
3067
3029
|
|
3068
3030
|
require.register("chai/utils/inspect.js", function(module, exports, require){
|
3069
3031
|
// This is (almost) directly from Node.js utils
|
@@ -3093,6 +3055,36 @@
|
|
3093
3055
|
return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
|
3094
3056
|
}
|
3095
3057
|
|
3058
|
+
// https://gist.github.com/1044128/
|
3059
|
+
var getOuterHTML = function(element) {
|
3060
|
+
if ('outerHTML' in element) return element.outerHTML;
|
3061
|
+
var ns = "http://www.w3.org/1999/xhtml";
|
3062
|
+
var container = document.createElementNS(ns, '_');
|
3063
|
+
var elemProto = (window.HTMLElement || window.Element).prototype;
|
3064
|
+
var xmlSerializer = new XMLSerializer();
|
3065
|
+
var html;
|
3066
|
+
if (document.xmlVersion) {
|
3067
|
+
return xmlSerializer.serializeToString(element);
|
3068
|
+
} else {
|
3069
|
+
container.appendChild(element.cloneNode(false));
|
3070
|
+
html = container.innerHTML.replace('><', '>' + element.innerHTML + '<');
|
3071
|
+
container.innerHTML = '';
|
3072
|
+
return html;
|
3073
|
+
}
|
3074
|
+
};
|
3075
|
+
|
3076
|
+
// Returns true if object is a DOM element.
|
3077
|
+
var isDOMElement = function (object) {
|
3078
|
+
if (typeof HTMLElement === 'object') {
|
3079
|
+
return object instanceof HTMLElement;
|
3080
|
+
} else {
|
3081
|
+
return object &&
|
3082
|
+
typeof object === 'object' &&
|
3083
|
+
object.nodeType === 1 &&
|
3084
|
+
typeof object.nodeName === 'string';
|
3085
|
+
}
|
3086
|
+
};
|
3087
|
+
|
3096
3088
|
function formatValue(ctx, value, recurseTimes) {
|
3097
3089
|
// Provide a hook for user-specified inspect functions.
|
3098
3090
|
// Check that value is an object with an inspect function on it
|
@@ -3110,6 +3102,11 @@
|
|
3110
3102
|
return primitive;
|
3111
3103
|
}
|
3112
3104
|
|
3105
|
+
// If it's DOM elem, get outer HTML.
|
3106
|
+
if (isDOMElement(value)) {
|
3107
|
+
return getOuterHTML(value);
|
3108
|
+
}
|
3109
|
+
|
3113
3110
|
// Look up the keys of the object.
|
3114
3111
|
var visibleKeys = Object.keys(value);
|
3115
3112
|
var keys = ctx.showHidden ? Object.getOwnPropertyNames(value) : visibleKeys;
|
@@ -3348,125 +3345,246 @@
|
|
3348
3345
|
|
3349
3346
|
}); // module: chai/utils/inspect.js
|
3350
3347
|
|
3351
|
-
require.register("chai/utils/
|
3348
|
+
require.register("chai/utils/objDisplay.js", function(module, exports, require){
|
3352
3349
|
/*!
|
3353
|
-
* Chai -
|
3350
|
+
* Chai - flag utility
|
3354
3351
|
* Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
|
3355
3352
|
* MIT Licensed
|
3356
3353
|
*/
|
3357
3354
|
|
3355
|
+
/*!
|
3356
|
+
* Module dependancies
|
3357
|
+
*/
|
3358
|
+
|
3359
|
+
var inspect = require('./inspect');
|
3360
|
+
|
3358
3361
|
/**
|
3359
|
-
* ###
|
3362
|
+
* ### .objDisplay (object)
|
3360
3363
|
*
|
3361
|
-
*
|
3364
|
+
* Determines if an object or an array matches
|
3365
|
+
* criteria to be inspected in-line for error
|
3366
|
+
* messages or should be truncated.
|
3362
3367
|
*
|
3363
|
-
*
|
3364
|
-
*
|
3365
|
-
*
|
3368
|
+
* @param {Mixed} javascript object to inspect
|
3369
|
+
* @name objDisplay
|
3370
|
+
* @api public
|
3371
|
+
*/
|
3372
|
+
|
3373
|
+
module.exports = function (obj) {
|
3374
|
+
var str = inspect(obj)
|
3375
|
+
, type = Object.prototype.toString.call(obj);
|
3376
|
+
|
3377
|
+
if (str.length >= 40) {
|
3378
|
+
if (type === '[object Array]') {
|
3379
|
+
return '[ Array(' + obj.length + ') ]';
|
3380
|
+
} else if (type === '[object Object]') {
|
3381
|
+
var keys = Object.keys(obj)
|
3382
|
+
, kstr = keys.length > 2
|
3383
|
+
? keys.splice(0, 2).join(', ') + ', ...'
|
3384
|
+
: keys.join(', ');
|
3385
|
+
return '{ Object (' + kstr + ') }';
|
3386
|
+
} else {
|
3387
|
+
return str;
|
3388
|
+
}
|
3389
|
+
} else {
|
3390
|
+
return str;
|
3391
|
+
}
|
3392
|
+
};
|
3393
|
+
|
3394
|
+
}); // module: chai/utils/objDisplay.js
|
3395
|
+
|
3396
|
+
require.register("chai/utils/overwriteMethod.js", function(module, exports, require){
|
3397
|
+
/*!
|
3398
|
+
* Chai - overwriteMethod utility
|
3399
|
+
* Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
|
3400
|
+
* MIT Licensed
|
3401
|
+
*/
|
3402
|
+
|
3403
|
+
/**
|
3404
|
+
* ### overwriteMethod (ctx, name, fn)
|
3405
|
+
*
|
3406
|
+
* Overwites an already existing method and provides
|
3407
|
+
* access to previous function. Must return function
|
3408
|
+
* to be used for name.
|
3409
|
+
*
|
3410
|
+
* utils.overwriteMethod(chai.Assertion.prototype, 'equal', function (_super) {
|
3411
|
+
* return function (str) {
|
3412
|
+
* var obj = utils.flag(this, 'object');
|
3413
|
+
* if (obj instanceof Foo) {
|
3414
|
+
* new chai.Assertion(obj.value).to.equal(str);
|
3415
|
+
* } else {
|
3416
|
+
* _super.apply(this, arguments);
|
3417
|
+
* }
|
3418
|
+
* }
|
3366
3419
|
* });
|
3367
3420
|
*
|
3368
3421
|
* Can also be accessed directly from `chai.Assertion`.
|
3369
3422
|
*
|
3370
|
-
* chai.Assertion.
|
3423
|
+
* chai.Assertion.overwriteMethod('foo', fn);
|
3371
3424
|
*
|
3372
3425
|
* Then can be used as any other assertion.
|
3373
3426
|
*
|
3374
|
-
* expect(myFoo).to.
|
3427
|
+
* expect(myFoo).to.equal('bar');
|
3375
3428
|
*
|
3376
|
-
* @param {Object} ctx object
|
3377
|
-
* @param {String} name of
|
3378
|
-
* @param {Function}
|
3379
|
-
* @name
|
3429
|
+
* @param {Object} ctx object whose method is to be overwritten
|
3430
|
+
* @param {String} name of method to overwrite
|
3431
|
+
* @param {Function} method function that returns a function to be used for name
|
3432
|
+
* @name overwriteMethod
|
3433
|
+
* @api public
|
3434
|
+
*/
|
3435
|
+
|
3436
|
+
module.exports = function (ctx, name, method) {
|
3437
|
+
var _method = ctx[name]
|
3438
|
+
, _super = function () { return this; };
|
3439
|
+
|
3440
|
+
if (_method && 'function' === typeof _method)
|
3441
|
+
_super = _method;
|
3442
|
+
|
3443
|
+
ctx[name] = function () {
|
3444
|
+
var result = method(_super).apply(this, arguments);
|
3445
|
+
return result === undefined ? this : result;
|
3446
|
+
}
|
3447
|
+
};
|
3448
|
+
|
3449
|
+
}); // module: chai/utils/overwriteMethod.js
|
3450
|
+
|
3451
|
+
require.register("chai/utils/overwriteProperty.js", function(module, exports, require){
|
3452
|
+
/*!
|
3453
|
+
* Chai - overwriteProperty utility
|
3454
|
+
* Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
|
3455
|
+
* MIT Licensed
|
3456
|
+
*/
|
3457
|
+
|
3458
|
+
/**
|
3459
|
+
* ### overwriteProperty (ctx, name, fn)
|
3460
|
+
*
|
3461
|
+
* Overwites an already existing property getter and provides
|
3462
|
+
* access to previous value. Must return function to use as getter.
|
3463
|
+
*
|
3464
|
+
* utils.overwriteProperty(chai.Assertion.prototype, 'ok', function (_super) {
|
3465
|
+
* return function () {
|
3466
|
+
* var obj = utils.flag(this, 'object');
|
3467
|
+
* if (obj instanceof Foo) {
|
3468
|
+
* new chai.Assertion(obj.name).to.equal('bar');
|
3469
|
+
* } else {
|
3470
|
+
* _super.call(this);
|
3471
|
+
* }
|
3472
|
+
* }
|
3473
|
+
* });
|
3474
|
+
*
|
3475
|
+
*
|
3476
|
+
* Can also be accessed directly from `chai.Assertion`.
|
3477
|
+
*
|
3478
|
+
* chai.Assertion.overwriteProperty('foo', fn);
|
3479
|
+
*
|
3480
|
+
* Then can be used as any other assertion.
|
3481
|
+
*
|
3482
|
+
* expect(myFoo).to.be.ok;
|
3483
|
+
*
|
3484
|
+
* @param {Object} ctx object whose property is to be overwritten
|
3485
|
+
* @param {String} name of property to overwrite
|
3486
|
+
* @param {Function} getter function that returns a getter function to be used for name
|
3487
|
+
* @name overwriteProperty
|
3380
3488
|
* @api public
|
3381
3489
|
*/
|
3382
3490
|
|
3383
3491
|
module.exports = function (ctx, name, getter) {
|
3492
|
+
var _get = Object.getOwnPropertyDescriptor(ctx, name)
|
3493
|
+
, _super = function () {};
|
3494
|
+
|
3495
|
+
if (_get && 'function' === typeof _get.get)
|
3496
|
+
_super = _get.get
|
3497
|
+
|
3384
3498
|
Object.defineProperty(ctx, name,
|
3385
3499
|
{ get: function () {
|
3386
|
-
var result = getter.call(this);
|
3500
|
+
var result = getter(_super).call(this);
|
3387
3501
|
return result === undefined ? this : result;
|
3388
3502
|
}
|
3389
3503
|
, configurable: true
|
3390
3504
|
});
|
3391
3505
|
};
|
3392
3506
|
|
3393
|
-
}); // module: chai/utils/
|
3507
|
+
}); // module: chai/utils/overwriteProperty.js
|
3394
3508
|
|
3395
|
-
require.register("chai/utils/
|
3509
|
+
require.register("chai/utils/test.js", function(module, exports, require){
|
3396
3510
|
/*!
|
3397
|
-
* Chai -
|
3511
|
+
* Chai - test utility
|
3398
3512
|
* Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
|
3399
3513
|
* MIT Licensed
|
3400
3514
|
*/
|
3401
3515
|
|
3402
3516
|
/*!
|
3403
|
-
* Module
|
3517
|
+
* Module dependancies
|
3404
3518
|
*/
|
3405
3519
|
|
3406
|
-
var
|
3520
|
+
var flag = require('./flag');
|
3407
3521
|
|
3408
3522
|
/**
|
3409
|
-
*
|
3523
|
+
* # test(object, expression)
|
3410
3524
|
*
|
3411
|
-
*
|
3525
|
+
* Test and object for expression.
|
3412
3526
|
*
|
3413
|
-
*
|
3414
|
-
*
|
3415
|
-
|
3416
|
-
|
3527
|
+
* @param {Object} object (constructed Assertion)
|
3528
|
+
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
3529
|
+
*/
|
3530
|
+
|
3531
|
+
module.exports = function (obj, args) {
|
3532
|
+
var negate = flag(obj, 'negate')
|
3533
|
+
, expr = args[0];
|
3534
|
+
return negate ? !expr : expr;
|
3535
|
+
};
|
3536
|
+
|
3537
|
+
}); // module: chai/utils/test.js
|
3538
|
+
|
3539
|
+
require.register("chai/utils/transferFlags.js", function(module, exports, require){
|
3540
|
+
/*!
|
3541
|
+
* Chai - transferFlags utility
|
3542
|
+
* Copyright(c) 2012 Jake Luer <jake@alogicalparadox.com>
|
3543
|
+
* MIT Licensed
|
3544
|
+
*/
|
3545
|
+
|
3546
|
+
/**
|
3547
|
+
* ### transferFlags(assertion, object, includeAll = true)
|
3417
3548
|
*
|
3418
|
-
*
|
3549
|
+
* Transfer all the flags for `assertion` to `object`. If
|
3550
|
+
* `includeAll` is set to `false`, then the base Chai
|
3551
|
+
* assertion flags (namely `object`, `ssfi`, and `message`)
|
3552
|
+
* will not be transferred.
|
3419
3553
|
*
|
3420
|
-
* chai.Assertion.addChainableMethod('foo', fn, chainingBehavior);
|
3421
3554
|
*
|
3422
|
-
*
|
3423
|
-
*
|
3555
|
+
* var newAssertion = new Assertion();
|
3556
|
+
* utils.transferFlags(assertion, newAssertion);
|
3424
3557
|
*
|
3425
|
-
*
|
3426
|
-
*
|
3558
|
+
* var anotherAsseriton = new Assertion(myObj);
|
3559
|
+
* utils.transferFlags(assertion, anotherAssertion, false);
|
3427
3560
|
*
|
3428
|
-
* @param {
|
3429
|
-
* @param {
|
3430
|
-
* @param {
|
3431
|
-
* @
|
3432
|
-
* @
|
3433
|
-
* @api public
|
3561
|
+
* @param {Assertion} assertion the assertion to transfer the flags from
|
3562
|
+
* @param {Object} object the object to transfer the flags too; usually a new assertion
|
3563
|
+
* @param {Boolean} includeAll
|
3564
|
+
* @name getAllFlags
|
3565
|
+
* @api private
|
3434
3566
|
*/
|
3435
3567
|
|
3436
|
-
module.exports = function (
|
3437
|
-
|
3438
|
-
chainingBehavior = function () { };
|
3439
|
-
|
3440
|
-
Object.defineProperty(ctx, name,
|
3441
|
-
{ get: function () {
|
3442
|
-
chainingBehavior.call(this);
|
3568
|
+
module.exports = function (assertion, object, includeAll) {
|
3569
|
+
var flags = assertion.__flags || (assertion.__flags = Object.create(null));
|
3443
3570
|
|
3444
|
-
|
3445
|
-
|
3446
|
-
|
3447
|
-
};
|
3571
|
+
if (!object.__flags) {
|
3572
|
+
object.__flags = Object.create(null);
|
3573
|
+
}
|
3448
3574
|
|
3449
|
-
|
3450
|
-
var asserterNames = Object.getOwnPropertyNames(ctx);
|
3451
|
-
asserterNames.forEach(function (asserterName) {
|
3452
|
-
var pd = Object.getOwnPropertyDescriptor(ctx, asserterName)
|
3453
|
-
, functionProtoPD = Object.getOwnPropertyDescriptor(Function.prototype, asserterName);
|
3454
|
-
// Avoid trying to overwrite things that we can't, like `length` and `arguments`.
|
3455
|
-
if (functionProtoPD && !functionProtoPD.configurable) return;
|
3456
|
-
if (asserterName === 'arguments') return; // @see chaijs/chai/issues/69
|
3457
|
-
Object.defineProperty(assert, asserterName, pd);
|
3458
|
-
});
|
3575
|
+
includeAll = arguments.length === 3 ? includeAll : true;
|
3459
3576
|
|
3460
|
-
|
3461
|
-
|
3462
|
-
|
3463
|
-
|
3464
|
-
|
3577
|
+
for (var flag in flags) {
|
3578
|
+
if (includeAll ||
|
3579
|
+
(flag !== 'object' && flag !== 'ssfi' && flag != 'message')) {
|
3580
|
+
object.__flags[flag] = flags[flag];
|
3581
|
+
}
|
3582
|
+
}
|
3465
3583
|
};
|
3466
3584
|
|
3467
|
-
}); // module: chai/utils/
|
3585
|
+
}); // module: chai/utils/transferFlags.js
|
3468
3586
|
|
3469
3587
|
require.alias("./chai.js", "chai");
|
3470
3588
|
|
3471
3589
|
return require('chai');
|
3472
|
-
});
|
3590
|
+
});
|