danieldkim-evergreen 0.4.0.5 → 0.4.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/lib/evergreen/version.rb +1 -1
  2. data/lib/evergreen/version.rb~ +1 -1
  3. data/lib/jasmine/Gemfile +6 -0
  4. data/lib/jasmine/MIT.LICENSE +20 -0
  5. data/lib/jasmine/README.markdown +28 -0
  6. data/lib/jasmine/Rakefile +182 -0
  7. data/lib/jasmine/cruise_config.rb +21 -0
  8. data/lib/jasmine/example/SpecRunner.html +27 -0
  9. data/lib/jasmine/example/spec/PlayerSpec.js +58 -0
  10. data/lib/jasmine/example/spec/SpecHelper.js +9 -0
  11. data/lib/jasmine/example/src/Player.js +22 -0
  12. data/lib/jasmine/example/src/Song.js +7 -0
  13. data/lib/jasmine/images/fail-16.png +0 -0
  14. data/lib/jasmine/images/fail.png +0 -0
  15. data/lib/jasmine/images/go-16.png +0 -0
  16. data/lib/jasmine/images/go.png +0 -0
  17. data/lib/jasmine/images/pending-16.png +0 -0
  18. data/lib/jasmine/images/pending.png +0 -0
  19. data/lib/jasmine/images/question-bk.png +0 -0
  20. data/lib/jasmine/images/questionbk-16.png +0 -0
  21. data/lib/jasmine/images/spinner.gif +0 -0
  22. data/lib/jasmine/jsdoc-template/allclasses.tmpl +17 -0
  23. data/lib/jasmine/jsdoc-template/allfiles.tmpl +56 -0
  24. data/lib/jasmine/jsdoc-template/class.tmpl +646 -0
  25. data/lib/jasmine/jsdoc-template/index.tmpl +39 -0
  26. data/lib/jasmine/jsdoc-template/publish.js +184 -0
  27. data/lib/jasmine/jsdoc-template/static/default.css +162 -0
  28. data/lib/jasmine/jsdoc-template/static/header.html +2 -0
  29. data/lib/jasmine/jsdoc-template/static/index.html +19 -0
  30. data/lib/jasmine/jsdoc-template/symbol.tmpl +35 -0
  31. data/lib/jasmine/lib/jasmine-html.js +188 -0
  32. data/lib/jasmine/lib/jasmine.css +166 -0
  33. data/lib/jasmine/lib/jasmine.js +2421 -0
  34. data/lib/jasmine/lib/json2.js +478 -0
  35. data/lib/jasmine/spec/runner.html +80 -0
  36. data/lib/jasmine/spec/suites/BaseSpec.js +27 -0
  37. data/lib/jasmine/spec/suites/CustomMatchersSpec.js +97 -0
  38. data/lib/jasmine/spec/suites/EnvSpec.js +158 -0
  39. data/lib/jasmine/spec/suites/ExceptionsSpec.js +107 -0
  40. data/lib/jasmine/spec/suites/JsApiReporterSpec.js +103 -0
  41. data/lib/jasmine/spec/suites/MatchersSpec.js +795 -0
  42. data/lib/jasmine/spec/suites/MockClockSpec.js +38 -0
  43. data/lib/jasmine/spec/suites/MultiReporterSpec.js +45 -0
  44. data/lib/jasmine/spec/suites/NestedResultsSpec.js +54 -0
  45. data/lib/jasmine/spec/suites/PrettyPrintSpec.js +93 -0
  46. data/lib/jasmine/spec/suites/QueueSpec.js +23 -0
  47. data/lib/jasmine/spec/suites/ReporterSpec.js +56 -0
  48. data/lib/jasmine/spec/suites/RunnerSpec.js +267 -0
  49. data/lib/jasmine/spec/suites/SpecRunningSpec.js +1253 -0
  50. data/lib/jasmine/spec/suites/SpecSpec.js +124 -0
  51. data/lib/jasmine/spec/suites/SpySpec.js +201 -0
  52. data/lib/jasmine/spec/suites/SuiteSpec.js +120 -0
  53. data/lib/jasmine/spec/suites/TrivialReporterSpec.js +238 -0
  54. data/lib/jasmine/spec/suites/UtilSpec.js +40 -0
  55. data/lib/jasmine/spec/suites/WaitsForBlockSpec.js +87 -0
  56. data/lib/jasmine/src/Block.js +22 -0
  57. data/lib/jasmine/src/Env.js +264 -0
  58. data/lib/jasmine/src/JsApiReporter.js +102 -0
  59. data/lib/jasmine/src/Matchers.js +354 -0
  60. data/lib/jasmine/src/MultiReporter.js +35 -0
  61. data/lib/jasmine/src/NestedResults.js +80 -0
  62. data/lib/jasmine/src/PrettyPrinter.js +122 -0
  63. data/lib/jasmine/src/Queue.js +99 -0
  64. data/lib/jasmine/src/Reporter.js +31 -0
  65. data/lib/jasmine/src/Runner.js +77 -0
  66. data/lib/jasmine/src/Spec.js +242 -0
  67. data/lib/jasmine/src/Suite.js +82 -0
  68. data/lib/jasmine/src/WaitsBlock.js +13 -0
  69. data/lib/jasmine/src/WaitsForBlock.js +52 -0
  70. data/lib/jasmine/src/base.js +589 -0
  71. data/lib/jasmine/src/html/TrivialReporter.js +188 -0
  72. data/lib/jasmine/src/html/jasmine.css +166 -0
  73. data/lib/jasmine/src/mock-timeout.js +183 -0
  74. data/lib/jasmine/src/util.js +67 -0
  75. data/lib/jasmine/src/version.json +5 -0
  76. metadata +76 -3
