qedproject 0.2.1 → 0.3.0

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.
@@ -34,7 +34,7 @@ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
34
34
  this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
35
35
  this.createDom('div', { className: 'banner' },
36
36
  this.createDom('div', { className: 'logo' },
37
- this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
37
+ this.createDom('span', { className: 'title' }, "Jasmine"),
38
38
  this.createDom('span', { className: 'version' }, runner.env.versionString())),
39
39
  this.createDom('div', { className: 'options' },
40
40
  "Show ",
@@ -110,7 +110,7 @@ jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
110
110
  jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
111
111
  var results = suite.results();
112
112
  var status = results.passed() ? 'passed' : 'failed';
113
- if (results.totalCount == 0) { // todo: change this to check results.skipped
113
+ if (results.totalCount === 0) { // todo: change this to check results.skipped
114
114
  status = 'skipped';
115
115
  }
116
116
  this.suiteDivs[suite.id].className += " " + status;
@@ -183,6 +183,8 @@ jasmine.TrivialReporter.prototype.specFilter = function(spec) {
183
183
  paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
184
184
  }
185
185
 
186
- if (!paramMap["spec"]) return true;
187
- return spec.getFullName().indexOf(paramMap["spec"]) == 0;
186
+ if (!paramMap.spec) {
187
+ return true;
188
+ }
189
+ return spec.getFullName().indexOf(paramMap.spec) === 0;
188
190
  };
@@ -1,10 +1,12 @@
1
+ var isCommonJS = typeof window == "undefined";
2
+
1
3
  /**
2
4
  * Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
3
5
  *
4
6
  * @namespace
5
7
  */
6
8
  var jasmine = {};
7
-
9
+ if (isCommonJS) exports.jasmine = jasmine;
8
10
  /**
9
11
  * @private
10
12
  */
@@ -20,6 +22,12 @@ jasmine.unimplementedMethod_ = function() {
20
22
  */
21
23
  jasmine.undefined = jasmine.___undefined___;
22
24
 
25
+ /**
26
+ * Show diagnostic messages in the console if set to true
27
+ *
28
+ */
29
+ jasmine.VERBOSE = false;
30
+
23
31
  /**
24
32
  * Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed.
25
33
  *
@@ -72,7 +80,7 @@ jasmine.MessageResult = function(values) {
72
80
 
73
81
  jasmine.MessageResult.prototype.toString = function() {
74
82
  var text = "";
75
- for(var i = 0; i < this.values.length; i++) {
83
+ for (var i = 0; i < this.values.length; i++) {
76
84
  if (i > 0) text += " ";
77
85
  if (jasmine.isString_(this.values[i])) {
78
86
  text += this.values[i];
@@ -89,9 +97,10 @@ jasmine.ExpectationResult = function(params) {
89
97
  this.passed_ = params.passed;
90
98
  this.expected = params.expected;
91
99
  this.actual = params.actual;
92
-
93
100
  this.message = this.passed_ ? 'Passed.' : params.message;
94
- this.trace = this.passed_ ? '' : new Error(this.message);
101
+
102
+ var trace = (params.trace || new Error(this.message));
103
+ this.trace = this.passed_ ? '' : trace;
95
104
  };
96
105
 
97
106
  jasmine.ExpectationResult.prototype.toString = function () {
@@ -106,7 +115,8 @@ jasmine.ExpectationResult.prototype.passed = function () {
106
115
  * Getter for the Jasmine environment. Ensures one gets created
107
116
  */
108
117
  jasmine.getEnv = function() {
109
- return jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
118
+ var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
119
+ return env;
110
120
  };
111
121
 
112
122
  /**
@@ -116,7 +126,7 @@ jasmine.getEnv = function() {
116
126
  * @returns {Boolean}
117
127
  */
118
128
  jasmine.isArray_ = function(value) {
119
- return jasmine.isA_("Array", value);
129
+ return jasmine.isA_("Array", value);
120
130
  };
121
131
 
122
132
  /**
@@ -169,7 +179,7 @@ jasmine.pp = function(value) {
169
179
  * @returns {Boolean}
170
180
  */
171
181
  jasmine.isDomNode = function(obj) {
172
- return obj['nodeType'] > 0;
182
+ return obj.nodeType > 0;
173
183
  };
174
184
 
175
185
  /**
@@ -405,7 +415,7 @@ jasmine.isSpy = function(putativeSpy) {
405
415
  * @param {Array} methodNames array of names of methods to make spies
406
416
  */
407
417
  jasmine.createSpyObj = function(baseName, methodNames) {
408
- if (!jasmine.isArray_(methodNames) || methodNames.length == 0) {
418
+ if (!jasmine.isArray_(methodNames) || methodNames.length === 0) {
409
419
  throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
410
420
  }
411
421
  var obj = {};
@@ -443,6 +453,7 @@ jasmine.log = function() {
443
453
  var spyOn = function(obj, methodName) {
444
454
  return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
445
455
  };
456
+ if (isCommonJS) exports.spyOn = spyOn;
446
457
 
447
458
  /**
448
459
  * Creates a Jasmine spec that will be added to the current suite.
@@ -460,6 +471,7 @@ var spyOn = function(obj, methodName) {
460
471
  var it = function(desc, func) {
461
472
  return jasmine.getEnv().it(desc, func);
462
473
  };
474
+ if (isCommonJS) exports.it = it;
463
475
 
464
476
  /**
465
477
  * Creates a <em>disabled</em> Jasmine spec.
@@ -472,6 +484,7 @@ var it = function(desc, func) {
472
484
  var xit = function(desc, func) {
473
485
  return jasmine.getEnv().xit(desc, func);
474
486
  };
487
+ if (isCommonJS) exports.xit = xit;
475
488
 
476
489
  /**
477
490
  * Starts a chain for a Jasmine expectation.
@@ -484,6 +497,7 @@ var xit = function(desc, func) {
484
497
  var expect = function(actual) {
485
498
  return jasmine.getEnv().currentSpec.expect(actual);
486
499
  };
500
+ if (isCommonJS) exports.expect = expect;
487
501
 
488
502
  /**
489
503
  * Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs.
@@ -493,6 +507,7 @@ var expect = function(actual) {
493
507
  var runs = function(func) {
494
508
  jasmine.getEnv().currentSpec.runs(func);
495
509
  };
510
+ if (isCommonJS) exports.runs = runs;
496
511
 
497
512
  /**
498
513
  * Waits a fixed time period before moving to the next block.
@@ -503,6 +518,7 @@ var runs = function(func) {
503
518
  var waits = function(timeout) {
504
519
  jasmine.getEnv().currentSpec.waits(timeout);
505
520
  };
521
+ if (isCommonJS) exports.waits = waits;
506
522
 
507
523
  /**
508
524
  * Waits for the latchFunction to return true before proceeding to the next block.
@@ -514,6 +530,7 @@ var waits = function(timeout) {
514
530
  var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
515
531
  jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);
516
532
  };
533
+ if (isCommonJS) exports.waitsFor = waitsFor;
517
534
 
518
535
  /**
519
536
  * A function that is called before each spec in a suite.
@@ -525,6 +542,7 @@ var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout
525
542
  var beforeEach = function(beforeEachFunction) {
526
543
  jasmine.getEnv().beforeEach(beforeEachFunction);
527
544
  };
545
+ if (isCommonJS) exports.beforeEach = beforeEach;
528
546
 
529
547
  /**
530
548
  * A function that is called after each spec in a suite.
@@ -536,6 +554,7 @@ var beforeEach = function(beforeEachFunction) {
536
554
  var afterEach = function(afterEachFunction) {
537
555
  jasmine.getEnv().afterEach(afterEachFunction);
538
556
  };
557
+ if (isCommonJS) exports.afterEach = afterEach;
539
558
 
540
559
  /**
541
560
  * Defines a suite of specifications.
@@ -555,6 +574,7 @@ var afterEach = function(afterEachFunction) {
555
574
  var describe = function(description, specDefinitions) {
556
575
  return jasmine.getEnv().describe(description, specDefinitions);
557
576
  };
577
+ if (isCommonJS) exports.describe = describe;
558
578
 
559
579
  /**
560
580
  * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
@@ -565,27 +585,35 @@ var describe = function(description, specDefinitions) {
565
585
  var xdescribe = function(description, specDefinitions) {
566
586
  return jasmine.getEnv().xdescribe(description, specDefinitions);
567
587
  };
588
+ if (isCommonJS) exports.xdescribe = xdescribe;
568
589
 
569
590
 
570
591
  // Provide the XMLHttpRequest class for IE 5.x-6.x:
571
592
  jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
572
- try {
573
- return new ActiveXObject("Msxml2.XMLHTTP.6.0");
574
- } catch(e) {
575
- }
576
- try {
577
- return new ActiveXObject("Msxml2.XMLHTTP.3.0");
578
- } catch(e) {
579
- }
580
- try {
581
- return new ActiveXObject("Msxml2.XMLHTTP");
582
- } catch(e) {
583
- }
584
- try {
585
- return new ActiveXObject("Microsoft.XMLHTTP");
586
- } catch(e) {
593
+ function tryIt(f) {
594
+ try {
595
+ return f();
596
+ } catch(e) {
597
+ }
598
+ return null;
587
599
  }
588
- throw new Error("This browser does not support XMLHttpRequest.");
600
+
601
+ var xhr = tryIt(function() {
602
+ return new ActiveXObject("Msxml2.XMLHTTP.6.0");
603
+ }) ||
604
+ tryIt(function() {
605
+ return new ActiveXObject("Msxml2.XMLHTTP.3.0");
606
+ }) ||
607
+ tryIt(function() {
608
+ return new ActiveXObject("Msxml2.XMLHTTP");
609
+ }) ||
610
+ tryIt(function() {
611
+ return new ActiveXObject("Microsoft.XMLHTTP");
612
+ });
613
+
614
+ if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
615
+
616
+ return xhr;
589
617
  } : XMLHttpRequest;
590
618
  /**
591
619
  * @namespace
@@ -606,7 +634,7 @@ jasmine.util.inherit = function(childClass, parentClass) {
606
634
  var subclass = function() {
607
635
  };
608
636
  subclass.prototype = parentClass.prototype;
609
- childClass.prototype = new subclass;
637
+ childClass.prototype = new subclass();
610
638
  };
611
639
 
612
640
  jasmine.util.formatException = function(e) {
@@ -707,12 +735,17 @@ jasmine.Env.prototype.version = function () {
707
735
  * @returns string containing jasmine version build info, if set.
708
736
  */
709
737
  jasmine.Env.prototype.versionString = function() {
710
- if (jasmine.version_) {
711
- var version = this.version();
712
- return version.major + "." + version.minor + "." + version.build + " revision " + version.revision;
713
- } else {
738
+ if (!jasmine.version_) {
714
739
  return "version unknown";
715
740
  }
741
+
742
+ var version = this.version();
743
+ var versionString = version.major + "." + version.minor + "." + version.build;
744
+ if (version.release_candidate) {
745
+ versionString += ".rc" + version.release_candidate;
746
+ }
747
+ versionString += " revision " + version.revision;
748
+ return versionString;
716
749
  };
717
750
 
718
751
  /**
@@ -760,14 +793,14 @@ jasmine.Env.prototype.describe = function(description, specDefinitions) {
760
793
  declarationError = e;
761
794
  }
762
795
 
763
- this.currentSuite = parentSuite;
764
-
765
796
  if (declarationError) {
766
797
  this.it("encountered a declaration exception", function() {
767
798
  throw declarationError;
768
799
  });
769
800
  }
770
801
 
802
+ this.currentSuite = parentSuite;
803
+
771
804
  return suite;
772
805
  };
773
806
 
@@ -828,7 +861,7 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal
828
861
  b.__Jasmine_been_here_before__ = a;
829
862
 
830
863
  var hasKey = function(obj, keyName) {
831
- return obj != null && obj[keyName] !== jasmine.undefined;
864
+ return obj !== null && obj[keyName] !== jasmine.undefined;
832
865
  };
833
866
 
834
867
  for (var property in b) {
@@ -854,7 +887,7 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal
854
887
 
855
888
  delete a.__Jasmine_been_here_before__;
856
889
  delete b.__Jasmine_been_here_before__;
857
- return (mismatchKeys.length == 0 && mismatchValues.length == 0);
890
+ return (mismatchKeys.length === 0 && mismatchValues.length === 0);
858
891
  };
859
892
 
860
893
  jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
@@ -1302,16 +1335,16 @@ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
1302
1335
  throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
1303
1336
  }
1304
1337
  this.message = function() {
1305
- if (this.actual.callCount == 0) {
1338
+ if (this.actual.callCount === 0) {
1306
1339
  // todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
1307
1340
  return [
1308
- "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
1309
- "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
1341
+ "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
1342
+ "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
1310
1343
  ];
1311
1344
  } else {
1312
1345
  return [
1313
- "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
1314
- "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
1346
+ "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
1347
+ "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
1315
1348
  ];
1316
1349
  }
1317
1350
  };
@@ -1333,7 +1366,7 @@ jasmine.Matchers.prototype.wasNotCalledWith = function() {
1333
1366
  return [
1334
1367
  "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",
1335
1368
  "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"
1336
- ]
1369
+ ];
1337
1370
  };
1338
1371
 
1339
1372
  return !this.env.contains_(this.actual.argsForCall, expectedArgs);
@@ -1366,6 +1399,23 @@ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
1366
1399
  return this.actual > expected;
1367
1400
  };
1368
1401
 
1402
+ /**
1403
+ * Matcher that checks that the expected item is equal to the actual item
1404
+ * up to a given level of decimal precision (default 2).
1405
+ *
1406
+ * @param {Number} expected
1407
+ * @param {Number} precision
1408
+ */
1409
+ jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
1410
+ if (!(precision === 0)) {
1411
+ precision = precision || 2;
1412
+ }
1413
+ var multiplier = Math.pow(10, precision);
1414
+ var actual = Math.round(this.actual * multiplier);
1415
+ expected = Math.round(expected * multiplier);
1416
+ return expected == actual;
1417
+ };
1418
+
1369
1419
  /**
1370
1420
  * Matcher that checks that the expected exception was thrown by the actual.
1371
1421
  *
@@ -1390,7 +1440,7 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
1390
1440
 
1391
1441
  this.message = function() {
1392
1442
  if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
1393
- return ["Expected function " + not + "to throw", expected ? expected.message || expected : " an exception", ", but it threw", exception.message || exception].join(' ');
1443
+ return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
1394
1444
  } else {
1395
1445
  return "Expected function to throw an exception.";
1396
1446
  }
@@ -1602,7 +1652,8 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
1602
1652
  jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
1603
1653
  for (var property in obj) {
1604
1654
  if (property == '__Jasmine_been_here_before__') continue;
1605
- fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false);
1655
+ fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
1656
+ obj.__lookupGetter__(property) !== null) : false);
1606
1657
  }
1607
1658
  };
1608
1659
 
@@ -1962,7 +2013,8 @@ jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessag
1962
2013
  jasmine.Spec.prototype.fail = function (e) {
1963
2014
  var expectationResult = new jasmine.ExpectationResult({
1964
2015
  passed: false,
1965
- message: e ? jasmine.util.formatException(e) : 'Exception'
2016
+ message: e ? jasmine.util.formatException(e) : 'Exception',
2017
+ trace: { stack: e.stack }
1966
2018
  });
1967
2019
  this.results_.addResult(expectationResult);
1968
2020
  };
@@ -2172,7 +2224,9 @@ jasmine.WaitsBlock = function(env, timeout, spec) {
2172
2224
  jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
2173
2225
 
2174
2226
  jasmine.WaitsBlock.prototype.execute = function (onComplete) {
2175
- this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
2227
+ if (jasmine.VERBOSE) {
2228
+ this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
2229
+ }
2176
2230
  this.env.setTimeout(function () {
2177
2231
  onComplete();
2178
2232
  }, this.timeout);
@@ -2200,7 +2254,9 @@ jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);
2200
2254
  jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10;
2201
2255
 
2202
2256
  jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
2203
- this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
2257
+ if (jasmine.VERBOSE) {
2258
+ this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
2259
+ }
2204
2260
  var latchFunctionResult;
2205
2261
  try {
2206
2262
  latchFunctionResult = this.latchFunction.apply(this.spec);
@@ -2412,10 +2468,9 @@ jasmine.getGlobal().clearInterval = function(timeoutKey) {
2412
2468
  }
2413
2469
  };
2414
2470
 
2415
-
2416
2471
  jasmine.version_= {
2417
2472
  "major": 1,
2418
- "minor": 0,
2419
- "build": 2,
2420
- "revision": 1298837858
2473
+ "minor": 1,
2474
+ "build": 0,
2475
+ "revision": 1315677058
2421
2476
  };
Binary file
Binary file
Binary file
Binary file
Binary file