evergreen 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/README.rdoc +4 -0
  2. data/bin/evergreen +18 -0
  3. data/lib/evergreen.rb +44 -0
  4. data/lib/evergreen/cli.rb +23 -0
  5. data/lib/evergreen/evergreen.js +3 -0
  6. data/lib/evergreen/runner.rb +56 -0
  7. data/lib/evergreen/server.rb +31 -0
  8. data/lib/evergreen/spec.rb +60 -0
  9. data/lib/evergreen/version.rb +3 -0
  10. data/lib/evergreen/views/list.erb +6 -0
  11. data/lib/evergreen/views/spec.erb +37 -0
  12. data/lib/jasmine/MIT.LICENSE +20 -0
  13. data/lib/jasmine/README.markdown +489 -0
  14. data/lib/jasmine/Rakefile +146 -0
  15. data/lib/jasmine/cruise_config.rb +21 -0
  16. data/lib/jasmine/doc/files.html +460 -0
  17. data/lib/jasmine/doc/index.html +322 -0
  18. data/lib/jasmine/doc/symbols/_global_.html +918 -0
  19. data/lib/jasmine/doc/symbols/jasmine.Block.html +417 -0
  20. data/lib/jasmine/doc/symbols/jasmine.Clock.html +678 -0
  21. data/lib/jasmine/doc/symbols/jasmine.Env.html +1169 -0
  22. data/lib/jasmine/doc/symbols/jasmine.JsApiReporter.html +822 -0
  23. data/lib/jasmine/doc/symbols/jasmine.Matchers.html +1474 -0
  24. data/lib/jasmine/doc/symbols/jasmine.MultiReporter.html +394 -0
  25. data/lib/jasmine/doc/symbols/jasmine.NestedResults.html +710 -0
  26. data/lib/jasmine/doc/symbols/jasmine.Reporter.html +574 -0
  27. data/lib/jasmine/doc/symbols/jasmine.Runner.html +710 -0
  28. data/lib/jasmine/doc/symbols/jasmine.Spec.html +1253 -0
  29. data/lib/jasmine/doc/symbols/jasmine.Spy.html +855 -0
  30. data/lib/jasmine/doc/symbols/jasmine.Suite.html +705 -0
  31. data/lib/jasmine/doc/symbols/jasmine.html +1345 -0
  32. data/lib/jasmine/doc/symbols/jasmine.util.html +535 -0
  33. data/lib/jasmine/doc/symbols/src/lib_TrivialReporter.js.html +124 -0
  34. data/lib/jasmine/doc/symbols/src/src_Block.js.html +29 -0
  35. data/lib/jasmine/doc/symbols/src/src_Env.js.html +248 -0
  36. data/lib/jasmine/doc/symbols/src/src_JsApiReporter.js.html +111 -0
  37. data/lib/jasmine/doc/symbols/src/src_Matchers.js.html +344 -0
  38. data/lib/jasmine/doc/symbols/src/src_MultiReporter.js.html +36 -0
  39. data/lib/jasmine/doc/symbols/src/src_NestedResults.js.html +88 -0
  40. data/lib/jasmine/doc/symbols/src/src_PrettyPrinter.js.html +130 -0
  41. data/lib/jasmine/doc/symbols/src/src_Queue.js.html +102 -0
  42. data/lib/jasmine/doc/symbols/src/src_Reporter.js.html +35 -0
  43. data/lib/jasmine/doc/symbols/src/src_Reporters.js.html +51 -0
  44. data/lib/jasmine/doc/symbols/src/src_Runner.js.html +75 -0
  45. data/lib/jasmine/doc/symbols/src/src_Spec.js.html +214 -0
  46. data/lib/jasmine/doc/symbols/src/src_Suite.js.html +77 -0
  47. data/lib/jasmine/doc/symbols/src/src_WaitsBlock.js.html +21 -0
  48. data/lib/jasmine/doc/symbols/src/src_WaitsForBlock.js.html +45 -0
  49. data/lib/jasmine/doc/symbols/src/src_base.js.html +585 -0
  50. data/lib/jasmine/doc/symbols/src/src_mock-timeout.js.html +185 -0
  51. data/lib/jasmine/doc/symbols/src/src_util.js.html +75 -0
  52. data/lib/jasmine/example/example_runner.html +22 -0
  53. data/lib/jasmine/example/spec/example_suite.js +11 -0
  54. data/lib/jasmine/images/fail-16.png +0 -0
  55. data/lib/jasmine/images/fail.png +0 -0
  56. data/lib/jasmine/images/go-16.png +0 -0
  57. data/lib/jasmine/images/go.png +0 -0
  58. data/lib/jasmine/images/pending-16.png +0 -0
  59. data/lib/jasmine/images/pending.png +0 -0
  60. data/lib/jasmine/images/question-bk.png +0 -0
  61. data/lib/jasmine/images/questionbk-16.png +0 -0
  62. data/lib/jasmine/images/spinner.gif +0 -0
  63. data/lib/jasmine/lib/TrivialReporter.js +171 -0
  64. data/lib/jasmine/lib/consolex.js +28 -0
  65. data/lib/jasmine/lib/jasmine-0.10.4.js +2371 -0
  66. data/lib/jasmine/lib/jasmine.css +166 -0
  67. data/lib/jasmine/lib/json2.js +478 -0
  68. data/lib/jasmine/spec/jasmine_helper.rb +44 -0
  69. data/lib/jasmine/spec/jasmine_spec.rb +31 -0
  70. data/lib/jasmine/spec/runner.html +80 -0
  71. data/lib/jasmine/spec/saucelabs.yml +24 -0
  72. data/lib/jasmine/spec/suites/CustomMatchersSpec.js +112 -0
  73. data/lib/jasmine/spec/suites/EnvSpec.js +158 -0
  74. data/lib/jasmine/spec/suites/ExceptionsSpec.js +107 -0
  75. data/lib/jasmine/spec/suites/JsApiReporterSpec.js +96 -0
  76. data/lib/jasmine/spec/suites/MatchersSpec.js +709 -0
  77. data/lib/jasmine/spec/suites/MockClockSpec.js +34 -0
  78. data/lib/jasmine/spec/suites/MultiReporterSpec.js +30 -0
  79. data/lib/jasmine/spec/suites/NestedResultsSpec.js +54 -0
  80. data/lib/jasmine/spec/suites/PrettyPrintSpec.js +93 -0
  81. data/lib/jasmine/spec/suites/QueueSpec.js +23 -0
  82. data/lib/jasmine/spec/suites/ReporterSpec.js +60 -0
  83. data/lib/jasmine/spec/suites/RunnerSpec.js +267 -0
  84. data/lib/jasmine/spec/suites/SpecRunningSpec.js +1195 -0
  85. data/lib/jasmine/spec/suites/SpecSpec.js +110 -0
  86. data/lib/jasmine/spec/suites/SpySpec.js +201 -0
  87. data/lib/jasmine/spec/suites/SuiteSpec.js +120 -0
  88. data/lib/jasmine/spec/suites/TrivialReporterSpec.js +158 -0
  89. data/lib/jasmine/spec/suites/UtilSpec.js +40 -0
  90. data/lib/jasmine/spec/suites/WaitsForBlockSpec.js +88 -0
  91. data/lib/jasmine/src/Block.js +22 -0
  92. data/lib/jasmine/src/Env.js +263 -0
  93. data/lib/jasmine/src/JsApiReporter.js +104 -0
  94. data/lib/jasmine/src/Matchers.js +336 -0
  95. data/lib/jasmine/src/MultiReporter.js +28 -0
  96. data/lib/jasmine/src/NestedResults.js +80 -0
  97. data/lib/jasmine/src/PrettyPrinter.js +122 -0
  98. data/lib/jasmine/src/Queue.js +94 -0
  99. data/lib/jasmine/src/Reporter.js +27 -0
  100. data/lib/jasmine/src/Reporters.js +43 -0
  101. data/lib/jasmine/src/Runner.js +77 -0
  102. data/lib/jasmine/src/Spec.js +206 -0
  103. data/lib/jasmine/src/Suite.js +82 -0
  104. data/lib/jasmine/src/WaitsBlock.js +13 -0
  105. data/lib/jasmine/src/WaitsForBlock.js +37 -0
  106. data/lib/jasmine/src/base.js +586 -0
  107. data/lib/jasmine/src/mock-timeout.js +177 -0
  108. data/lib/jasmine/src/util.js +67 -0
  109. data/lib/jasmine/src/version.json +5 -0
  110. metadata +238 -0
