jasmine-core 2.0.0.rc3 → 2.0.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. data/lib/console/console.js +160 -0
  2. data/lib/jasmine-core/boot.js +84 -8
  3. data/lib/jasmine-core/boot/boot.js +84 -8
  4. data/lib/jasmine-core/jasmine-html.js +6 -3
  5. data/lib/jasmine-core/jasmine.js +236 -260
  6. data/lib/jasmine-core/spec/core/AnySpec.js +1 -1
  7. data/lib/jasmine-core/spec/core/ClockSpec.js +0 -20
  8. data/lib/jasmine-core/spec/core/CustomMatchersSpec.js +149 -96
  9. data/lib/jasmine-core/spec/core/EnvSpec.js +7 -39
  10. data/lib/jasmine-core/spec/core/ExceptionsSpec.js +13 -19
  11. data/lib/jasmine-core/spec/core/ExpectationSpec.js +74 -1
  12. data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +0 -1
  13. data/lib/jasmine-core/spec/core/ObjectContainingSpec.js +1 -1
  14. data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +28 -20
  15. data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +1 -1
  16. data/lib/jasmine-core/spec/core/SpecRunningSpec.js +0 -1
  17. data/lib/jasmine-core/spec/core/SpecSpec.js +2 -11
  18. data/lib/jasmine-core/spec/core/SuiteSpec.js +2 -50
  19. data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +13 -1
  20. data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +4 -4
  21. data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +3 -2
  22. data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +1 -1
  23. data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +0 -1
  24. data/lib/jasmine-core/spec/html/QueryStringSpec.js +1 -1
  25. data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +1 -1
  26. data/lib/jasmine-core/spec/node_suite.js +13 -11
  27. data/lib/jasmine-core/spec/support/dev_boot.js +17 -6
  28. data/lib/jasmine-core/version.rb +1 -1
  29. metadata +41 -13
  30. checksums.yaml +0 -7
@@ -26,11 +26,12 @@ jasmineRequire.html = function(j$) {
26
26
  j$.QueryString = jasmineRequire.QueryString();
27
27
  j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
28
28
  };
