jazrb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +134 -0
  3. data/bin/autojaz +4 -0
  4. data/bin/jazrb +230 -0
  5. data/doc/jasmine/files.html +460 -0
  6. data/doc/jasmine/index.html +322 -0
  7. data/doc/jasmine/symbols/_global_.html +1083 -0
  8. data/doc/jasmine/symbols/jasmine.Block.html +417 -0
  9. data/doc/jasmine/symbols/jasmine.Clock.html +678 -0
  10. data/doc/jasmine/symbols/jasmine.Env.html +1135 -0
  11. data/doc/jasmine/symbols/jasmine.EnvjsReporter.html +328 -0
  12. data/doc/jasmine/symbols/jasmine.JsApiReporter.html +822 -0
  13. data/doc/jasmine/symbols/jasmine.Matchers.html +1106 -0
  14. data/doc/jasmine/symbols/jasmine.MultiReporter.html +394 -0
  15. data/doc/jasmine/symbols/jasmine.NestedResults.html +710 -0
  16. data/doc/jasmine/symbols/jasmine.Reporter.html +574 -0
  17. data/doc/jasmine/symbols/jasmine.Runner.html +710 -0
  18. data/doc/jasmine/symbols/jasmine.Spec.html +1372 -0
  19. data/doc/jasmine/symbols/jasmine.Spy.html +855 -0
  20. data/doc/jasmine/symbols/jasmine.Suite.html +705 -0
  21. data/doc/jasmine/symbols/jasmine.XMLReporter.html +328 -0
  22. data/doc/jasmine/symbols/jasmine.html +1359 -0
  23. data/doc/jasmine/symbols/jasmine.util.html +535 -0
  24. data/doc/jasmine/symbols/src/lib_EnvjsReporter.js.html +149 -0
  25. data/doc/jasmine/symbols/src/lib_TrivialReporter.js.html +127 -0
  26. data/doc/jasmine/symbols/src/lib_XMLReporter.js.html +210 -0
  27. data/doc/jasmine/symbols/src/src_Block.js.html +35 -0
  28. data/doc/jasmine/symbols/src/src_Env.js.html +233 -0
  29. data/doc/jasmine/symbols/src/src_JsApiReporter.js.html +110 -0
  30. data/doc/jasmine/symbols/src/src_Matchers.js.html +399 -0
  31. data/doc/jasmine/symbols/src/src_MultiReporter.js.html +36 -0
  32. data/doc/jasmine/symbols/src/src_NestedResults.js.html +88 -0
  33. data/doc/jasmine/symbols/src/src_PrettyPrinter.js.html +128 -0
  34. data/doc/jasmine/symbols/src/src_Queue.js.html +119 -0
  35. data/doc/jasmine/symbols/src/src_Reporter.js.html +35 -0
  36. data/doc/jasmine/symbols/src/src_Reporters.js.html +51 -0
  37. data/doc/jasmine/symbols/src/src_Runner.js.html +75 -0
  38. data/doc/jasmine/symbols/src/src_Spec.js.html +228 -0
  39. data/doc/jasmine/symbols/src/src_Suite.js.html +77 -0
  40. data/doc/jasmine/symbols/src/src_WaitsBlock.js.html +21 -0
  41. data/doc/jasmine/symbols/src/src_WaitsForBlock.js.html +45 -0
  42. data/doc/jasmine/symbols/src/src_base.js.html +566 -0
  43. data/doc/jasmine/symbols/src/src_mock-timeout.js.html +185 -0
  44. data/doc/jasmine/symbols/src/src_util.js.html +75 -0
  45. data/lib/autotest/discover.rb +3 -0
  46. data/lib/autotest/jazrb.rb +55 -0
  47. data/lib/jazrb/intro.js +46 -0
  48. data/lib/jazrb/jasmine/EnvjsReporter.js +141 -0
  49. data/lib/jazrb/jasmine/TrivialReporter.js +155 -0
  50. data/lib/jazrb/jasmine/XMLReporter.js +241 -0
  51. data/lib/jazrb/jasmine/consolex.js +28 -0
  52. data/lib/jazrb/jasmine/jasmine-0.10.0.js +2526 -0
  53. data/lib/jazrb/jasmine/jasmine.js +2526 -0
  54. data/lib/jazrb/jasmine/json2.js +478 -0
  55. data/lib/jazrb/options.rb +26 -0
  56. data/lib/jazrb/outro.js +3 -0
  57. data/lib/jazrb/qintro.js +113 -0
  58. data/lib/jazrb/qoutro.js +3 -0
  59. data/lib/jazrb/qunit/qunit.css +17 -0
  60. data/lib/jazrb/qunit/qunit.js +1027 -0
  61. data/lib/jazrb.rb +0 -0
  62. data/spec/example/hello_world_spec.js +29 -0
  63. data/spec/example/nested/HelloWorldSpec.js +13 -0
  64. data/spec/example/nested/SpecHelper.js +1 -0
  65. data/spec/example/plain_spec.js +8 -0
  66. data/spec/example/spec_helper.js +1 -0
  67. data/spec/spec_helper.js +18 -0
  68. data/spec/spec_runner.js +143 -0
  69. data/test/jazrb_test.rb +7 -0
  70. data/test/test_helper.rb +10 -0
  71. data/vendor/jasmine/MIT.LICENSE +20 -0
  72. data/vendor/jasmine/README.markdown +479 -0
  73. data/vendor/jasmine/Rakefile +155 -0
  74. data/vendor/jasmine/contrib/ruby/jasmine_runner.rb +334 -0
  75. data/vendor/jasmine/contrib/ruby/jasmine_spec_builder.rb +153 -0
  76. data/vendor/jasmine/contrib/ruby/run.html +47 -0
  77. data/vendor/jasmine/contrib/ruby/spec/jasmine_runner_spec.rb +71 -0
  78. data/vendor/jasmine/doc/files.html +460 -0
  79. data/vendor/jasmine/doc/index.html +322 -0
  80. data/vendor/jasmine/doc/symbols/_global_.html +1083 -0
  81. data/vendor/jasmine/doc/symbols/jasmine.Block.html +417 -0
  82. data/vendor/jasmine/doc/symbols/jasmine.Clock.html +678 -0
  83. data/vendor/jasmine/doc/symbols/jasmine.Env.html +1135 -0
  84. data/vendor/jasmine/doc/symbols/jasmine.EnvjsReporter.html +328 -0
  85. data/vendor/jasmine/doc/symbols/jasmine.JsApiReporter.html +822 -0
  86. data/vendor/jasmine/doc/symbols/jasmine.Matchers.html +1106 -0
  87. data/vendor/jasmine/doc/symbols/jasmine.MultiReporter.html +394 -0
  88. data/vendor/jasmine/doc/symbols/jasmine.NestedResults.html +710 -0
  89. data/vendor/jasmine/doc/symbols/jasmine.Reporter.html +574 -0
  90. data/vendor/jasmine/doc/symbols/jasmine.Runner.html +710 -0
  91. data/vendor/jasmine/doc/symbols/jasmine.Spec.html +1372 -0
  92. data/vendor/jasmine/doc/symbols/jasmine.Spy.html +855 -0
  93. data/vendor/jasmine/doc/symbols/jasmine.Suite.html +705 -0
  94. data/vendor/jasmine/doc/symbols/jasmine.XMLReporter.html +328 -0
  95. data/vendor/jasmine/doc/symbols/jasmine.html +1359 -0
  96. data/vendor/jasmine/doc/symbols/jasmine.util.html +535 -0
  97. data/vendor/jasmine/doc/symbols/src/lib_EnvjsReporter.js.html +149 -0
  98. data/vendor/jasmine/doc/symbols/src/lib_TrivialReporter.js.html +127 -0
  99. data/vendor/jasmine/doc/symbols/src/lib_XMLReporter.js.html +210 -0
  100. data/vendor/jasmine/doc/symbols/src/src_Block.js.html +35 -0
  101. data/vendor/jasmine/doc/symbols/src/src_Env.js.html +233 -0
  102. data/vendor/jasmine/doc/symbols/src/src_JsApiReporter.js.html +110 -0
  103. data/vendor/jasmine/doc/symbols/src/src_Matchers.js.html +399 -0
  104. data/vendor/jasmine/doc/symbols/src/src_MultiReporter.js.html +36 -0
  105. data/vendor/jasmine/doc/symbols/src/src_NestedResults.js.html +88 -0
  106. data/vendor/jasmine/doc/symbols/src/src_PrettyPrinter.js.html +128 -0
  107. data/vendor/jasmine/doc/symbols/src/src_Queue.js.html +119 -0
  108. data/vendor/jasmine/doc/symbols/src/src_Reporter.js.html +35 -0
  109. data/vendor/jasmine/doc/symbols/src/src_Reporters.js.html +51 -0
  110. data/vendor/jasmine/doc/symbols/src/src_Runner.js.html +75 -0
  111. data/vendor/jasmine/doc/symbols/src/src_Spec.js.html +228 -0
  112. data/vendor/jasmine/doc/symbols/src/src_Suite.js.html +77 -0
  113. data/vendor/jasmine/doc/symbols/src/src_WaitsBlock.js.html +21 -0
  114. data/vendor/jasmine/doc/symbols/src/src_WaitsForBlock.js.html +45 -0
  115. data/vendor/jasmine/doc/symbols/src/src_base.js.html +566 -0
  116. data/vendor/jasmine/doc/symbols/src/src_mock-timeout.js.html +185 -0
  117. data/vendor/jasmine/doc/symbols/src/src_util.js.html +75 -0
  118. data/vendor/jasmine/examples/html/example_suite.html +27 -0
  119. data/vendor/jasmine/examples/html/spec/example_suite.js +11 -0
  120. data/vendor/jasmine/examples/ruby/Rakefile +33 -0
  121. data/vendor/jasmine/examples/ruby/spec/example/example_spec.js +11 -0
  122. data/vendor/jasmine/examples/ruby/spec/jasmine_helper.rb +41 -0
  123. data/vendor/jasmine/examples/ruby/spec/jasmine_spec.rb +31 -0
  124. data/vendor/jasmine/examples/ruby/spec/saucelabs.yml +24 -0
  125. data/vendor/jasmine/geminstaller.yml +23 -0
  126. data/vendor/jasmine/images/fail-16.png +0 -0
  127. data/vendor/jasmine/images/fail.png +0 -0
  128. data/vendor/jasmine/images/go-16.png +0 -0
  129. data/vendor/jasmine/images/go.png +0 -0
  130. data/vendor/jasmine/images/pending-16.png +0 -0
  131. data/vendor/jasmine/images/pending.png +0 -0
  132. data/vendor/jasmine/images/question-bk.png +0 -0
  133. data/vendor/jasmine/images/questionbk-16.png +0 -0
  134. data/vendor/jasmine/images/spinner.gif +0 -0
  135. data/vendor/jasmine/jasmine.watchr +70 -0
  136. data/vendor/jasmine/lib/EnvjsReporter.js +141 -0
  137. data/vendor/jasmine/lib/TrivialReporter.js +155 -0
  138. data/vendor/jasmine/lib/XMLReporter.js +241 -0
  139. data/vendor/jasmine/lib/consolex.js +28 -0
  140. data/vendor/jasmine/lib/jasmine-0.10.0.js +2526 -0
  141. data/vendor/jasmine/lib/jasmine.css +86 -0
  142. data/vendor/jasmine/lib/json2.js +478 -0
  143. data/vendor/jasmine/spec/jasmine_helper.rb +44 -0
  144. data/vendor/jasmine/spec/jasmine_spec.rb +31 -0
  145. data/vendor/jasmine/spec/runner.html +43 -0
  146. data/vendor/jasmine/spec/runner.js +78 -0
  147. data/vendor/jasmine/spec/saucelabs.yml +24 -0
  148. data/vendor/jasmine/spec/suites/EnvSpec.js +71 -0
  149. data/vendor/jasmine/spec/suites/ExceptionsSpec.js +107 -0
  150. data/vendor/jasmine/spec/suites/JsApiReporterSpec.js +82 -0
  151. data/vendor/jasmine/spec/suites/MatchersSpec.js +589 -0
  152. data/vendor/jasmine/spec/suites/MockClockSpec.js +34 -0
  153. data/vendor/jasmine/spec/suites/MultiReporterSpec.js +30 -0
  154. data/vendor/jasmine/spec/suites/NestedResultsSpec.js +54 -0
  155. data/vendor/jasmine/spec/suites/PrettyPrintSpec.js +93 -0
  156. data/vendor/jasmine/spec/suites/QueueSpec.js +23 -0
  157. data/vendor/jasmine/spec/suites/ReporterSpec.js +60 -0
  158. data/vendor/jasmine/spec/suites/RunnerSpec.js +258 -0
  159. data/vendor/jasmine/spec/suites/SpecRunningSpec.js +1117 -0
  160. data/vendor/jasmine/spec/suites/SpecSpec.js +110 -0
  161. data/vendor/jasmine/spec/suites/SpySpec.js +187 -0
  162. data/vendor/jasmine/spec/suites/SuiteSpec.js +101 -0
  163. data/vendor/jasmine/spec/suites/TrivialReporterSpec.js +140 -0
  164. data/vendor/jasmine/spec/suites/UtilSpec.js +23 -0
  165. data/vendor/jasmine/src/Block.js +34 -0
  166. data/vendor/jasmine/src/Env.js +236 -0
  167. data/vendor/jasmine/src/JsApiReporter.js +103 -0
  168. data/vendor/jasmine/src/Matchers.js +326 -0
  169. data/vendor/jasmine/src/MultiReporter.js +28 -0
  170. data/vendor/jasmine/src/NestedResults.js +99 -0
  171. data/vendor/jasmine/src/PrettyPrinter.js +122 -0
  172. data/vendor/jasmine/src/Queue.js +210 -0
  173. data/vendor/jasmine/src/Reporter.js +27 -0
  174. data/vendor/jasmine/src/Reporters.js +43 -0
  175. data/vendor/jasmine/src/Runner.js +68 -0
  176. data/vendor/jasmine/src/Spec.js +254 -0
  177. data/vendor/jasmine/src/Suite.js +70 -0
  178. data/vendor/jasmine/src/WaitsBlock.js +13 -0
  179. data/vendor/jasmine/src/WaitsForBlock.js +38 -0
  180. data/vendor/jasmine/src/base.js +604 -0
  181. data/vendor/jasmine/src/mock-timeout.js +177 -0
  182. data/vendor/jasmine/src/util.js +67 -0
  183. data/vendor/jasmine/src/version.json +5 -0
  184. metadata +279 -0