@@ -0,0 +1,38 @@
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
+
35
+ it("shouldn't complain if you call jasmine.Clock.useMock() more than once", function() {
36
+ jasmine.Clock.useMock();
37
+ });
38
+ });
@@ -0,0 +1,45 @@
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
+ var delegate = {};
14
+ multiReporter.addReporter(delegate);
15
+
16
+ this.addMatchers({
17
+ toDelegateMethod: function(methodName) {
18
+ delegate[methodName] = jasmine.createSpy(methodName);
19
+ this.actual[methodName]("whatever argument");
20
+
21
+ return delegate[methodName].wasCalled
22
+ && delegate[methodName].mostRecentCall.args.length == 1
23
+ && delegate[methodName].mostRecentCall.args[0] == "whatever argument";
24
+ }
25
+ });
26
+
27
+ expect(multiReporter).toDelegateMethod('reportRunnerStarting');
28
+ expect(multiReporter).toDelegateMethod('reportRunnerResults');
29
+ expect(multiReporter).toDelegateMethod('reportSuiteResults');
30
+ expect(multiReporter).toDelegateMethod('reportSpecStarting');
31
+ expect(multiReporter).toDelegateMethod('reportSpecResults');
32
+ expect(multiReporter).toDelegateMethod('log');
33
+ });
34
+
35
+ it("should delegate to any and all subreporters", function() {
36
+ multiReporter.reportSpecResults('blah', 'foo');
37
+ expect(fakeReporter1.reportSpecResults).toHaveBeenCalledWith('blah', 'foo');
38
+ expect(fakeReporter2.reportSpecResults).toHaveBeenCalledWith('blah', 'foo');
39
+ });
40
+
41
+ it("should quietly skip delegating to any subreporters which lack the given method", function() {
42
+ multiReporter.reportRunnerStarting('blah', 'foo');
43
+ expect(fakeReporter2.reportRunnerStarting).toHaveBeenCalledWith('blah', 'foo');
44
+ });
45
+ });
@@ -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 the global (usually window) object", function() {
73
+ expect(jasmine.pp(jasmine.getGlobal())).toEqual("<global>");
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,56 @@
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
+ env.addReporter({
37
+ reportSpecResults: function() {
38
+ foo++;
39
+ },
40
+ reportSuiteResults: function() {
41
+ bar++;
42
+ },
43
+ reportRunnerResults: function() {
44
+ baz++;
45
+ }
46
+ });
47
+
48
+ var runner = env.currentRunner();
49
+ runner.execute();
50
+
51
+ expect(foo).toEqual(3); // 'foo was expected to be 3, was ' + foo);
52
+ expect(bar).toEqual(2); // 'bar was expected to be 2, was ' + bar);
53
+ expect(baz).toEqual(1); // 'baz was expected to be 1, was ' + baz);
54
+ });
55
+
56
+ });
@@ -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).not.toHaveBeenCalled();
214
+ fakeTimer.tick(200);
215
+ //This blows up the JSApiReporter.
216
+ //expect(fakeReporter.reportRunnerResults).toHaveBeenCalledWith(env.currentRunner);
217
+ expect(fakeReporter.reportRunnerResults).toHaveBeenCalled();
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).not.toHaveBeenCalled();
231
+ runner.execute();
232
+ expect(fakeReporter.reportRunnerStarting).toHaveBeenCalled();
233
+ var reportedRunner = fakeReporter.reportRunnerStarting.mostRecentCall.args[0];
234
+ expect(reportedRunner.arbitraryVariable).toEqual('foo');
235
+ expect(runner.queue.start).toHaveBeenCalled();
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
+ });