@@ -0,0 +1,34 @@
1
+ describe("MockClock", function () {
2
+
3
+ beforeEach(function() {
4
+ jasmine.Clock.useMock();
5
+ });
6
+
7
+ describe("setTimeout", function () {
8
+ it("should mock the clock when useMock is in a beforeEach", function() {
9
+ var expected = false;
10
+ setTimeout(function() {
11
+ expected = true;
12
+ }, 30000);
13
+ expect(expected).toBe(false);
14
+ jasmine.Clock.tick(30001);
15
+ expect(expected).toBe(true);
16
+ });
17
+ });
18
+
19
+ describe("setInterval", function () {
20
+ it("should mock the clock when useMock is in a beforeEach", function() {
21
+ var interval = 0;
22
+ setInterval(function() {
23
+ interval++;
24
+ }, 30000);
25
+ expect(interval).toEqual(0);
26
+ jasmine.Clock.tick(30001);
27
+ expect(interval).toEqual(1);
28
+ jasmine.Clock.tick(30001);
29
+ expect(interval).toEqual(2);
30
+ jasmine.Clock.tick(1);
31
+ expect(interval).toEqual(2);
32
+ });
33
+ });
34
+ });
@@ -0,0 +1,30 @@
1
+ describe("jasmine.MultiReporter", function() {
2
+ var multiReporter, fakeReporter1, fakeReporter2;
3
+
4
+ beforeEach(function() {
5
+ multiReporter = new jasmine.MultiReporter();
6
+ fakeReporter1 = jasmine.createSpyObj("fakeReporter1", ["reportSpecResults"]);
7
+ fakeReporter2 = jasmine.createSpyObj("fakeReporter2", ["reportSpecResults", "reportRunnerStarting"]);
8
+ multiReporter.addReporter(fakeReporter1);
9
+ multiReporter.addReporter(fakeReporter2);
10
+ });
11
+
12
+ it("should support all the method calls that jasmine.Reporter supports", function() {
13
+ multiReporter.reportRunnerStarting();
14
+ multiReporter.reportRunnerResults();
15
+ multiReporter.reportSuiteResults();
16
+ multiReporter.reportSpecResults();
17
+ multiReporter.log();
18
+ });
19
+
20
+ it("should delegate to any and all subreporters", function() {
21
+ multiReporter.reportSpecResults('blah', 'foo');
22
+ expect(fakeReporter1.reportSpecResults).wasCalledWith('blah', 'foo');
23
+ expect(fakeReporter2.reportSpecResults).wasCalledWith('blah', 'foo');
24
+ });
25
+
26
+ it("should quietly skip delegating to any subreporters which lack the given method", function() {
27
+ multiReporter.reportRunnerStarting('blah', 'foo');
28
+ expect(fakeReporter2.reportRunnerStarting).wasCalledWith('blah', 'foo');
29
+ });
30
+ });
@@ -0,0 +1,54 @@
1
+ describe('jasmine.NestedResults', function() {
2
+ it('#addResult increments counters', function() {
3
+ // Leaf case
4
+ var results = new jasmine.NestedResults();
5
+
6
+ results.addResult(new jasmine.ExpectationResult({
7
+ matcherName: "foo", passed: true, message: 'Passed.', actual: 'bar', expected: 'bar'}
8
+ ));
9
+
10
+ expect(results.getItems().length).toEqual(1);
11
+ expect(results.totalCount).toEqual(1);
12
+ expect(results.passedCount).toEqual(1);
13
+ expect(results.failedCount).toEqual(0);
14
+
15
+ results.addResult(new jasmine.ExpectationResult({
16
+ matcherName: "baz", passed: false, message: 'FAIL.', actual: "corge", expected: "quux"
17
+ }));
18
+
19
+ expect(results.getItems().length).toEqual(2);
20
+ expect(results.totalCount).toEqual(2);
21
+ expect(results.passedCount).toEqual(1);
22
+ expect(results.failedCount).toEqual(1);
23
+ });
24
+
25
+ it('should roll up counts for nested results', function() {
26
+ // Branch case
27
+ var leafResultsOne = new jasmine.NestedResults();
28
+ leafResultsOne.addResult(new jasmine.ExpectationResult({
29
+ matcherName: "toSomething", passed: true, message: 'message', actual: '', expected:''
30
+ }));
31
+
32
+ leafResultsOne.addResult(new jasmine.ExpectationResult({
33
+ matcherName: "toSomethingElse", passed: false, message: 'message', actual: 'a', expected: 'b'
34
+ }));
35
+
36
+ var leafResultsTwo = new jasmine.NestedResults();
37
+ leafResultsTwo.addResult(new jasmine.ExpectationResult({
38
+ matcherName: "toSomething", passed: true, message: 'message', actual: '', expected: ''
39
+ }));
40
+ leafResultsTwo.addResult(new jasmine.ExpectationResult({
41
+ matcherName: "toSomethineElse", passed: false, message: 'message', actual: 'c', expected: 'd'
42
+ }));
43
+
44
+ var branchResults = new jasmine.NestedResults();
45
+ branchResults.addResult(leafResultsOne);
46
+ branchResults.addResult(leafResultsTwo);
47
+
48
+ expect(branchResults.getItems().length).toEqual(2);
49
+ expect(branchResults.totalCount).toEqual(4);
50
+ expect(branchResults.passedCount).toEqual(2);
51
+ expect(branchResults.failedCount).toEqual(2);
52
+ });
53
+
54
+ });
@@ -0,0 +1,93 @@
1
+ describe("jasmine.pp", function () {
2
+ it("should wrap strings in single quotes", function() {
3
+ expect(jasmine.pp("some string")).toEqual("'some string'");
4
+ expect(jasmine.pp("som' string")).toEqual("'som' string'");
5
+ });
6
+
7
+ it("should stringify primitives properly", function() {
8
+ expect(jasmine.pp(true)).toEqual("true");
9
+ expect(jasmine.pp(false)).toEqual("false");
10
+ expect(jasmine.pp(null)).toEqual("null");
11
+ expect(jasmine.pp(jasmine.undefined)).toEqual("undefined");
12
+ expect(jasmine.pp(3)).toEqual("3");
13
+ expect(jasmine.pp(-3.14)).toEqual("-3.14");
14
+ });
15
+
16
+ it("should stringify arrays properly", function() {
17
+ expect(jasmine.pp([1, 2])).toEqual("[ 1, 2 ]");
18
+ expect(jasmine.pp([1, 'foo', {}, jasmine.undefined, null])).toEqual("[ 1, 'foo', { }, undefined, null ]");
19
+ });
20
+
21
+ it("should indicate circular array references", function() {
22
+ var array1 = [1, 2];
23
+ var array2 = [array1];
24
+ array1.push(array2);
25
+ expect(jasmine.pp(array1)).toEqual("[ 1, 2, [ <circular reference: Array> ] ]");
26
+ });
27
+
28
+ it("should stringify objects properly", function() {
29
+ expect(jasmine.pp({foo: 'bar'})).toEqual("{ foo : 'bar' }");
30
+ expect(jasmine.pp({foo:'bar', baz:3, nullValue: null, undefinedValue: jasmine.undefined})).toEqual("{ foo : 'bar', baz : 3, nullValue : null, undefinedValue : undefined }");
31
+ expect(jasmine.pp({foo: function () {
32
+ }, bar: [1, 2, 3]})).toEqual("{ foo : Function, bar : [ 1, 2, 3 ] }");
33
+ });
34
+
35
+ it("should stringify RegExp objects properly", function() {
36
+ expect(jasmine.pp(/x|y|z/)).toEqual("/x|y|z/");
37
+ });
38
+
39
+ it("should indicate circular object references", function() {
40
+ var sampleValue = {foo: 'hello'};
41
+ sampleValue.nested = sampleValue;
42
+ expect(jasmine.pp(sampleValue)).toEqual("{ foo : 'hello', nested : <circular reference: Object> }");
43
+ });
44
+
45
+ it("should indicate getters on objects as such", function() {
46
+ var sampleValue = {id: 1};
47
+ if (sampleValue.__defineGetter__) {
48
+ //not supported in IE!
49
+ sampleValue.__defineGetter__('calculatedValue', function() {
50
+ throw new Error("don't call me!");
51
+ });
52
+ }
53
+ if (sampleValue.__defineGetter__) {
54
+ expect(jasmine.pp(sampleValue)).toEqual("{ id : 1, calculatedValue : <getter> }");
55
+ }
56
+ else {
57
+ expect(jasmine.pp(sampleValue)).toEqual("{ id : 1 }");
58
+ }
59
+ });
60
+
61
+ it("should stringify HTML nodes properly", function() {
62
+ var sampleNode = document.createElement('div');
63
+ sampleNode.innerHTML = 'foo<b>bar</b>';
64
+ expect(jasmine.pp(sampleNode)).toEqual("HTMLNode");
65
+ expect(jasmine.pp({foo: sampleNode})).toEqual("{ foo : HTMLNode }");
66
+ });
67
+
68
+ it('should not do HTML escaping of strings', function() {
69
+ expect(jasmine.pp('some <b>html string</b> &', false)).toEqual('\'some <b>html string</b> &\'');
70
+ });
71
+
72
+ it("should abbreviate window objects", function() {
73
+ expect(jasmine.pp(window)).toEqual("<window>");
74
+ });
75
+
76
+ it("should stringify Date objects properly", function() {
77
+ var now = new Date();
78
+ expect(jasmine.pp(now)).toEqual("Date(" + now.toString() + ")");
79
+ });
80
+
81
+ it("should stringify spy objects properly", function() {
82
+ var TestObject = {
83
+ someFunction: function() {
84
+ }
85
+ };
86
+ spyOn(TestObject, 'someFunction');
87
+ expect(jasmine.pp(TestObject.someFunction)).toEqual("spy on someFunction");
88
+
89
+ expect(jasmine.pp(jasmine.createSpy("something"))).toEqual("spy on something");
90
+ });
91
+
92
+ });
93
+
@@ -0,0 +1,23 @@
1
+ describe("jasmine.Queue", function() {
2
+ it("should not call itself recursively, so we don't get stack overflow errors", function() {
3
+ var queue = new jasmine.Queue(new jasmine.Env());
4
+ queue.add(new jasmine.Block(null, function() {}));
5
+ queue.add(new jasmine.Block(null, function() {}));
6
+ queue.add(new jasmine.Block(null, function() {}));
7
+ queue.add(new jasmine.Block(null, function() {}));
8
+
9
+ var nestCount = 0;
10
+ var maxNestCount = 0;
11
+ var nextCallCount = 0;
12
+ queue.next_ = function() {
13
+ nestCount++;
14
+ if (nestCount > maxNestCount) maxNestCount = nestCount;
15
+
16
+ jasmine.Queue.prototype.next_.apply(queue, arguments);
17
+ nestCount--;
18
+ };
19
+
20
+ queue.start();
21
+ expect(maxNestCount).toEqual(1);
22
+ });
23
+ });
@@ -0,0 +1,60 @@
1
+ describe('jasmine.Reporter', function() {
2
+ var env;
3
+
4
+
5
+ beforeEach(function() {
6
+ env = new jasmine.Env();
7
+ env.updateInterval = 0;
8
+ });
9
+
10
+ it('should get called from the test runner', function() {
11
+ env.describe('Suite for JSON Reporter with Callbacks', function () {
12
+ env.it('should be a test', function() {
13
+ this.runs(function () {
14
+ this.expect(true).toEqual(true);
15
+ });
16
+ });
17
+ env.it('should be a failing test', function() {
18
+ this.runs(function () {
19
+ this.expect(false).toEqual(true);
20
+ });
21
+ });
22
+ });
23
+ env.describe('Suite for JSON Reporter with Callbacks 2', function () {
24
+ env.it('should be a test', function() {
25
+ this.runs(function () {
26
+ this.expect(true).toEqual(true);
27
+ });
28
+ });
29
+
30
+ });
31
+
32
+ var foo = 0;
33
+ var bar = 0;
34
+ var baz = 0;
35
+
36
+ var specCallback = function (results) {
37
+ foo++;
38
+ };
39
+ var suiteCallback = function (results) {
40
+ bar++;
41
+ };
42
+ var runnerCallback = function (results) {
43
+ baz++;
44
+ };
45
+
46
+ env.reporter = jasmine.Reporters.reporter({
47
+ specCallback: specCallback,
48
+ suiteCallback: suiteCallback,
49
+ runnerCallback: runnerCallback
50
+ });
51
+
52
+ var runner = env.currentRunner();
53
+ runner.execute();
54
+
55
+ expect(foo).toEqual(3); // 'foo was expected to be 3, was ' + foo);
56
+ expect(bar).toEqual(2); // 'bar was expected to be 2, was ' + bar);
57
+ expect(baz).toEqual(1); // 'baz was expected to be 1, was ' + baz);
58
+ });
59
+
60
+ });
@@ -0,0 +1,267 @@
1
+ describe('RunnerTest', function() {
2
+ var fakeTimer;
3
+ var env;
4
+
5
+ beforeEach(function() {
6
+ env = new jasmine.Env();
7
+ env.updateInterval = 0;
8
+
9
+ fakeTimer = new jasmine.FakeTimer();
10
+ env.setTimeout = fakeTimer.setTimeout;
11
+ env.clearTimeout = fakeTimer.clearTimeout;
12
+ env.setInterval = fakeTimer.setInterval;
13
+ env.clearInterval = fakeTimer.clearInterval;
14
+ });
15
+
16
+ describe('beforeEach', function() {
17
+ it('should run before each spec for all suites', function () {
18
+ var foo;
19
+ env.beforeEach(function () {
20
+ foo = 0;
21
+ });
22
+
23
+ env.describe('suite 1', function () {
24
+ env.it('test 1-1', function() {
25
+ foo++;
26
+ this.expect(foo).toEqual(1);
27
+ });
28
+ env.it('test 1-2', function() {
29
+ foo++;
30
+ this.expect(foo).toEqual(1);
31
+ });
32
+ });
33
+
34
+ env.describe('suite 2', function () {
35
+ env.it('test 2-1', function() {
36
+ foo++;
37
+ this.expect(foo).toEqual(1);
38
+ });
39
+ });
40
+
41
+ env.currentRunner().execute();
42
+
43
+ var runnerResults = env.currentRunner().results();
44
+ expect(runnerResults.totalCount).toEqual(3);
45
+ expect(runnerResults.passedCount).toEqual(3);
46
+ });
47
+
48
+
49
+ it('should provide all specs', function () {
50
+ var foo;
51
+ env.beforeEach(function () {
52
+ foo = 0;
53
+ });
54
+
55
+ env.describe('suite 1', function () {
56
+ env.it('test 1-1', function() {
57
+ foo++;
58
+ this.expect(foo).toEqual(1);
59
+ });
60
+ env.it('test 1-2', function() {
61
+ foo++;
62
+ this.expect(foo).toEqual(1);
63
+ });
64
+ });
65
+
66
+ env.describe('suite 2', function () {
67
+ env.it('test 2-1', function() {
68
+ foo++;
69
+ this.expect(foo).toEqual(1);
70
+ });
71
+ });
72
+
73
+ env.currentRunner().execute();
74
+
75
+
76
+ expect(env.currentRunner().specs().length).toEqual(3);
77
+ });
78
+ });
79
+
80
+ describe('afterEach', function() {
81
+ it('should run after each spec for all suites', function () {
82
+ var foo = 3;
83
+ env.afterEach(function () {
84
+ foo = foo - 1;
85
+ });
86
+
87
+ env.describe('suite 1', function () {
88
+ env.it('test 1-1', function() {
89
+ this.expect(foo).toEqual(3);
90
+ });
91
+ env.it('test 1-2', function() {
92
+ this.expect(foo).toEqual(2);
93
+ });
94
+ });
95
+
96
+ env.describe('suite 2', function () {
97
+ env.it('test 2-1', function() {
98
+ this.expect(foo).toEqual(1);
99
+ });
100
+ });
101
+
102
+ env.currentRunner().execute();
103
+
104
+ var runnerResults = env.currentRunner().results();
105
+ expect(runnerResults.totalCount).toEqual(3);
106
+ expect(runnerResults.passedCount).toEqual(3);
107
+ });
108
+ });
109
+
110
+
111
+ it('should run child suites and specs and generate results when execute is called', function() {
112
+ env.describe('one suite description', function () {
113
+ env.it('should be a test', function() {
114
+ this.runs(function () {
115
+ this.expect(true).toEqual(true);
116
+ });
117
+ });
118
+ });
119
+
120
+ env.describe('another suite description', function () {
121
+ env.it('should be another test', function() {
122
+ this.runs(function () {
123
+ this.expect(true).toEqual(false);
124
+ });
125
+ });
126
+ });
127
+
128
+ env.currentRunner().execute();
129
+
130
+ var runnerResults = env.currentRunner().results();
131
+ expect(runnerResults.totalCount).toEqual(2);
132
+ expect(runnerResults.passedCount).toEqual(1);
133
+ expect(runnerResults.failedCount).toEqual(1);
134
+ });
135
+
136
+
137
+ it('should ignore suites that have been x\'d', function() {
138
+ env.xdescribe('one suite description', function () {
139
+ env.it('should be a test', function() {
140
+ this.runs(function () {
141
+ this.expect(true).toEqual(true);
142
+ });
143
+ });
144
+ });
145
+
146
+ env.describe('another suite description', function () {
147
+ env.it('should be another test', function() {
148
+ this.runs(function () {
149
+ this.expect(true).toEqual(false);
150
+ });
151
+ });
152
+ });
153
+
154
+ env.currentRunner().execute();
155
+
156
+ var runnerResults = env.currentRunner().results();
157
+ expect(runnerResults.totalCount).toEqual(1);
158
+ expect(runnerResults.passedCount).toEqual(0);
159
+ expect(runnerResults.failedCount).toEqual(1);
160
+ });
161
+
162
+ it('should roll up results from all specs', function() {
163
+ env.describe('one suite description', function () {
164
+ env.it('should be a test', function() {
165
+ this.runs(function () {
166
+ this.expect(true).toEqual(true);
167
+ });
168
+ });
169
+ });
170
+
171
+ env.describe('another suite description', function () {
172
+ env.it('should be another test', function() {
173
+ this.runs(function () {
174
+ this.expect(true).toEqual(false);
175
+ });
176
+ });
177
+ });
178
+
179
+ env.currentRunner().execute();
180
+
181
+ var results = env.currentRunner().results();
182
+ expect(results.totalCount).toEqual(2);
183
+ expect(results.passedCount).toEqual(1);
184
+ expect(results.failedCount).toEqual(1);
185
+ });
186
+
187
+ describe('reporting', function () {
188
+ var fakeReporter;
189
+ beforeEach(function () {
190
+ fakeReporter = jasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting", "reportRunnerResults"]);
191
+ env.addReporter(fakeReporter);
192
+ });
193
+
194
+ it('should report runner results when the runner has completed running', function() {
195
+ env.describe('one suite description', function () {
196
+ env.it('should be a test', function() {
197
+ this.runs(function () {
198
+ this.expect(true).toEqual(true);
199
+ });
200
+ });
201
+ });
202
+
203
+ env.describe('another suite description', function () {
204
+ env.it('should be another test', function() {
205
+ this.waits(200);
206
+ this.runs(function () {
207
+ this.expect(true).toEqual(false);
208
+ });
209
+ });
210
+ });
211
+
212
+ env.currentRunner().execute();
213
+ expect(fakeReporter.reportRunnerResults).wasNotCalled();
214
+ fakeTimer.tick(200);
215
+ //This blows up the JSApiReporter.
216
+ //expect(fakeReporter.reportRunnerResults).wasCalledWith(env.currentRunner);
217
+ expect(fakeReporter.reportRunnerResults).wasCalled();
218
+ expect(fakeReporter.reportRunnerResults.mostRecentCall.args[0].results()).toEqual(env.currentRunner().results());
219
+ });
220
+ });
221
+
222
+ it("should report when the tests start running", function() {
223
+ var fakeReporter = jasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting"]);
224
+ env.addReporter(fakeReporter);
225
+
226
+
227
+ var runner = new jasmine.Runner(env);
228
+ runner.arbitraryVariable = 'foo';
229
+ spyOn(runner.queue, 'start');
230
+ expect(fakeReporter.reportRunnerStarting).wasNotCalled();
231
+ runner.execute();
232
+ expect(fakeReporter.reportRunnerStarting).wasCalled();
233
+ var reportedRunner = fakeReporter.reportRunnerStarting.mostRecentCall.args[0];
234
+ expect(reportedRunner.arbitraryVariable).toEqual('foo');
235
+ expect(runner.queue.start).wasCalled();
236
+ });
237
+
238
+ describe("when suites are nested", function() {
239
+ var suite1, suite2, suite3;
240
+
241
+ function suiteNames(suites) {
242
+ var suiteDescriptions = [];
243
+ for (var i = 0; i < suites.length; i++) {
244
+ suiteDescriptions.push(suites[i].getFullName());
245
+ }
246
+ return suiteDescriptions;
247
+ }
248
+
249
+ beforeEach(function() {
250
+ suite1 = env.describe("suite 1", function() {
251
+ suite2 = env.describe("suite 2", function() {
252
+ });
253
+ });
254
+ suite3 = env.describe("suite 3", function() {});
255
+ });
256
+
257
+ it("#suites should return a flat array of all suites, including nested suites", function() {
258
+ var suites = env.currentRunner().suites();
259
+ expect(suiteNames(suites)).toEqual([suite1.getFullName(), suite2.getFullName(), suite3.getFullName()]);
260
+ });
261
+
262
+ it("#topLevelSuites should return a flat array of all top-level suites only", function() {
263
+ var suites = env.currentRunner().topLevelSuites();
264
+ expect(suiteNames(suites)).toEqual([suite1.getFullName(), suite3.getFullName()]);
265
+ });
266
+ });
267
+ });