@@ -0,0 +1,1117 @@
1
+ describe("jasmine spec running", function () {
2
+ var env;
3
+ var fakeTimer;
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
+ it('should assign spec ids sequentially', function() {
17
+ var it0, it1, it2, it3, it4;
18
+ env.describe('test suite', function() {
19
+ it0 = env.it('spec 0', function() {
20
+ });
21
+ it1 = env.it('spec 1', function() {
22
+ });
23
+ it2 = env.xit('spec 2', function() {
24
+ });
25
+ it3 = env.it('spec 3', function() {
26
+ });
27
+ });
28
+ env.describe('test suite 2', function() {
29
+ it4 = env.it('spec 4', function() {
30
+ });
31
+ });
32
+
33
+ expect(it0.id).toEqual(0);
34
+ expect(it1.id).toEqual(1);
35
+ expect(it2.id).toEqual(2);
36
+ expect(it3.id).toEqual(3);
37
+ expect(it4.id).toEqual(4);
38
+ });
39
+
40
+ it("should build up some objects with results we can inspect", function() {
41
+
42
+ var specWithNoBody, specWithExpectation, specWithFailingExpectations, specWithMultipleExpectations;
43
+
44
+ var suite = env.describe('default current suite', function() {
45
+ specWithNoBody = env.it('new spec');
46
+
47
+ specWithExpectation = env.it('spec with an expectation').runs(function () {
48
+ var foo = 'bar';
49
+ this.expect(foo).toEqual('bar');
50
+ });
51
+
52
+ specWithFailingExpectations = env.it('spec with failing expectation').runs(function () {
53
+ var foo = 'bar';
54
+ this.expect(foo).toEqual('baz');
55
+ });
56
+
57
+ specWithMultipleExpectations = env.it('spec with multiple assertions').runs(function () {
58
+ var foo = 'bar';
59
+ var baz = 'quux';
60
+
61
+ this.expect(foo).toEqual('bar');
62
+ this.expect(baz).toEqual('quux');
63
+ });
64
+ });
65
+
66
+ suite.execute();
67
+
68
+ expect(specWithNoBody.description).toEqual('new spec');
69
+
70
+ expect(specWithExpectation.results().getItems().length).toEqual(1); // "Results aren't there after a spec was executed"
71
+ expect(specWithExpectation.results().getItems()[0].passed()).toEqual(true); // "Results has a result, but it's true"
72
+ expect(specWithExpectation.results().description).toEqual('spec with an expectation'); // "Spec's results did not get the spec's description"
73
+
74
+ expect(specWithFailingExpectations.results().getItems()[0].passed()).toEqual(false); // "Expectation that failed, passed"
75
+
76
+ expect(specWithMultipleExpectations.results().getItems().length).toEqual(2); // "Spec doesn't support multiple expectations"
77
+ });
78
+
79
+ it("should work without a runs block", function() {
80
+ var another_spec;
81
+ env.describe('default current suite', function() {
82
+ another_spec = env.it('spec with an expectation', function () {
83
+ var foo = 'bar';
84
+ this.expect(foo).toEqual('bar');
85
+ this.expect(foo).toEqual('baz');
86
+ });
87
+ });
88
+
89
+ another_spec.execute();
90
+ another_spec.done = true;
91
+
92
+ expect(another_spec.results().getItems().length).toEqual(2);
93
+ expect(another_spec.results().getItems()[0].passed()).toEqual(true); // "In a spec without a run block, expected first expectation result to be true but was false"
94
+ expect(another_spec.results().getItems()[1].passed()).toEqual(false); // "In a spec without a run block, expected second expectation result to be false but was true";
95
+ expect(another_spec.results().description).toEqual('spec with an expectation'); // "In a spec without a run block, results did not include the spec's description";
96
+ });
97
+
98
+ it('should queue waits and runs that it encounters while executing specs', function() {
99
+ var specWithRunsAndWaits;
100
+ var foo = 0;
101
+ env.describe('test async spec', function() {
102
+ specWithRunsAndWaits = env.it('spec w/ queued statments', function () {
103
+ this.runs(function () {
104
+ foo++;
105
+ });
106
+ this.waits(500);
107
+ this.runs(function () {
108
+ foo++;
109
+ });
110
+ this.waits(500);
111
+ this.runs(function () {
112
+ foo++;
113
+ });
114
+ });
115
+ });
116
+
117
+ expect(foo).toEqual(0);
118
+ specWithRunsAndWaits.execute();
119
+
120
+ expect(foo).toEqual(1);
121
+ fakeTimer.tick(500);
122
+ expect(foo).toEqual(2);
123
+ fakeTimer.tick(500);
124
+ expect(foo).toEqual(3);
125
+ });
126
+
127
+ it("should run asynchronous tests", function () {
128
+ var foo = 0;
129
+
130
+ var a_spec;
131
+ env.describe('test async spec', function() {
132
+ a_spec = env.it('spec w/ queued statments', function () {
133
+ this.runs(function () {
134
+ foo++;
135
+ });
136
+ this.runs(function () {
137
+ this.expect(foo).toEqual(1);
138
+ });
139
+ });
140
+ });
141
+
142
+ a_spec.execute();
143
+
144
+ expect(a_spec.results().getItems().length).toEqual(1); // 'No call to waits(): Spec queue did not run all functions';
145
+ expect(a_spec.results().getItems()[0].passed()).toEqual(true); // 'No call to waits(): Queued expectation failed';
146
+
147
+ foo = 0;
148
+ env.describe('test async spec', function() {
149
+ a_spec = env.it('spec w/ queued statments', function () {
150
+ this.runs(function () {
151
+ fakeTimer.setTimeout(function() {
152
+ foo++;
153
+ }, 500);
154
+ });
155
+ this.waits(1000);
156
+ this.runs(function() {
157
+ this.expect(foo).toEqual(1);
158
+ });
159
+ });
160
+ });
161
+
162
+ a_spec.execute();
163
+
164
+ expect(a_spec.results().getItems().length).toEqual(0);
165
+
166
+ fakeTimer.tick(500);
167
+ expect(a_spec.results().getItems().length).toEqual(0);
168
+
169
+ fakeTimer.tick(500);
170
+ expect(a_spec.results().getItems().length).toEqual(1); // 'Calling waits(): Spec queue did not run all functions';
171
+
172
+ expect(a_spec.results().getItems()[0].passed()).toEqual(true); // 'Calling waits(): Queued expectation failed';
173
+
174
+ var bar = 0;
175
+ var another_spec;
176
+ env.describe('test async spec', function() {
177
+ another_spec = env.it('spec w/ queued statments', function () {
178
+ this.runs(function () {
179
+ fakeTimer.setTimeout(function() {
180
+ bar++;
181
+ }, 250);
182
+
183
+ });
184
+ this.waits(500);
185
+ this.runs(function () {
186
+ fakeTimer.setTimeout(function() {
187
+ bar++;
188
+ }, 250);
189
+ });
190
+ this.waits(500);
191
+ this.runs(function () {
192
+ this.expect(bar).toEqual(2);
193
+ });
194
+ });
195
+ });
196
+
197
+
198
+ another_spec.execute();
199
+
200
+ fakeTimer.tick(1000);
201
+
202
+ expect(another_spec.results().getItems().length).toEqual(1);
203
+ expect(another_spec.results().getItems()[0].passed()).toEqual(true);
204
+
205
+ var baz = 0;
206
+ var yet_another_spec;
207
+ env.describe('test async spec', function() {
208
+ yet_another_spec = env.it('spec w/ async fail', function () {
209
+ this.runs(function () {
210
+ fakeTimer.setTimeout(function() {
211
+ baz++;
212
+ }, 250);
213
+ });
214
+ this.waits(100);
215
+ this.runs(function() {
216
+ this.expect(baz).toEqual(1);
217
+ });
218
+ });
219
+ });
220
+
221
+
222
+ yet_another_spec.execute();
223
+ //tick twice so that second runs gets eval'd first: mockClock bug?
224
+ fakeTimer.tick(100);
225
+ fakeTimer.tick(150);
226
+
227
+
228
+ expect(yet_another_spec.results().getItems().length).toEqual(1);
229
+ expect(yet_another_spec.results().getItems()[0].passed()).toEqual(false);
230
+ });
231
+
232
+ it("testAsyncSpecsWithMockSuite", function () {
233
+ var bar = 0;
234
+ var another_spec;
235
+ env.describe('test async spec', function() {
236
+ another_spec = env.it('spec w/ queued statments', function () {
237
+ this.runs(function () {
238
+ fakeTimer.setTimeout(function() {
239
+ bar++;
240
+ }, 250);
241
+ });
242
+ this.waits(500);
243
+ this.runs(function () {
244
+ fakeTimer.setTimeout(function() {
245
+ bar++;
246
+ }, 250);
247
+ });
248
+ this.waits(1500);
249
+ this.runs(function() {
250
+ this.expect(bar).toEqual(2);
251
+ });
252
+ });
253
+ });
254
+
255
+ another_spec.execute();
256
+ fakeTimer.tick(2000);
257
+ expect(another_spec.results().getItems().length).toEqual(1);
258
+ expect(another_spec.results().getItems()[0].passed()).toEqual(true);
259
+ });
260
+
261
+ it("testWaitsFor", function() {
262
+ var doneWaiting = false;
263
+ var runsBlockExecuted = false;
264
+
265
+ var spec;
266
+ env.describe('foo', function() {
267
+ spec = env.it('has a waits for', function() {
268
+ this.runs(function() {
269
+ });
270
+
271
+ this.waitsFor(500, function() {
272
+ return doneWaiting;
273
+ });
274
+
275
+ this.runs(function() {
276
+ runsBlockExecuted = true;
277
+ });
278
+ });
279
+ });
280
+
281
+ spec.execute();
282
+ expect(runsBlockExecuted).toEqual(false); //, 'should not have executed runs block yet');
283
+ fakeTimer.tick(100);
284
+ doneWaiting = true;
285
+ fakeTimer.tick(100);
286
+ expect(runsBlockExecuted).toEqual(true); //, 'should have executed runs block');
287
+ });
288
+
289
+ it("testWaitsForFailsWithMessage", function() {
290
+ var spec;
291
+ env.describe('foo', function() {
292
+ spec = env.it('has a waits for', function() {
293
+ this.runs(function() {
294
+ });
295
+
296
+ this.waitsFor(500, function() {
297
+ return false; // force a timeout
298
+ }, 'my awesome condition');
299
+
300
+ this.runs(function() {
301
+ });
302
+ });
303
+ });
304
+
305
+ spec.execute();
306
+ fakeTimer.tick(1000);
307
+ var actual = spec.results().getItems()[0].message;
308
+ var expected = 'timeout: timed out after 500 msec waiting for my awesome condition';
309
+ expect(actual).toEqual(expected);
310
+ });
311
+
312
+ it("waitsFor fails and skips the rest of the spec if timeout is reached and the latch function is still false", function() {
313
+ var runsBlockExecuted = false;
314
+
315
+ var spec;
316
+ env.describe('foo', function() {
317
+ spec = env.it('has a waits for', function() {
318
+ this.runs(function() {
319
+ });
320
+
321
+ this.waitsFor(500, function() {
322
+ return false;
323
+ });
324
+
325
+ this.runs(function() {
326
+ runsBlockExecuted = true;
327
+ });
328
+ });
329
+ });
330
+
331
+ spec.execute();
332
+ expect(runsBlockExecuted).toEqual(false);
333
+ fakeTimer.tick(100);
334
+ expect(runsBlockExecuted).toEqual(false);
335
+ fakeTimer.tick(400);
336
+ expect(runsBlockExecuted).toEqual(false);
337
+ var actual = spec.results().getItems()[0].message;
338
+ var expected = 'timeout: timed out after 500 msec waiting for something to happen';
339
+ expect(actual).toEqual(expected,
340
+ 'expected "' + expected + '" but found "' + actual + '"');
341
+ });
342
+
343
+ it("testSpecAfter", function() {
344
+ var log = "";
345
+ var spec;
346
+ var suite = env.describe("has after", function() {
347
+ spec = env.it('spec with after', function() {
348
+ this.runs(function() {
349
+ log += "spec";
350
+ });
351
+ });
352
+ });
353
+ spec.after(function() {
354
+ log += "after1";
355
+ });
356
+ spec.after(function() {
357
+ log += "after2";
358
+ });
359
+
360
+ suite.execute();
361
+
362
+ expect(log).toEqual("specafter2after1");
363
+ });
364
+
365
+ describe('test suite declaration', function() {
366
+ var suite;
367
+ var dummyFunction = function() {
368
+ };
369
+
370
+ it('should give the suite a description', function() {
371
+ suite = env.describe('one suite description', dummyFunction);
372
+ expect(suite.description).toEqual('one suite description');
373
+ });
374
+
375
+ it('should enqueue functions for multipart tests and support waits, and run any ready runs() blocks', function() {
376
+ var foo = 0;
377
+ var bar = 0;
378
+
379
+ suite = env.describe('one suite description', function () {
380
+ env.it('should be a test with queuedFunctions', function() {
381
+ this.runs(function() {
382
+ foo++;
383
+ });
384
+ this.waits(100);
385
+ this.runs(function() {
386
+ bar++;
387
+ });
388
+ });
389
+ });
390
+
391
+ suite.execute();
392
+
393
+ expect(foo).toEqual(1);
394
+ expect(bar).toEqual(0);
395
+
396
+ fakeTimer.tick(100);
397
+ expect(bar).toEqual(1);
398
+ });
399
+
400
+ });
401
+
402
+ it("testBeforeAndAfterCallbacks", function () {
403
+ var suiteWithBefore = env.describe('one suite with a before', function () {
404
+
405
+ this.beforeEach(function () {
406
+ this.foo = 1;
407
+ });
408
+
409
+ env.it('should be a spec', function () {
410
+ this.runs(function() {
411
+ this.foo++;
412
+ this.expect(this.foo).toEqual(2);
413
+ });
414
+ });
415
+
416
+ env.it('should be another spec', function () {
417
+ this.runs(function() {
418
+ this.foo++;
419
+ this.expect(this.foo).toEqual(2);
420
+ });
421
+ });
422
+ });
423
+
424
+ suiteWithBefore.execute();
425
+
426
+ var suite = suiteWithBefore;
427
+
428
+ expect(suite.results().getItems()[0].passed()).toEqual(true); // "testBeforeAndAfterCallbacks: the first spec's foo should have been 2");
429
+ expect(suite.results().getItems()[1].passed()).toEqual(true); // "testBeforeAndAfterCallbacks: the second spec's this.foo should have been 2");
430
+
431
+
432
+ var foo = 1;
433
+ var suiteWithAfter = env.describe('one suite with an after_each', function () {
434
+
435
+ env.it('should be a spec with an after_each', function () {
436
+ this.expect(foo).toEqual(1);
437
+ foo++;
438
+ this.expect(foo).toEqual(2);
439
+ });
440
+
441
+ env.it('should be another spec with an after_each', function () {
442
+ this.expect(foo).toEqual(0);
443
+ foo++;
444
+ this.expect(foo).toEqual(1);
445
+ });
446
+
447
+ this.afterEach(function () {
448
+ foo = 0;
449
+ });
450
+ });
451
+
452
+ suiteWithAfter.execute();
453
+
454
+ suite = suiteWithAfter;
455
+ expect(suite.afterEach.length).toEqual(1);
456
+ expect(suite.results().getItems()[0].passed()).toEqual(true);
457
+ expect(suite.results().getItems()[1].passed()).toEqual(true);
458
+ expect(foo).toEqual(0);
459
+
460
+ });
461
+
462
+ it('#waits should allow consecutive waits calls', function () {
463
+ var foo = 0;
464
+ var waitsSuite = env.describe('suite that waits', function () {
465
+ env.it('should wait', function() {
466
+ this.waits(500);
467
+ this.waits(500);
468
+ this.runs(function () {
469
+ foo++;
470
+ });
471
+ });
472
+ });
473
+
474
+ waitsSuite.execute();
475
+ expect(foo).toEqual(0);
476
+ fakeTimer.tick(500);
477
+ expect(foo).toEqual(0);
478
+ fakeTimer.tick(500);
479
+
480
+ expect(foo).toEqual(1);
481
+ });
482
+
483
+ it('nested suites', function () {
484
+
485
+ var foo = 0;
486
+ var bar = 0;
487
+ var baz = 0;
488
+ var quux = 0;
489
+ var nested = env.describe('suite', function () {
490
+ env.describe('nested', function () {
491
+ env.it('should run nested suites', function () {
492
+ foo++;
493
+ });
494
+ env.it('should run nested suites', function () {
495
+ bar++;
496
+ });
497
+ });
498
+
499
+ env.describe('nested 2', function () {
500
+ env.it('should run suites following nested suites', function () {
501
+ baz++;
502
+ });
503
+ });
504
+
505
+ env.it('should run tests following nested suites', function () {
506
+ quux++;
507
+ });
508
+ });
509
+
510
+ expect(foo).toEqual(0);
511
+ expect(bar).toEqual(0);
512
+ expect(baz).toEqual(0);
513
+ expect(quux).toEqual(0);
514
+ nested.execute();
515
+
516
+ expect(foo).toEqual(1);
517
+ expect(bar).toEqual(1);
518
+ expect(baz).toEqual(1);
519
+ expect(quux).toEqual(1);
520
+ });
521
+
522
+ describe('#waitsFor should allow consecutive calls', function () {
523
+
524
+ var foo;
525
+ beforeEach(function () {
526
+
527
+ foo = 0;
528
+ });
529
+
530
+ it('exits immediately (does not stack) if the latchFunction times out', function () {
531
+ var reachedFirstWaitsFor = false;
532
+ var reachedSecondWaitsFor = false;
533
+ var waitsSuite = env.describe('suite that waits', function () {
534
+ env.it('should stack timeouts', function() {
535
+ this.waitsFor(500, function () {
536
+ reachedFirstWaitsFor = true;
537
+ return false;
538
+ });
539
+ this.waitsFor(500, function () {
540
+ reachedSecondWaitsFor = true;
541
+ });
542
+ this.runs(function () {
543
+ foo++;
544
+ });
545
+ });
546
+ });
547
+
548
+ expect(reachedFirstWaitsFor).toEqual(false);
549
+ waitsSuite.execute();
550
+
551
+ expect(reachedFirstWaitsFor).toEqual(true);
552
+ expect(foo).toEqual(0);
553
+ expect(reachedSecondWaitsFor).toEqual(false);
554
+ fakeTimer.tick(500);
555
+ expect(reachedSecondWaitsFor).toEqual(false);
556
+ expect(foo).toEqual(0);
557
+ fakeTimer.tick(500);
558
+ expect(reachedSecondWaitsFor).toEqual(false);
559
+ expect(foo).toEqual(0);
560
+ });
561
+
562
+ it('stacks latchFunctions', function () {
563
+ var firstWaitsResult = false;
564
+ var secondWaitsResult = false;
565
+ var waitsSuite = env.describe('suite that waits', function () {
566
+ env.it('spec with waitsFors', function() {
567
+ this.waitsFor(600, function () {
568
+ fakeTimer.setTimeout(function () {
569
+ firstWaitsResult = true;
570
+ }, 300);
571
+ return firstWaitsResult;
572
+ });
573
+ this.waitsFor(600, function () {
574
+ fakeTimer.setTimeout(function () {
575
+ secondWaitsResult = true;
576
+ }, 300);
577
+ return secondWaitsResult;
578
+ });
579
+ this.runs(function () {
580
+ foo++;
581
+ });
582
+ });
583
+ });
584
+
585
+ expect(firstWaitsResult).toEqual(false);
586
+ expect(secondWaitsResult).toEqual(false);
587
+ waitsSuite.execute();
588
+
589
+ expect(firstWaitsResult).toEqual(false);
590
+ expect(secondWaitsResult).toEqual(false);
591
+ expect(foo).toEqual(0);
592
+
593
+ fakeTimer.tick(300);
594
+
595
+ expect(firstWaitsResult).toEqual(true);
596
+ expect(secondWaitsResult).toEqual(false);
597
+ expect(foo).toEqual(0);
598
+
599
+ fakeTimer.tick(300);
600
+
601
+ expect(firstWaitsResult).toEqual(true);
602
+ expect(secondWaitsResult).toEqual(true);
603
+ expect(foo).toEqual(1);
604
+
605
+ });
606
+ });
607
+
608
+ it("#beforeEach should be able to eval runs and waits blocks", function () {
609
+ var foo = 0;
610
+ var bar = 0;
611
+ var suiteWithBefore = env.describe('one suite with a before', function () {
612
+ this.beforeEach(function () {
613
+ this.runs(function () {
614
+ foo++;
615
+ });
616
+ this.waits(500);
617
+ this.runs(function () {
618
+ foo++;
619
+ });
620
+ this.waits(500);
621
+ });
622
+
623
+ env.it('should be a spec', function () {
624
+ bar = 1;
625
+ foo++;
626
+ });
627
+
628
+ });
629
+
630
+ expect(foo).toEqual(0);
631
+ expect(bar).toEqual(0);
632
+ suiteWithBefore.execute();
633
+
634
+ expect(bar).toEqual(0);
635
+ expect(foo).toEqual(1);
636
+ fakeTimer.tick(500);
637
+
638
+ expect(bar).toEqual(0);
639
+ expect(foo).toEqual(2);
640
+ fakeTimer.tick(500);
641
+ expect(bar).toEqual(1);
642
+ expect(foo).toEqual(3);
643
+ });
644
+
645
+ it("#afterEach should be able to eval runs and waits blocks", function () {
646
+ var foo = 0;
647
+ var firstSpecHasRun = false;
648
+ var secondSpecHasRun = false;
649
+ var suiteWithAfter = env.describe('one suite with a before', function () {
650
+ this.afterEach(function () {
651
+ this.waits(500);
652
+ this.runs(function () {
653
+ foo++;
654
+ });
655
+ this.waits(500);
656
+ });
657
+
658
+ env.it('should be the first spec', function () {
659
+ firstSpecHasRun = true;
660
+ });
661
+
662
+ env.it('should be a spec', function () {
663
+ secondSpecHasRun = true;
664
+ foo++;
665
+ });
666
+
667
+ });
668
+
669
+ expect(firstSpecHasRun).toEqual(false);
670
+ expect(secondSpecHasRun).toEqual(false);
671
+ expect(foo).toEqual(0);
672
+
673
+ suiteWithAfter.execute();
674
+
675
+
676
+ expect(firstSpecHasRun).toEqual(true);
677
+ expect(secondSpecHasRun).toEqual(false);
678
+ expect(foo).toEqual(0);
679
+
680
+ fakeTimer.tick(500);
681
+
682
+ expect(foo).toEqual(1);
683
+ expect(secondSpecHasRun).toEqual(false);
684
+ fakeTimer.tick(500);
685
+
686
+ expect(foo).toEqual(2);
687
+ expect(secondSpecHasRun).toEqual(true);
688
+
689
+ });
690
+
691
+ it("Spec#after should be able to eval runs and waits blocks", function () {
692
+ var runsBeforeAfter = false;
693
+ var firstSpecHasRun = false;
694
+ var secondSpecHasRun = false;
695
+ var afterHasRun = false;
696
+ var suiteWithAfter = env.describe('one suite with a before', function () {
697
+
698
+ env.it('should be the first spec', function () {
699
+ firstSpecHasRun = true;
700
+ this.after(function () {
701
+ this.waits(500);
702
+ this.runs(function () {
703
+ afterHasRun = true;
704
+ });
705
+ this.waits(500);
706
+ }, true);
707
+ this.waits(500);
708
+ this.runs(function () {
709
+ runsBeforeAfter = true;
710
+ });
711
+ });
712
+
713
+ env.it('should be a spec', function () {
714
+ secondSpecHasRun = true;
715
+ });
716
+
717
+ });
718
+
719
+ expect(firstSpecHasRun).toEqual(false);
720
+ expect(runsBeforeAfter).toEqual(false);
721
+ expect(afterHasRun).toEqual(false);
722
+ expect(secondSpecHasRun).toEqual(false);
723
+
724
+ suiteWithAfter.execute();
725
+
726
+ expect(firstSpecHasRun).toEqual(true);
727
+ expect(runsBeforeAfter).toEqual(false);
728
+ expect(afterHasRun).toEqual(false);
729
+ expect(secondSpecHasRun).toEqual(false);
730
+
731
+ fakeTimer.tick(500);
732
+
733
+ expect(firstSpecHasRun).toEqual(true);
734
+ expect(runsBeforeAfter).toEqual(true);
735
+ expect(afterHasRun).toEqual(false);
736
+ expect(secondSpecHasRun).toEqual(false);
737
+
738
+ fakeTimer.tick(500);
739
+
740
+ expect(firstSpecHasRun).toEqual(true);
741
+ expect(runsBeforeAfter).toEqual(true);
742
+ expect(afterHasRun).toEqual(true);
743
+ expect(secondSpecHasRun).toEqual(false);
744
+
745
+ fakeTimer.tick(500);
746
+
747
+ expect(firstSpecHasRun).toEqual(true);
748
+ expect(runsBeforeAfter).toEqual(true);
749
+ expect(afterHasRun).toEqual(true);
750
+ expect(secondSpecHasRun).toEqual(true);
751
+ });
752
+
753
+ it("handles waits", function () {
754
+ var firstSpecHasRun = false;
755
+ var secondSpecHasRun = false;
756
+ var suiteWithAfter = env.describe('one suite with a before', function () {
757
+
758
+ env.it('should be the first spec', function () {
759
+ this.waits(500);
760
+ this.runs(function () {
761
+ firstSpecHasRun = true;
762
+ });
763
+ });
764
+
765
+ env.it('should be a spec', function () {
766
+ secondSpecHasRun = true;
767
+ });
768
+
769
+ });
770
+
771
+ expect(firstSpecHasRun).toEqual(false);
772
+ expect(secondSpecHasRun).toEqual(false);
773
+
774
+ suiteWithAfter.execute();
775
+
776
+ expect(firstSpecHasRun).toEqual(false);
777
+ expect(secondSpecHasRun).toEqual(false);
778
+
779
+ fakeTimer.tick(500);
780
+
781
+ expect(firstSpecHasRun).toEqual(true);
782
+ expect(secondSpecHasRun).toEqual(true);
783
+ });
784
+
785
+ it("testBeforeExecutesSafely", function() {
786
+ var report = "";
787
+ var suite = env.describe('before fails on first test, passes on second', function() {
788
+ var counter = 0;
789
+ this.beforeEach(function() {
790
+ counter++;
791
+ if (counter == 1) {
792
+ throw "before failure";
793
+ }
794
+ });
795
+ env.it("first should not run because before fails", function() {
796
+ this.runs(function() {
797
+ report += "first";
798
+ this.expect(true).toEqual(true);
799
+ });
800
+ });
801
+ env.it("second should run and pass because before passes", function() {
802
+ this.runs(function() {
803
+ report += "second";
804
+ this.expect(true).toEqual(true);
805
+ });
806
+ });
807
+ });
808
+
809
+ suite.execute();
810
+
811
+ expect(report).toEqual("firstsecond");
812
+ var suiteResults = suite.results();
813
+ expect(suiteResults.getItems()[0].getItems()[0].passed()).toEqual(false);
814
+ expect(suiteResults.getItems()[1].getItems()[0].passed()).toEqual(true);
815
+ });
816
+
817
+ it("testAfterExecutesSafely", function() {
818
+ var report = "";
819
+ var suite = env.describe('after fails on first test, then passes', function() {
820
+ var counter = 0;
821
+ this.afterEach(function() {
822
+ counter++;
823
+ if (counter == 1) {
824
+ throw "after failure";
825
+ }
826
+ });
827
+ env.it("first should run, expectation passes, but spec fails because after fails", function() {
828
+ this.runs(function() {
829
+ report += "first";
830
+ this.expect(true).toEqual(true);
831
+ });
832
+ });
833
+ env.it("second should run and pass because after passes", function() {
834
+ this.runs(function() {
835
+ report += "second";
836
+ this.expect(true).toEqual(true);
837
+ });
838
+ });
839
+ env.it("third should run and pass because after passes", function() {
840
+ this.runs(function() {
841
+ report += "third";
842
+ this.expect(true).toEqual(true);
843
+ });
844
+ });
845
+ });
846
+
847
+ suite.execute();
848
+
849
+ expect(report).toEqual("firstsecondthird"); // "all tests should run");
850
+ //After each errors should not go in spec results because it confuses the count.
851
+ var suiteResults = suite.results();
852
+ expect(suiteResults.getItems().length).toEqual(3, 'testAfterExecutesSafely should have results for three specs');
853
+
854
+ expect(suiteResults.getItems()[0].getItems()[0].passed()).toEqual(true, "testAfterExecutesSafely 1st spec should pass");
855
+ expect(suiteResults.getItems()[1].getItems()[0].passed()).toEqual(true, "testAfterExecutesSafely 2nd spec should pass");
856
+ expect(suiteResults.getItems()[2].getItems()[0].passed()).toEqual(true, "testAfterExecutesSafely 3rd spec should pass");
857
+
858
+ expect(suiteResults.getItems()[0].getItems()[0].passed()).toEqual(true, "testAfterExecutesSafely 1st result for 1st suite spec should pass");
859
+ expect(suiteResults.getItems()[0].getItems()[1].passed()).toEqual(false, "testAfterExecutesSafely 2nd result for 1st suite spec should fail because afterEach failed");
860
+ expect(suiteResults.getItems()[1].getItems()[0].passed()).toEqual(true, "testAfterExecutesSafely 2nd suite spec should pass");
861
+ expect(suiteResults.getItems()[2].getItems()[0].passed()).toEqual(true, "testAfterExecutesSafely 3rd suite spec should pass");
862
+ });
863
+
864
+ it("testNestedDescribes", function() {
865
+ var actions = [];
866
+
867
+ env.beforeEach(function () {
868
+ actions.push('runner beforeEach');
869
+ });
870
+
871
+ env.afterEach(function () {
872
+ actions.push('runner afterEach');
873
+ });
874
+
875
+ env.describe('Something', function() {
876
+ env.beforeEach(function() {
877
+ actions.push('outer beforeEach');
878
+ });
879
+
880
+ env.afterEach(function() {
881
+ actions.push('outer afterEach');
882
+ });
883
+
884
+ env.it('does it 1', function() {
885
+ actions.push('outer it 1');
886
+ });
887
+
888
+ env.describe('Inner 1', function() {
889
+ env.beforeEach(function() {
890
+ actions.push('inner 1 beforeEach');
891
+ });
892
+
893
+ env.afterEach(function() {
894
+ actions.push('inner 1 afterEach');
895
+ });
896
+
897
+ env.it('does it 2', function() {
898
+ actions.push('inner 1 it');
899
+ });
900
+ });
901
+
902
+ env.it('does it 3', function() {
903
+ actions.push('outer it 2');
904
+ });
905
+
906
+ env.describe('Inner 2', function() {
907
+ env.beforeEach(function() {
908
+ actions.push('inner 2 beforeEach');
909
+ });
910
+
911
+ env.afterEach(function() {
912
+ actions.push('inner 2 afterEach');
913
+ });
914
+
915
+ env.it('does it 2', function() {
916
+ actions.push('inner 2 it');
917
+ });
918
+ });
919
+ });
920
+
921
+ env.execute();
922
+
923
+
924
+ var expected = [
925
+ "runner beforeEach",
926
+ "outer beforeEach",
927
+ "outer it 1",
928
+ "outer afterEach",
929
+ "runner afterEach",
930
+
931
+ "runner beforeEach",
932
+ "outer beforeEach",
933
+ "inner 1 beforeEach",
934
+ "inner 1 it",
935
+ "inner 1 afterEach",
936
+ "outer afterEach",
937
+ "runner afterEach",
938
+
939
+ "runner beforeEach",
940
+ "outer beforeEach",
941
+ "outer it 2",
942
+ "outer afterEach",
943
+ "runner afterEach",
944
+
945
+ "runner beforeEach",
946
+ "outer beforeEach",
947
+ "inner 2 beforeEach",
948
+ "inner 2 it",
949
+ "inner 2 afterEach",
950
+ "outer afterEach",
951
+ "runner afterEach"
952
+ ];
953
+ expect(actions).toEqual(expected);
954
+ });
955
+
956
+ it("builds up nested names", function() {
957
+ var nestedSpec;
958
+ env.describe('Test Subject', function() {
959
+ env.describe('when under circumstance A', function() {
960
+ env.describe('and circumstance B', function() {
961
+ nestedSpec = env.it('behaves thusly', function() {
962
+ });
963
+ });
964
+ });
965
+ });
966
+
967
+ expect(nestedSpec.getFullName()).toEqual('Test Subject when under circumstance A and circumstance B behaves thusly.'); //, "Spec.fullName was incorrect: " + nestedSpec.getFullName());
968
+ });
969
+
970
+ it("should skip empty suites", function () {
971
+ env.describe('NonEmptySuite1', function() {
972
+ env.it('should pass', function() {
973
+ this.expect(true).toEqual(true);
974
+ });
975
+ env.describe('NestedEmptySuite', function() {
976
+ });
977
+ env.it('should pass', function() {
978
+ this.expect(true).toEqual(true);
979
+ });
980
+ });
981
+
982
+ env.describe('EmptySuite', function() {
983
+ });
984
+
985
+ env.describe('NonEmptySuite2', function() {
986
+ env.it('should pass', function() {
987
+ this.expect(true).toEqual(true);
988
+ });
989
+ });
990
+
991
+ env.execute();
992
+
993
+ var runnerResults = env.currentRunner_.results();
994
+ expect(runnerResults.totalCount).toEqual(3);
995
+ expect(runnerResults.passedCount).toEqual(3);
996
+ expect(runnerResults.failedCount).toEqual(0);
997
+ });
998
+
999
+ it("should bind 'this' to the running spec within the spec body", function() {
1000
+ var spec;
1001
+ var suite = env.describe('one suite description', function () {
1002
+ env.it('should be a test with queuedFunctions', function() {
1003
+ spec = this.runs(function() {
1004
+ this.foo = 0;
1005
+ this.foo++;
1006
+ });
1007
+
1008
+ this.runs(function() {
1009
+ var that = this;
1010
+ fakeTimer.setTimeout(function() {
1011
+ that.foo++;
1012
+ }, 250);
1013
+ });
1014
+
1015
+ this.runs(function() {
1016
+ this.expect(this.foo).toEqual(2);
1017
+ });
1018
+
1019
+ this.waits(300);
1020
+
1021
+ this.runs(function() {
1022
+ this.expect(this.foo).toEqual(2);
1023
+ });
1024
+ });
1025
+
1026
+ });
1027
+
1028
+ suite.execute();
1029
+ fakeTimer.tick(600);
1030
+ expect(spec.foo).toEqual(2);
1031
+ var suiteResults = suite.results();
1032
+ expect(suiteResults.getItems()[0].getItems().length).toEqual(2);
1033
+ expect(suiteResults.getItems()[0].getItems()[0].passed()).toEqual(false);
1034
+ expect(suiteResults.getItems()[0].getItems()[1].passed()).toEqual(true);
1035
+ });
1036
+
1037
+ it("shouldn't run disabled tests", function() {
1038
+ var xitSpecWasRun = false;
1039
+ var suite = env.describe('default current suite', function() {
1040
+ env.xit('disabled spec').runs(function () {
1041
+ xitSpecWasRun = true;
1042
+ });
1043
+
1044
+ env.it('enabled spec').runs(function () {
1045
+ var foo = 'bar';
1046
+ expect(foo).toEqual('bar');
1047
+ });
1048
+ });
1049
+
1050
+ suite.execute();
1051
+ expect(xitSpecWasRun).toEqual(false);
1052
+ });
1053
+
1054
+ it('shouldn\'t execute specs in disabled suites', function() {
1055
+ var spy = jasmine.createSpy();
1056
+ var disabledSuite = env.xdescribe('a disabled suite', function() {
1057
+ env.it('enabled spec, but should not be run', function() {
1058
+ spy();
1059
+ });
1060
+ });
1061
+
1062
+ disabledSuite.execute();
1063
+
1064
+ expect(spy).wasNotCalled();
1065
+ });
1066
+
1067
+ it('#explodes should throw an exception when it is called inside a spec', function() {
1068
+ var exceptionMessage = false;
1069
+ var anotherSuite = env.describe('Spec', function () {
1070
+ env.it('plodes', function() {
1071
+ try {
1072
+ this.explodes();
1073
+ }
1074
+ catch (e) {
1075
+ exceptionMessage = e;
1076
+ }
1077
+ expect(exceptionMessage).toNotEqual(false);
1078
+ });
1079
+ });
1080
+
1081
+ anotherSuite.execute();
1082
+
1083
+ expect(exceptionMessage).toEqual('explodes function should not have been called');
1084
+ });
1085
+
1086
+ it("should be easy to add more matchers local to a spec, suite, etc.", function() {
1087
+ var spec1, spec2, spec1Matcher, spec2Matcher;
1088
+
1089
+ var suite = env.describe('some suite', function() {
1090
+ env.beforeEach(function() {
1091
+ this.addMatchers({ matcherForSuite: function(expected) {
1092
+ return "matcherForSuite: actual: " + this.actual + "; expected: " + expected;
1093
+ } });
1094
+ });
1095
+
1096
+ spec1 = env.it('spec with an expectation').runs(function () {
1097
+ this.addMatchers({ matcherForSpec: function(expected) {
1098
+ return "matcherForSpec: actual: " + this.actual + "; expected: " + expected;
1099
+ } });
1100
+ spec1Matcher = this.expect("xxx");
1101
+ });
1102
+
1103
+ spec2 = env.it('spec with failing expectation').runs(function () {
1104
+ spec2Matcher = this.expect("yyy");
1105
+ });
1106
+ });
1107
+
1108
+ suite.execute();
1109
+
1110
+ expect(spec1Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: xxx; expected: expected");
1111
+ expect(spec1Matcher.matcherForSpec("expected")).toEqual("matcherForSpec: actual: xxx; expected: expected");
1112
+
1113
+ expect(spec2Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: yyy; expected: expected");
1114
+ expect(spec2Matcher.matcherForSpec).toBe(jasmine.undefined);
1115
+ });
1116
+
1117
+ });