29
+
29
30
  jasmineRequire.HtmlReporter = function(j$) {
30
31
 
31
32
  var noopTimer = {
32
- start: function(){},
33
- elapsed: function(){ return 0; }
33
+ start: function() {},
34
+ elapsed: function() { return 0; }
34
35
  };
35
36
 
36
37
  function HtmlReporter(options) {
@@ -101,7 +102,8 @@ jasmineRequire.HtmlReporter = function(j$) {
101
102
  symbols.appendChild(createDom("li", {
102
103
  className: result.status,
103
104
  id: "spec_" + result.id,
104
- title: result.fullName}
105
+ title: result.fullName
106
+ }
105
107
  ));
106
108
 
107
109
  if (result.status == "failed") {
@@ -307,6 +309,7 @@ jasmineRequire.ResultsNode = function() {
307
309
 
308
310
  return ResultsNode;
309
311
  };
312
+
310
313
  jasmineRequire.QueryString = function() {
311
314
  function QueryString(options) {
312
315
 
@@ -142,18 +142,18 @@ getJasmineRequireObj().base = function(j$) {
142
142
  j$.createSpy = function(name, originalFn) {
143
143
 
144
144
  var spyStrategy = new j$.SpyStrategy({
145
- name: name,
146
- fn: originalFn,
147
- getSpy: function() { return spy; }
148
- }),
149
- callTracker = new j$.CallTracker(),
150
- spy = function() {
151
- callTracker.track({
152
- object: this,
153
- args: Array.prototype.slice.apply(arguments)
154
- });
155
- return spyStrategy.exec.apply(this, arguments);
156
- };
145
+ name: name,
146
+ fn: originalFn,
147
+ getSpy: function() { return spy; }
148
+ }),
149
+ callTracker = new j$.CallTracker(),
150
+ spy = function() {
151
+ callTracker.track({
152
+ object: this,
153
+ args: Array.prototype.slice.apply(arguments)
154
+ });
155
+ return spyStrategy.exec.apply(this, arguments);
156
+ };
157
157
 
158
158
  for (var prop in originalFn) {
159
159
  if (prop === 'and' || prop === 'calls') {
@@ -174,7 +174,7 @@ getJasmineRequireObj().base = function(j$) {
174
174
  return false;
175
175
  }
176
176
  return putativeSpy.and instanceof j$.SpyStrategy &&
177
- putativeSpy.calls instanceof j$.CallTracker;
177
+ putativeSpy.calls instanceof j$.CallTracker;
178
178
  };
179
179
 
180
180
  j$.createSpyObj = function(baseName, methodNames) {
@@ -194,14 +194,16 @@ getJasmineRequireObj().util = function() {
194
194
  var util = {};
195
195
 
196
196
  util.inherit = function(childClass, parentClass) {
197
- var subclass = function() {
197
+ var Subclass = function() {
198
198
  };
199
- subclass.prototype = parentClass.prototype;
200
- childClass.prototype = new subclass();
199
+ Subclass.prototype = parentClass.prototype;
200
+ childClass.prototype = new Subclass();
201
201
  };
202
202
 
203
203
  util.htmlEscape = function(str) {
204
- if (!str) return str;
204
+ if (!str) {
205
+ return str;
206
+ }
205
207
  return str.replace(/&/g, '&')
206
208
  .replace(/</g, '&lt;')
207
209
  .replace(/>/g, '&gt;');
@@ -209,7 +211,9 @@ getJasmineRequireObj().util = function() {
209
211
 
210
212
  util.argsToArray = function(args) {
211
213
  var arrayOfArgs = [];
212
- for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
214
+ for (var i = 0; i < args.length; i++) {
215
+ arrayOfArgs.push(args[i]);
216
+ }
213
217
  return arrayOfArgs;
214
218
  };
215
219
 
@@ -222,7 +226,6 @@ getJasmineRequireObj().util = function() {
222
226
 
223
227
  getJasmineRequireObj().Spec = function(j$) {
224
228
  function Spec(attrs) {
225
- this.encounteredExpectations = false;
226
229
  this.expectationFactory = attrs.expectationFactory;
227
230
  this.resultCallback = attrs.resultCallback || function() {};
228
231
  this.id = attrs.id;
@@ -248,13 +251,11 @@ getJasmineRequireObj().Spec = function(j$) {
248
251
  id: this.id,
249
252
  description: this.description,
250
253
  fullName: this.getFullName(),
251
- status: this.status(),
252
254
  failedExpectations: []
253
255
  };
254
256
  }
255
257
 
256
258
  Spec.prototype.addExpectationResult = function(passed, data) {
257
- this.encounteredExpectations = true;
258
259
  if (passed) {
259
260
  return;
260
261
  }
@@ -278,7 +279,7 @@ getJasmineRequireObj().Spec = function(j$) {
278
279
  function timeoutable(fn) {
279
280
  return function(done) {
280
281
  var timeout = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() {
281
- onException(new Error('timeout'));
282
+ onException(new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'));
282
283
  done();
283
284
  }, j$.DEFAULT_TIMEOUT_INTERVAL]]);
284
285
 
@@ -292,8 +293,8 @@ getJasmineRequireObj().Spec = function(j$) {
292
293
  }
293
294
 
294
295
  var befores = this.beforeFns() || [],
295
- afters = this.afterFns() || [],
296
- thisOne = (this.fn.length) ? timeoutable(this.fn) : this.fn;
296
+ afters = this.afterFns() || [],
297
+ thisOne = (this.fn.length) ? timeoutable(this.fn) : this.fn;
297
298
  var allFns = befores.concat(thisOne).concat(afters);
298
299
 
299
300
  this.queueRunner({
@@ -303,18 +304,18 @@ getJasmineRequireObj().Spec = function(j$) {
303
304
  });
304
305
 
305
306
  function onException(e) {
306
- if (Spec.isPendingSpecException(e)) {
307
- self.pend();
308
- return;
309
- }
307
+ if (Spec.isPendingSpecException(e)) {
308
+ self.pend();
309
+ return;
310
+ }
310
311
 
311
- self.addExpectationResult(false, {
312
- matcherName: "",
313
- passed: false,
314
- expected: "",
315
- actual: "",
316
- error: e
317
- });
312
+ self.addExpectationResult(false, {
313
+ matcherName: "",
314
+ passed: false,
315
+ expected: "",
316
+ actual: "",
317
+ error: e
318
+ });
318
319
  }
319
320
 
320
321
  function complete() {
@@ -340,7 +341,7 @@ getJasmineRequireObj().Spec = function(j$) {
340
341
  return 'disabled';
341
342
  }
342
343
 
343
- if (this.markedPending || !this.encounteredExpectations) {
344
+ if (this.markedPending) {
344
345
  return 'pending';
345
346
  }
346
347
 
@@ -375,6 +376,8 @@ getJasmineRequireObj().Env = function(j$) {
375
376
  var self = this;
376
377
  var global = options.global || j$.getGlobal();
377
378
 
379
+ var totalSpecsDefined = 0;
380
+
378
381
  var catchExceptions = true;
379
382
 
380
383
  var realSetTimeout = j$.getGlobal().setTimeout;
@@ -385,9 +388,10 @@ getJasmineRequireObj().Env = function(j$) {
385
388
 
386
389
  var spies = [];
387
390
 
388
- this.currentSpec = null;
391
+ var currentSpec = null;
392
+ var currentSuite = null;
389
393
 
390
- this.reporter = new j$.ReportDispatcher([
394
+ var reporter = new j$.ReportDispatcher([
391
395
  "jasmineStarted",
392
396
  "jasmineDone",
393
397
  "suiteStarted",
@@ -396,14 +400,11 @@ getJasmineRequireObj().Env = function(j$) {
396
400
  "specDone"
397
401
  ]);
398
402
 
399
- this.lastUpdate = 0;
400
403
  this.specFilter = function() {
401
404
  return true;
402
405
  };
403
406
 
404
- this.nextSpecId_ = 0;
405
- this.nextSuiteId_ = 0;
406
- this.equalityTesters_ = [];
407
+ var equalityTesters = [];
407
408
 
408
409
  var customEqualityTesters = [];
409
410
  this.addCustomEqualityTester = function(tester) {
@@ -412,6 +413,16 @@ getJasmineRequireObj().Env = function(j$) {
412
413
 
413
414
  j$.Expectation.addCoreMatchers(j$.matchers);
414
415
 
416
+ var nextSpecId = 0;
417
+ var getNextSpecId = function() {
418
+ return 'spec' + nextSpecId++;
419
+ };
420
+
421
+ var nextSuiteId = 0;
422
+ var getNextSuiteId = function() {
423
+ return 'suite' + nextSuiteId++;
424
+ };
425
+
415
426
  var expectationFactory = function(actual, spec) {
416
427
  return j$.Expectation.Factory({
417
428
  util: j$.matchersUtil,
@@ -426,32 +437,34 @@ getJasmineRequireObj().Env = function(j$) {
426
437
  };
427
438
 
428
439
  var specStarted = function(spec) {
429
- self.currentSpec = spec;
430
- self.reporter.specStarted(spec.result);
440
+ currentSpec = spec;
441
+ reporter.specStarted(spec.result);
431
442
  };
432
443
 
433
- var beforeFns = function(currentSuite) {
444
+ var beforeFns = function(suite) {
434
445
  return function() {
435
446
  var befores = [];
436
- for (var suite = currentSuite; suite; suite = suite.parentSuite) {
447
+ while(suite) {
437
448
  befores = befores.concat(suite.beforeFns);
449
+ suite = suite.parentSuite;
438
450
  }
439
451
  return befores.reverse();
440
452
  };
441
453
  };
442
454
 
443
- var afterFns = function(currentSuite) {
455
+ var afterFns = function(suite) {
444
456
  return function() {
445
457
  var afters = [];
446
- for (var suite = currentSuite; suite; suite = suite.parentSuite) {
458
+ while(suite) {
447
459
  afters = afters.concat(suite.afterFns);
460
+ suite = suite.parentSuite;
448
461
  }
449
462
  return afters;
450
463
  };
451
464
  };
452
465
 
453
- var getSpecName = function(spec, currentSuite) {
454
- return currentSuite.getFullName() + ' ' + spec.description;
466
+ var getSpecName = function(spec, suite) {
467
+ return suite.getFullName() + ' ' + spec.description;
455
468
  };
456
469
 
457
470
  // TODO: we may just be able to pass in the fn instead of wrapping here
@@ -474,10 +487,6 @@ getJasmineRequireObj().Env = function(j$) {
474
487
  return catchExceptions;
475
488
  };
476
489
 
477
- this.catchException = function(e) {
478
- return j$.Spec.isPendingSpecException(e) || catchExceptions;
479
- };
480
-
481
490
  var maximumSpecCallbackDepth = 20;
482
491
  var currentSpecCallbackDepth = 0;
483
492
 
@@ -491,97 +500,33 @@ getJasmineRequireObj().Env = function(j$) {
491
500
  }
492
501
  }
493
502
 
494
- var queueRunnerFactory = function(options) {
495
- options.catchException = self.catchException;
496
- options.clearStack = options.clearStack || clearStack;
497
-
498
- new j$.QueueRunner(options).run(options.fns, 0);
503
+ var catchException = function(e) {
504
+ return j$.Spec.isPendingSpecException(e) || catchExceptions;
499
505
  };
500
506
 
501
- var totalSpecsDefined = 0;
502
- this.specFactory = function(description, fn, suite) {
503
- totalSpecsDefined++;
504
-
505
- var spec = new j$.Spec({
506
- id: self.nextSpecId(),
507
- beforeFns: beforeFns(suite),
508
- afterFns: afterFns(suite),
509
- expectationFactory: expectationFactory,
510
- exceptionFormatter: exceptionFormatter,
511
- resultCallback: specResultCallback,
512
- getSpecName: function(spec) {
513
- return getSpecName(spec, suite);
514
- },
515
- onStart: specStarted,
516
- description: description,
517
- expectationResultFactory: expectationResultFactory,
518
- queueRunner: queueRunnerFactory,
519
- fn: fn,
520
- timer: {setTimeout: realSetTimeout, clearTimeout: realClearTimeout}
521
- });
522
-
523
- runnableLookupTable[spec.id] = spec;
524
-
525
- if (!self.specFilter(spec)) {
526
- spec.disable();
527
- }
528
-
529
- return spec;
530
-
531
- function removeAllSpies() {
532
- for (var i = 0; i < spies.length; i++) {
533
- var spyEntry = spies[i];
534
- spyEntry.baseObj[spyEntry.methodName] = spyEntry.originalValue;
535
- }
536
- spies = [];
537
- }
538
-
539
- function specResultCallback(result) {
540
- removeAllSpies();
541
- j$.Expectation.resetMatchers();
542
- customEqualityTesters.length = 0;
543
- self.clock.uninstall();
544
- self.currentSpec = null;
545
- self.reporter.specDone(result);
546
- }
547
- };
507
+ var queueRunnerFactory = function(options) {
508
+ options.catchException = catchException;
509
+ options.clearStack = options.clearStack || clearStack;
548
510
 
549
- var suiteStarted = function(suite) {
550
- self.reporter.suiteStarted(suite.result);
511
+ new j$.QueueRunner(options).execute();
551
512
  };
552
513
 
553
- var suiteConstructor = j$.Suite;
554
-
555
- this.topSuite = new j$.Suite({
514
+ var topSuite = new j$.Suite({
556
515
  env: this,
557
- id: this.nextSuiteId(),
516
+ id: getNextSuiteId(),
558
517
  description: 'Jasmine__TopLevel__Suite',
559
518
  queueRunner: queueRunnerFactory,
560
- completeCallback: function() {}, // TODO - hook this up
561
519
  resultCallback: function() {} // TODO - hook this up
562
520
  });
563
- runnableLookupTable[this.topSuite.id] = this.topSuite;
564
- this.currentSuite = this.topSuite;
521
+ runnableLookupTable[topSuite.id] = topSuite;
522
+ currentSuite = topSuite;
565
523
 
566
- this.suiteFactory = function(description) {
567
- var suite = new suiteConstructor({
568
- env: self,
569
- id: self.nextSuiteId(),
570
- description: description,
571
- parentSuite: self.currentSuite,
572
- queueRunner: queueRunnerFactory,
573
- onStart: suiteStarted,
574
- resultCallback: function(attrs) {
575
- self.reporter.suiteDone(attrs);
576
- }
577
- });
578
-
579
- runnableLookupTable[suite.id] = suite;
580
- return suite;
524
+ this.topSuite = function() {
525
+ return topSuite;
581
526
  };
582
527
 
583
528
  this.execute = function(runnablesToRun) {
584
- runnablesToRun = runnablesToRun || [this.topSuite.id];
529
+ runnablesToRun = runnablesToRun || [topSuite.id];
585
530
 
586
531
  var allFns = [];
587
532
  for(var i = 0; i < runnablesToRun.length; i++) {
@@ -589,11 +534,19 @@ getJasmineRequireObj().Env = function(j$) {
589
534
  allFns.push((function(runnable) { return function(done) { runnable.execute(done); }; })(runnable));
590
535
  }
591
536
 
592
- this.reporter.jasmineStarted({
537
+ reporter.jasmineStarted({
593
538
  totalSpecsDefined: totalSpecsDefined
594
539
  });
595
540
 
596
- queueRunnerFactory({fns: allFns, onComplete: this.reporter.jasmineDone});
541
+ queueRunnerFactory({fns: allFns, onComplete: reporter.jasmineDone});
542
+ };
543
+
544
+ this.addReporter = function(reporterToAdd) {
545
+ reporter.addReporter(reporterToAdd);
546
+ };
547
+
548
+ this.addMatchers = function(matchersToAdd) {
549
+ j$.Expectation.addMatchers(matchersToAdd);
597
550
  };
598
551
 
599
552
  this.spyOn = function(obj, methodName) {
@@ -623,108 +576,133 @@ getJasmineRequireObj().Env = function(j$) {
623
576
 
624
577
  return spy;
625
578
  };
626
- }
627
579
 
628
- Env.prototype.addMatchers = function(matchersToAdd) {
629
- j$.Expectation.addMatchers(matchersToAdd);
630
- };
631
-
632
- Env.prototype.version = function() {
633
- return j$.version;
634
- };
580
+ var suiteFactory = function(description) {
581
+ var suite = new j$.Suite({
582
+ env: self,
583
+ id: getNextSuiteId(),
584
+ description: description,
585
+ parentSuite: currentSuite,
586
+ queueRunner: queueRunnerFactory,
587
+ onStart: suiteStarted,
588
+ resultCallback: function(attrs) {
589
+ reporter.suiteDone(attrs);
590
+ }
591
+ });
635
592
 
636
- Env.prototype.expect = function(actual) {
637
- return this.currentSpec.expect(actual);
638
- };
593
+ runnableLookupTable[suite.id] = suite;
594
+ return suite;
595
+ };
639
596
 
597
+ this.describe = function(description, specDefinitions) {
598
+ var suite = suiteFactory(description);
640
599
 
641
- // TODO: move this to closure
642
- Env.prototype.versionString = function() {
643
- console.log("DEPRECATED == use j$.version");
644
- return j$.version;
645
- };
600
+ var parentSuite = currentSuite;
601
+ parentSuite.addChild(suite);
602
+ currentSuite = suite;
646
603
 
647
- // TODO: move this to closure
648
- Env.prototype.nextSpecId = function() {
649
- return 'spec' + this.nextSpecId_++;
650
- };
604
+ var declarationError = null;
605
+ try {
606
+ specDefinitions.call(suite);
607
+ } catch (e) {
608
+ declarationError = e;
609
+ }
651
610
 
652
- // TODO: move this to closure
653
- Env.prototype.nextSuiteId = function() {
654
- return 'suite' + this.nextSuiteId_++;
655
- };
611
+ if (declarationError) {
612
+ this.it("encountered a declaration exception", function() {
613
+ throw declarationError;
614
+ });
615
+ }
656
616
 
657
- // TODO: move this to closure
658
- Env.prototype.addReporter = function(reporter) {
659
- this.reporter.addReporter(reporter);
660
- };
617
+ currentSuite = parentSuite;
661
618
 
662
- // TODO: move this to closure
663
- Env.prototype.describe = function(description, specDefinitions) {
664
- var suite = this.suiteFactory(description);
619
+ return suite;
620
+ };
665
621
 
666
- var parentSuite = this.currentSuite;
667
- parentSuite.addSuite(suite);
668
- this.currentSuite = suite;
622
+ this.xdescribe = function(description, specDefinitions) {
623
+ var suite = this.describe(description, specDefinitions);
624
+ suite.disable();
625
+ return suite;
626
+ };
669
627
 
670
- var declarationError = null;
671
- try {
672
- specDefinitions.call(suite);
673
- } catch (e) {
674
- declarationError = e;
675
- }
628
+ var specFactory = function(description, fn, suite) {
629
+ totalSpecsDefined++;
676
630
 
677
- if (declarationError) {
678
- this.it("encountered a declaration exception", function() {
679
- throw declarationError;
631
+ var spec = new j$.Spec({
632
+ id: getNextSpecId(),
633
+ beforeFns: beforeFns(suite),
634
+ afterFns: afterFns(suite),
635
+ expectationFactory: expectationFactory,
636
+ exceptionFormatter: exceptionFormatter,
637
+ resultCallback: specResultCallback,
638
+ getSpecName: function(spec) {
639
+ return getSpecName(spec, suite);
640
+ },
641
+ onStart: specStarted,
642
+ description: description,
643
+ expectationResultFactory: expectationResultFactory,
644
+ queueRunner: queueRunnerFactory,
645
+ fn: fn,
646
+ timer: {setTimeout: realSetTimeout, clearTimeout: realClearTimeout}
680
647
  });
681
- }
682
648
 
683
- this.currentSuite = parentSuite;
649
+ runnableLookupTable[spec.id] = spec;
684
650
 
685
- return suite;
686
- };
651
+ if (!self.specFilter(spec)) {
652
+ spec.disable();
653
+ }
687
654
 
688
- // TODO: move this to closure
689
- Env.prototype.xdescribe = function(description, specDefinitions) {
690
- var suite = this.describe(description, specDefinitions);
691
- suite.disable();
692
- return suite;
693
- };
655
+ return spec;
694
656
 
695
- // TODO: move this to closure
696
- Env.prototype.it = function(description, fn) {
697
- var spec = this.specFactory(description, fn, this.currentSuite);
698
- this.currentSuite.addSpec(spec);
699
- return spec;
700
- };
657
+ function removeAllSpies() {
658
+ for (var i = 0; i < spies.length; i++) {
659
+ var spyEntry = spies[i];
660
+ spyEntry.baseObj[spyEntry.methodName] = spyEntry.originalValue;
661
+ }
662
+ spies = [];
663
+ }
701
664
 
702
- // TODO: move this to closure
703
- Env.prototype.xit = function(description, fn) {
704
- var spec = this.it(description, fn);
705
- spec.pend();
706
- return spec;
707
- };
665
+ function specResultCallback(result) {
666
+ removeAllSpies();
667
+ j$.Expectation.resetMatchers();
668
+ customEqualityTesters = [];
669
+ currentSpec = null;
670
+ reporter.specDone(result);
671
+ }
672
+ };
708
673
 
709
- // TODO: move this to closure
710
- Env.prototype.beforeEach = function(beforeEachFunction) {
711
- this.currentSuite.beforeEach(beforeEachFunction);
712
- };
674
+ var suiteStarted = function(suite) {
675
+ reporter.suiteStarted(suite.result);
676
+ };
713
677
 
714
- // TODO: move this to closure
715
- Env.prototype.afterEach = function(afterEachFunction) {
716
- this.currentSuite.afterEach(afterEachFunction);
717
- };
678
+ this.it = function(description, fn) {
679
+ var spec = specFactory(description, fn, currentSuite);
680
+ currentSuite.addChild(spec);
681
+ return spec;
682
+ };
718
683
 
719
- // TODO: move this to closure
720
- Env.prototype.pending = function() {
721
- throw j$.Spec.pendingSpecExceptionMessage;
722
- };
684
+ this.xit = function(description, fn) {
685
+ var spec = this.it(description, fn);
686
+ spec.pend();
687
+ return spec;
688
+ };
723
689
 
724
- // TODO: Still needed?
725
- Env.prototype.currentRunner = function() {
726
- return this.topSuite;
727
- };
690
+ this.expect = function(actual) {
691
+ return currentSpec.expect(actual);
692
+ };
693
+
694
+ this.beforeEach = function(beforeEachFunction) {
695
+ currentSuite.beforeEach(beforeEachFunction);
696
+ };
697
+
698
+ this.afterEach = function(afterEachFunction) {
699
+ currentSuite.afterEach(afterEachFunction);
700
+ };
701
+
702
+ this.pending = function() {
703
+ throw j$.Spec.pendingSpecExceptionMessage;
704
+ };
705
+ }
728
706
 
729
707
  return Env;
730
708
  };
@@ -839,6 +817,7 @@ getJasmineRequireObj().Any = function() {
839
817
 
840
818
  return Any;
841
819
  };
820
+
842
821
  getJasmineRequireObj().CallTracker = function() {
843
822
 
844
823
  function CallTracker() {
@@ -905,7 +884,8 @@ getJasmineRequireObj().Clock = function() {
905
884
  setInterval: setInterval,
906
885
  clearInterval: clearInterval
907
886
  },
908
- installed = false;
887
+ installed = false,
888
+ timer;
909
889
 
910
890
  self.install = function() {
911
891
  replace(global, fakeTimingFunctions);
@@ -952,7 +932,7 @@ getJasmineRequireObj().Clock = function() {
952
932
  if (installed) {
953
933
  delayedFunctionScheduler.tick(millis);
954
934
  } else {
955
- throw new Error("Mock clock is not installed, use jasmine.getEnv().clock.install()");
935
+ throw new Error("Mock clock is not installed, use jasmine.clock().install()");
956
936
  }
957
937
  };
958
938
 
@@ -960,8 +940,6 @@ getJasmineRequireObj().Clock = function() {
960
940
 
961
941
  function legacyIE() {
962
942
  //if these methods are polyfilled, apply will be present
963
- //TODO: it may be difficult to load the polyfill before jasmine loads
964
- //(env should be new-ed inside of onload)
965
943
  return !(realTimingFunctions.setTimeout || realTimingFunctions.setInterval).apply;
966
944
  }
967
945
 
@@ -1163,12 +1141,21 @@ getJasmineRequireObj().Expectation = function() {
1163
1141
 
1164
1142
  args.unshift(this.actual);
1165
1143
 
1166
- var result = matcherFactory(this.util, this.customEqualityTesters).compare.apply(null, args);
1144
+ var matcher = matcherFactory(this.util, this.customEqualityTesters),
1145
+ matcherCompare = matcher.compare;
1167
1146
 
1168
- if (this.isNot) {
1147
+ function defaultNegativeCompare() {
1148
+ var result = matcher.compare.apply(null, args);
1169
1149
  result.pass = !result.pass;
1150
+ return result;
1151
+ }
1152
+
1153
+ if (this.isNot) {
1154
+ matcherCompare = matcher.negativeCompare || defaultNegativeCompare;
1170
1155
  }
1171
1156
 
1157
+ var result = matcherCompare.apply(null, args);
1158
+
1172
1159
  if (!result.pass) {
1173
1160
  if (!result.message) {
1174
1161
  args.unshift(this.isNot);
@@ -1364,8 +1351,8 @@ getJasmineRequireObj().pp = function(j$) {
1364
1351
 
1365
1352
  PrettyPrinter.prototype.iterateObject = function(obj, fn) {
1366
1353
  for (var property in obj) {
1367
- if (!obj.hasOwnProperty(property)) continue;
1368
- if (property == '__Jasmine_been_here_before__') continue;
1354
+ if (!obj.hasOwnProperty(property)) { continue; }
1355
+ if (property == '__Jasmine_been_here_before__') { continue; }
1369
1356
  fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) &&
1370
1357
  obj.__lookupGetter__(property) !== null) : false);
1371
1358
  }
@@ -1522,11 +1509,11 @@ getJasmineRequireObj().ReportDispatcher = function() {
1522
1509
 
1523
1510
  for (var i = 0; i < dispatchedMethods.length; i++) {
1524
1511
  var method = dispatchedMethods[i];
1525
- this[method] = function(m) {
1512
+ this[method] = (function(m) {
1526
1513
  return function() {
1527
1514
  dispatch(m, arguments);
1528
1515
  };
1529
- }(method);
1516
+ }(method));
1530
1517
  }
1531
1518
 
1532
1519
  var reporters = [];
@@ -1610,7 +1597,6 @@ getJasmineRequireObj().Suite = function() {
1610
1597
  this.parentSuite = attrs.parentSuite;
1611
1598
  this.description = attrs.description;
1612
1599
  this.onStart = attrs.onStart || function() {};
1613
- this.completeCallback = attrs.completeCallback || function() {}; // TODO: this is unused
1614
1600
  this.resultCallback = attrs.resultCallback || function() {};
1615
1601
  this.clearStack = attrs.clearStack || function(fn) {fn();};
1616
1602
 
@@ -1619,9 +1605,7 @@ getJasmineRequireObj().Suite = function() {
1619
1605
  this.queueRunner = attrs.queueRunner || function() {};
1620
1606
  this.disabled = false;
1621
1607
 
1622
- this.children_ = []; // TODO: rename
1623
- this.suites = []; // TODO: needed?
1624
- this.specs = []; // TODO: needed?
1608
+ this.children = [];
1625
1609
 
1626
1610
  this.result = {
1627
1611
  id: this.id,
@@ -1653,19 +1637,8 @@ getJasmineRequireObj().Suite = function() {
1653
1637
  this.afterFns.unshift(fn);
1654
1638
  };
1655
1639
 
1656
- Suite.prototype.addSpec = function(spec) {
1657
- this.children_.push(spec);
1658
- this.specs.push(spec); // TODO: needed?
1659
- };
1660
-
1661
- Suite.prototype.addSuite = function(suite) {
1662
- suite.parentSuite = this;
1663
- this.children_.push(suite);
1664
- this.suites.push(suite); // TODO: needed?
1665
- };
1666
-
1667
- Suite.prototype.children = function() {
1668
- return this.children_;
1640
+ Suite.prototype.addChild = function(child) {
1641
+ this.children.push(child);
1669
1642
  };
1670
1643
 
1671
1644
  Suite.prototype.execute = function(onComplete) {
@@ -1675,11 +1648,10 @@ getJasmineRequireObj().Suite = function() {
1675
1648
  return;
1676
1649
  }
1677
1650
 
1678
- var allFns = [],
1679
- children = this.children_;
1651
+ var allFns = [];
1680
1652
 
1681
- for (var i = 0; i < children.length; i++) {
1682
- allFns.push(wrapChildAsAsync(children[i]));
1653
+ for (var i = 0; i < this.children.length; i++) {
1654
+ allFns.push(wrapChildAsAsync(this.children[i]));
1683
1655
  }
1684
1656
 
1685
1657
  this.onStart(this);
@@ -1701,7 +1673,7 @@ getJasmineRequireObj().Suite = function() {
1701
1673
  return function(done) { child.execute(done); };
1702
1674
  }
1703
1675
  };
1704
-
1676
+
1705
1677
  return Suite;
1706
1678
  };
1707
1679
 
@@ -1727,6 +1699,7 @@ getJasmineRequireObj().Timer = function() {
1727
1699
 
1728
1700
  return Timer;
1729
1701
  };
1702
+
1730
1703
  getJasmineRequireObj().matchersUtil = function(j$) {
1731
1704
  // TODO: what to do about jasmine.pp not being inject? move to JSON.stringify? gut PrettyPrinter?
1732
1705
 
@@ -1766,7 +1739,9 @@ getJasmineRequireObj().matchersUtil = function(j$) {
1766
1739
 
1767
1740
  if (expected.length > 0) {
1768
1741
  for (var i = 0; i < expected.length; i++) {
1769
- if (i > 0) message += ",";
1742
+ if (i > 0) {
1743
+ message += ",";
1744
+ }
1770
1745
  message += " " + j$.pp(expected[i]);
1771
1746
  }
1772
1747
  }
@@ -1781,9 +1756,9 @@ getJasmineRequireObj().matchersUtil = function(j$) {
1781
1756
  var result = true;
1782
1757
 
1783
1758
  for (var i = 0; i < customTesters.length; i++) {
1784
- result = customTesters[i](a, b);
1785
- if (result) {
1786
- return true;
1759
+ var customTesterResult = customTesters[i](a, b);
1760
+ if (!j$.util.isUndefined(customTesterResult)) {
1761
+ return customTesterResult;
1787
1762
  }
1788
1763
  }
1789
1764
 
@@ -1814,11 +1789,11 @@ getJasmineRequireObj().matchersUtil = function(j$) {
1814
1789
 
1815
1790
  // Identical objects are equal. `0 === -0`, but they aren't identical.
1816
1791
  // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
1817
- if (a === b) return a !== 0 || 1 / a == 1 / b;
1792
+ if (a === b) { return a !== 0 || 1 / a == 1 / b; }
1818
1793
  // A strict comparison is necessary because `null == undefined`.
1819
- if (a === null || b === null) return a === b;
1794
+ if (a === null || b === null) { return a === b; }
1820
1795
  var className = Object.prototype.toString.call(a);
1821
- if (className != Object.prototype.toString.call(b)) return false;
1796
+ if (className != Object.prototype.toString.call(b)) { return false; }
1822
1797
  switch (className) {
1823
1798
  // Strings, numbers, dates, and booleans are compared by value.
1824
1799
  case '[object String]':
@@ -1842,14 +1817,14 @@ getJasmineRequireObj().matchersUtil = function(j$) {
1842
1817
  a.multiline == b.multiline &&
1843
1818
  a.ignoreCase == b.ignoreCase;
1844
1819
  }
1845
- if (typeof a != 'object' || typeof b != 'object') return false;
1820
+ if (typeof a != 'object' || typeof b != 'object') { return false; }
1846
1821
  // Assume equality for cyclic structures. The algorithm for detecting cyclic
1847
1822
  // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
1848
1823
  var length = aStack.length;
1849
1824
  while (length--) {
1850
1825
  // Linear search. Performance is inversely proportional to the number of
1851
1826
  // unique nested structures.
1852
- if (aStack[length] == a) return bStack[length] == b;
1827
+ if (aStack[length] == a) { return bStack[length] == b; }
1853
1828
  }
1854
1829
  // Add the first object to the stack of traversed objects.
1855
1830
  aStack.push(a);
@@ -1863,7 +1838,7 @@ getJasmineRequireObj().matchersUtil = function(j$) {
1863
1838
  if (result) {
1864
1839
  // Deep compare the contents, ignoring non-numeric properties.
1865
1840
  while (size--) {
1866
- if (!(result = eq(a[size], b[size], aStack, bStack, customTesters))) break;
1841
+ if (!(result = eq(a[size], b[size], aStack, bStack, customTesters))) { break; }
1867
1842
  }
1868
1843
  }
1869
1844
  } else {
@@ -1880,13 +1855,13 @@ getJasmineRequireObj().matchersUtil = function(j$) {
1880
1855
  // Count the expected number of properties.
1881
1856
  size++;
1882
1857
  // Deep compare each member.
1883
- if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters))) break;
1858
+ if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters))) { break; }
1884
1859
  }
1885
1860
  }
1886
1861
  // Ensure that both objects contain the same number of properties.
1887
1862
  if (result) {
1888
1863
  for (key in b) {
1889
- if (has(b, key) && !(size--)) break;
1864
+ if (has(b, key) && !(size--)) { break; }
1890
1865
  }
1891
1866
  result = !size;
1892
1867
  }
@@ -1906,6 +1881,7 @@ getJasmineRequireObj().matchersUtil = function(j$) {
1906
1881
  }
1907
1882
  }
1908
1883
  };
1884
+
1909
1885
  getJasmineRequireObj().toBe = function() {
1910
1886
  function toBe() {
1911
1887
  return {
@@ -2387,5 +2363,5 @@ getJasmineRequireObj().toThrowError = function(j$) {
2387
2363
  };
2388
2364
 
2389
2365
  getJasmineRequireObj().version = function() {
2390
- return "2.0.0-rc2";
2391
- };
2366
+ return "2.0.0-rc5";
2367
+ };