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,2526 @@
1
+ /**
2
+ * Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
3
+ *
4
+ * @namespace
5
+ */
6
+ var jasmine = {};
7
+
8
+ /**
9
+ * @private
10
+ */
11
+ jasmine.unimplementedMethod_ = function() {
12
+ throw new Error("unimplemented method");
13
+ };
14
+
15
+ /**
16
+ * Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code is just
17
+ * a plain old variable and may be redefined by somebody else.
18
+ *
19
+ * @private
20
+ */
21
+ jasmine.undefined = jasmine.___undefined___;
22
+
23
+ /**
24
+ * Default interval for event loop yields. Small values here may result in slow test running. Zero means no updates until all tests have completed.
25
+ *
26
+ */
27
+ jasmine.DEFAULT_UPDATE_INTERVAL = 250;
28
+
29
+ /**
30
+ * Allows for bound functions to be compared. Internal use only.
31
+ *
32
+ * @ignore
33
+ * @private
34
+ * @param base {Object} bound 'this' for the function
35
+ * @param name {Function} function to find
36
+ */
37
+ jasmine.bindOriginal_ = function(base, name) {
38
+ var original = base[name];
39
+ if (original.apply) {
40
+ return function() {
41
+ return original.apply(base, arguments);
42
+ };
43
+ } else {
44
+ // IE support
45
+ return window[name];
46
+ }
47
+ };
48
+
49
+ jasmine.setTimeout = jasmine.bindOriginal_(window, 'setTimeout');
50
+ jasmine.clearTimeout = jasmine.bindOriginal_(window, 'clearTimeout');
51
+ jasmine.setInterval = jasmine.bindOriginal_(window, 'setInterval');
52
+ jasmine.clearInterval = jasmine.bindOriginal_(window, 'clearInterval');
53
+
54
+ jasmine.MessageResult = function(text) {
55
+ this.type = 'MessageResult';
56
+ this.text = text;
57
+ this.trace = new Error(); // todo: test better
58
+ };
59
+
60
+ jasmine.ExpectationResult = function(params) {
61
+ this.type = 'ExpectationResult';
62
+ this.matcherName = params.matcherName;
63
+ this.passed_ = params.passed;
64
+ this.expected = params.expected;
65
+ this.actual = params.actual;
66
+
67
+ /** @deprecated */
68
+ this.details = params.details;
69
+
70
+ this.message = this.passed_ ? 'Passed.' : params.message;
71
+ this.trace = this.passed_ ? '' :
72
+ ( params.exception ? params.exception : new Error(this.message) );
73
+ };
74
+
75
+ jasmine.ExpectationResult.prototype.passed = function () {
76
+ return this.passed_;
77
+ };
78
+
79
+ /**
80
+ * Getter for the Jasmine environment. Ensures one gets created
81
+ */
82
+ jasmine.getEnv = function() {
83
+ return jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
84
+ };
85
+
86
+ /**
87
+ * @ignore
88
+ * @private
89
+ * @param value
90
+ * @returns {Boolean}
91
+ */
92
+ jasmine.isArray_ = function(value) {
93
+ return value &&
94
+ ( value instanceof Array || (
95
+ typeof value === 'object' &&
96
+ typeof value.length === 'number' &&
97
+ ( typeof value.splice === 'function' || value.callee || value.item ) &&
98
+ !(value.propertyIsEnumerable('length')) ) );
99
+ };
100
+
101
+ /**
102
+ * Pretty printer for expecations. Takes any object and turns it into a human-readable string.
103
+ *
104
+ * @param value {Object} an object to be outputted
105
+ * @returns {String}
106
+ */
107
+ jasmine.pp = function(value) {
108
+ var stringPrettyPrinter = new jasmine.StringPrettyPrinter();
109
+ stringPrettyPrinter.format(value);
110
+ return stringPrettyPrinter.string;
111
+ };
112
+
113
+ /**
114
+ * Returns true if the object is a DOM Node.
115
+ *
116
+ * @param {Object} obj object to check
117
+ * @returns {Boolean}
118
+ */
119
+ jasmine.isDomNode = function(obj) {
120
+ return obj['nodeType'] > 0;
121
+ };
122
+
123
+ /**
124
+ * Returns a matchable 'generic' object of the class type. For use in expecations of type when values don't matter.
125
+ *
126
+ * @example
127
+ * // don't care about which function is passed in, as long as it's a function
128
+ * expect(mySpy).wasCalledWith(jasmine.any(Function));
129
+ *
130
+ * @param {Class} clazz
131
+ * @returns matchable object of the type clazz
132
+ */
133
+ jasmine.any = function(clazz) {
134
+ return new jasmine.Matchers.Any(clazz);
135
+ };
136
+
137
+ /**
138
+ * Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks.
139
+ *
140
+ * Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine
141
+ * expectation syntax. Spies can be checked if they were called or not and what the calling params were.
142
+ *
143
+ * A Spy has the following mehtod: wasCalled, callCount, mostRecentCall, and argsForCall (see docs)
144
+ * Spies are torn down at the end of every spec.
145
+ *
146
+ * Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj.
147
+ *
148
+ * @example
149
+ * // a stub
150
+ * var myStub = jasmine.createSpy('myStub'); // can be used anywhere
151
+ *
152
+ * // spy example
153
+ * var foo = {
154
+ * not: function(bool) { return !bool; }
155
+ * }
156
+ *
157
+ * // actual foo.not will not be called, execution stops
158
+ * spyOn(foo, 'not');
159
+
160
+ // foo.not spied upon, execution will continue to implementation
161
+ * spyOn(foo, 'not').andCallThrough();
162
+ *
163
+ * // fake example
164
+ * var foo = {
165
+ * not: function(bool) { return !bool; }
166
+ * }
167
+ *
168
+ * // foo.not(val) will return val
169
+ * spyOn(foo, 'not').andCallFake(function(value) {return value;});
170
+ *
171
+ * // mock example
172
+ * foo.not(7 == 7);
173
+ * expect(foo.not).wasCalled();
174
+ * expect(foo.not).wasCalledWith(true);
175
+ *
176
+ * @constructor
177
+ * @see spyOn, jasmine.createSpy, jasmine.createSpyObj
178
+ * @param {String} name
179
+ */
180
+ jasmine.Spy = function(name) {
181
+ /**
182
+ * The name of the spy, if provided.
183
+ */
184
+ this.identity = name || 'unknown';
185
+ /**
186
+ * Is this Object a spy?
187
+ */
188
+ this.isSpy = true;
189
+ /**
190
+ * The actual function this spy stubs.
191
+ */
192
+ this.plan = function() {
193
+ };
194
+ /**
195
+ * Tracking of the most recent call to the spy.
196
+ * @example
197
+ * var mySpy = jasmine.createSpy('foo');
198
+ * mySpy(1, 2);
199
+ * mySpy.mostRecentCall.args = [1, 2];
200
+ */
201
+ this.mostRecentCall = {};
202
+
203
+ /**
204
+ * Holds arguments for each call to the spy, indexed by call count
205
+ * @example
206
+ * var mySpy = jasmine.createSpy('foo');
207
+ * mySpy(1, 2);
208
+ * mySpy(7, 8);
209
+ * mySpy.mostRecentCall.args = [7, 8];
210
+ * mySpy.argsForCall[0] = [1, 2];
211
+ * mySpy.argsForCall[1] = [7, 8];
212
+ */
213
+ this.argsForCall = [];
214
+ this.calls = [];
215
+ };
216
+
217
+ /**
218
+ * Tells a spy to call through to the actual implemenatation.
219
+ *
220
+ * @example
221
+ * var foo = {
222
+ * bar: function() { // do some stuff }
223
+ * }
224
+ *
225
+ * // defining a spy on an existing property: foo.bar
226
+ * spyOn(foo, 'bar').andCallThrough();
227
+ */
228
+ jasmine.Spy.prototype.andCallThrough = function() {
229
+ this.plan = this.originalValue;
230
+ return this;
231
+ };
232
+
233
+ /**
234
+ * For setting the return value of a spy.
235
+ *
236
+ * @example
237
+ * // defining a spy from scratch: foo() returns 'baz'
238
+ * var foo = jasmine.createSpy('spy on foo').andReturn('baz');
239
+ *
240
+ * // defining a spy on an existing property: foo.bar() returns 'baz'
241
+ * spyOn(foo, 'bar').andReturn('baz');
242
+ *
243
+ * @param {Object} value
244
+ */
245
+ jasmine.Spy.prototype.andReturn = function(value) {
246
+ this.plan = function() {
247
+ return value;
248
+ };
249
+ return this;
250
+ };
251
+
252
+ /**
253
+ * For throwing an exception when a spy is called.
254
+ *
255
+ * @example
256
+ * // defining a spy from scratch: foo() throws an exception w/ message 'ouch'
257
+ * var foo = jasmine.createSpy('spy on foo').andThrow('baz');
258
+ *
259
+ * // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch'
260
+ * spyOn(foo, 'bar').andThrow('baz');
261
+ *
262
+ * @param {String} exceptionMsg
263
+ */
264
+ jasmine.Spy.prototype.andThrow = function(exceptionMsg) {
265
+ this.plan = function() {
266
+ throw exceptionMsg;
267
+ };
268
+ return this;
269
+ };
270
+
271
+ /**
272
+ * Calls an alternate implementation when a spy is called.
273
+ *
274
+ * @example
275
+ * var baz = function() {
276
+ * // do some stuff, return something
277
+ * }
278
+ * // defining a spy from scratch: foo() calls the function baz
279
+ * var foo = jasmine.createSpy('spy on foo').andCall(baz);
280
+ *
281
+ * // defining a spy on an existing property: foo.bar() calls an anonymnous function
282
+ * spyOn(foo, 'bar').andCall(function() { return 'baz';} );
283
+ *
284
+ * @param {Function} fakeFunc
285
+ */
286
+ jasmine.Spy.prototype.andCallFake = function(fakeFunc) {
287
+ this.plan = fakeFunc;
288
+ return this;
289
+ };
290
+
291
+ /**
292
+ * Resets all of a spy's the tracking variables so that it can be used again.
293
+ *
294
+ * @example
295
+ * spyOn(foo, 'bar');
296
+ *
297
+ * foo.bar();
298
+ *
299
+ * expect(foo.bar.callCount).toEqual(1);
300
+ *
301
+ * foo.bar.reset();
302
+ *
303
+ * expect(foo.bar.callCount).toEqual(0);
304
+ */
305
+ jasmine.Spy.prototype.reset = function() {
306
+ this.wasCalled = false;
307
+ this.callCount = 0;
308
+ this.argsForCall = [];
309
+ this.calls = [];
310
+ this.mostRecentCall = {};
311
+ };
312
+
313
+ jasmine.createSpy = function(name) {
314
+
315
+ var spyObj = function() {
316
+ spyObj.wasCalled = true;
317
+ spyObj.callCount++;
318
+ var args = jasmine.util.argsToArray(arguments);
319
+ spyObj.mostRecentCall.object = this;
320
+ spyObj.mostRecentCall.args = args;
321
+ spyObj.argsForCall.push(args);
322
+ spyObj.calls.push({object: this, args: args});
323
+ if(this instanceof arguments.callee) {
324
+ var a = arguments;
325
+ var array = ["new spyObj.plan("];
326
+ for(var i=0; i < a.length; i++){
327
+ if(i>0){
328
+ array.push(",");
329
+ }
330
+ array.push("a[", i, "]");
331
+ }
332
+ array.push(")");
333
+ var string = array.join("");
334
+ return eval(string);
335
+ } else {
336
+ return spyObj.plan.apply(this, arguments);
337
+ }
338
+ };
339
+
340
+ var spy = new jasmine.Spy(name);
341
+
342
+ for (var prop in spy) {
343
+ spyObj[prop] = spy[prop];
344
+ }
345
+
346
+ spyObj.reset();
347
+
348
+ return spyObj;
349
+ };
350
+
351
+ /**
352
+ * Determines whether an object is a spy.
353
+ *
354
+ * @param {jasmine.Spy|Object} putativeSpy
355
+ * @returns {Boolean}
356
+ */
357
+ jasmine.isSpy = function(putativeSpy) {
358
+ return putativeSpy && putativeSpy.isSpy;
359
+ };
360
+
361
+ /**
362
+ * Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something
363
+ * large in one call.
364
+ *
365
+ * @param {String} baseName name of spy class
366
+ * @param {Array} methodNames array of names of methods to make spies
367
+ */
368
+ jasmine.createSpyObj = function(baseName, methodNames) {
369
+ var obj = {};
370
+ for (var i = 0; i < methodNames.length; i++) {
371
+ obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]);
372
+ }
373
+ return obj;
374
+ };
375
+
376
+ jasmine.log = function(message) {
377
+ jasmine.getEnv().currentSpec.log(message);
378
+ };
379
+
380
+ /**
381
+ * Function that installs a spy on an existing object's method name. Used within a Spec to create a spy.
382
+ *
383
+ * @example
384
+ * // spy example
385
+ * var foo = {
386
+ * not: function(bool) { return !bool; }
387
+ * }
388
+ * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops
389
+ *
390
+ * @see jasmine.createSpy
391
+ * @param obj
392
+ * @param methodName
393
+ * @returns a Jasmine spy that can be chained with all spy methods
394
+ */
395
+ var spyOn = function(obj, methodName, ignore) {
396
+ return jasmine.getEnv().currentSpec.spyOn(obj, methodName, ignore);
397
+ };
398
+
399
+ /**
400
+ * Creates a Jasmine spec that will be added to the current suite.
401
+ *
402
+ * // TODO: pending tests
403
+ *
404
+ * @example
405
+ * it('should be true', function() {
406
+ * expect(true).toEqual(true);
407
+ * });
408
+ *
409
+ * @param {String} desc description of this specification
410
+ * @param {Function} func defines the preconditions and expectations of the spec
411
+ */
412
+ var it = function(desc, func) {
413
+ return jasmine.getEnv().it(desc, func);
414
+ };
415
+
416
+ /**
417
+ * Creates a <em>disabled</em> Jasmine spec.
418
+ *
419
+ * A convenience method that allows existing specs to be disabled temporarily during development.
420
+ *
421
+ * @param {String} desc description of this specification
422
+ * @param {Function} func defines the preconditions and expectations of the spec
423
+ */
424
+ var xit = function(desc, func) {
425
+ return jasmine.getEnv().xit(desc, func);
426
+ };
427
+
428
+ jasmine.pending_ = function(){
429
+ Error.call(this,"Pending");
430
+ };
431
+ jasmine.pending_.prototype = new Error;
432
+
433
+ var pending = function() {
434
+ throw new jasmine.pending_;
435
+ };
436
+
437
+ jasmine.eventually_ = function(){
438
+ Error.call(this,"Eventually");
439
+ };
440
+ jasmine.eventually_.prototype = new Error;
441
+
442
+ /**
443
+ * Starts a chain for a Jasmine expectation.
444
+ *
445
+ * It is passed an Object that is the actual value and should chain to one of the many
446
+ * jasmine.Matchers functions.
447
+ *
448
+ * @param {Object} actual Actual value to test against and expected value
449
+ */
450
+ var expect = function(actual) {
451
+ return jasmine.getEnv().currentSpec.expect(actual);
452
+ };
453
+
454
+ /**
455
+ * Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs.
456
+ *
457
+ * @param {Function} func Function that defines part of a jasmine spec.
458
+ */
459
+ var runs = function(func) {
460
+ jasmine.getEnv().currentSpec.runs(func);
461
+ };
462
+
463
+ /**
464
+ * Waits for a timeout before moving to the next runs()-defined block.
465
+ * @param {Number} timeout
466
+ */
467
+ var waits = function(timeout) {
468
+ jasmine.getEnv().currentSpec.waits(timeout);
469
+ };
470
+
471
+ var anticipate = function(number) {
472
+ jasmine.getEnv().currentSpec.anticipate(number);
473
+ };
474
+
475
+ var incomplete = function(delay) {
476
+ jasmine.getEnv().currentSpec.stop(delay);
477
+ };
478
+
479
+ var complete = function() {
480
+ jasmine.getEnv().currentSpec.start();
481
+ };
482
+
483
+ var eventually = function(fn) {
484
+ jasmine.getEnv().currentSpec.eventually(fn);
485
+ };
486
+
487
+ var wait_for = function(condition,fn) {
488
+ jasmine.getEnv().currentSpec.wait_for(condition,fn);
489
+ };
490
+
491
+ /**
492
+ * Waits for the latchFunction to return true before proceeding to the next runs()-defined block.
493
+ *
494
+ * @param {Number} timeout
495
+ * @param {Function} latchFunction
496
+ * @param {String} message
497
+ */
498
+ var waitsFor = function(timeout, latchFunction, message) {
499
+ jasmine.getEnv().currentSpec.waitsFor(timeout, latchFunction, message);
500
+ };
501
+
502
+ /**
503
+ * A function that is called before each spec in a suite.
504
+ *
505
+ * Used for spec setup, including validating assumptions.
506
+ *
507
+ * @param {Function} beforeEachFunction
508
+ */
509
+ var beforeEach = function(beforeEachFunction) {
510
+ jasmine.getEnv().beforeEach(beforeEachFunction);
511
+ };
512
+
513
+ /**
514
+ * A function that is called after each spec in a suite.
515
+ *
516
+ * Used for restoring any state that is hijacked during spec execution.
517
+ *
518
+ * @param {Function} afterEachFunction
519
+ */
520
+ var afterEach = function(afterEachFunction) {
521
+ jasmine.getEnv().afterEach(afterEachFunction);
522
+ };
523
+
524
+ /**
525
+ * Defines a suite of specifications.
526
+ *
527
+ * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared
528
+ * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization
529
+ * of setup in some tests.
530
+ *
531
+ * @example
532
+ * // TODO: a simple suite
533
+ *
534
+ * // TODO: a simple suite with a nested describe block
535
+ *
536
+ * @param {String} description A string, usually the class under test.
537
+ * @param {Function} specDefinitions function that defines several specs.
538
+ */
539
+ var describe = function(description, specDefinitions) {
540
+ return jasmine.getEnv().describe(description, specDefinitions);
541
+ };
542
+
543
+ /**
544
+ * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
545
+ *
546
+ * @param {String} description A string, usually the class under test.
547
+ * @param {Function} specDefinitions function that defines several specs.
548
+ */
549
+ var xdescribe = function(description, specDefinitions) {
550
+ return jasmine.getEnv().xdescribe(description, specDefinitions);
551
+ };
552
+
553
+
554
+ jasmine.XmlHttpRequest = XMLHttpRequest;
555
+
556
+ // Provide the XMLHttpRequest class for IE 5.x-6.x:
557
+ if (typeof XMLHttpRequest == "undefined") jasmine.XmlHttpRequest = function() {
558
+ try {
559
+ return new ActiveXObject("Msxml2.XMLHTTP.6.0");
560
+ } catch(e) {
561
+ }
562
+ try {
563
+ return new ActiveXObject("Msxml2.XMLHTTP.3.0");
564
+ } catch(e) {
565
+ }
566
+ try {
567
+ return new ActiveXObject("Msxml2.XMLHTTP");
568
+ } catch(e) {
569
+ }
570
+ try {
571
+ return new ActiveXObject("Microsoft.XMLHTTP");
572
+ } catch(e) {
573
+ }
574
+ throw new Error("This browser does not support XMLHttpRequest.");
575
+ };
576
+
577
+ /**
578
+ * Adds suite files to an HTML document so that they are executed, thus adding them to the current
579
+ * Jasmine environment.
580
+ *
581
+ * @param {String} url path to the file to include
582
+ * @param {Boolean} opt_global
583
+ */
584
+
585
+ jasmine._eval = function(__jasmine__) {
586
+ return (function(){eval(__jasmine__);})();
587
+ };
588
+
589
+ jasmine.include = function(url, opt_global) {
590
+ if (opt_global) {
591
+ document.write('<script type="text/javascript" src="' + url + '"></' + 'script>');
592
+ } else {
593
+ var xhr;
594
+ try {
595
+ xhr = new jasmine.XmlHttpRequest();
596
+ xhr.open("GET", url, false);
597
+ xhr.send(null);
598
+ } catch(e) {
599
+ throw new Error("couldn't fetch " + url + ": " + e);
600
+ }
601
+
602
+ return jasmine._eval(xhr.responseText);
603
+ }
604
+ };
605
+ /**
606
+ * @namespace
607
+ */
608
+ jasmine.util = {};
609
+
610
+ /**
611
+ * Declare that a child class inherit it's prototype from the parent class.
612
+ *
613
+ * @private
614
+ * @param {Function} childClass
615
+ * @param {Function} parentClass
616
+ */
617
+ jasmine.util.inherit = function(childClass, parentClass) {
618
+ /**
619
+ * @private
620
+ */
621
+ var subclass = function() {
622
+ };
623
+ subclass.prototype = parentClass.prototype;
624
+ childClass.prototype = new subclass;
625
+ };
626
+
627
+ jasmine.util.formatException = function(e) {
628
+ var lineNumber;
629
+ if (e.line) {
630
+ lineNumber = e.line;
631
+ }
632
+ else if (e.lineNumber) {
633
+ lineNumber = e.lineNumber;
634
+ }
635
+
636
+ var file;
637
+
638
+ if (e.sourceURL) {
639
+ file = e.sourceURL;
640
+ }
641
+ else if (e.fileName) {
642
+ file = e.fileName;
643
+ }
644
+
645
+ var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();
646
+
647
+ if (file && lineNumber) {
648
+ message += ' in ' + file + ' (line ' + lineNumber + ')';
649
+ }
650
+
651
+ return message;
652
+ };
653
+
654
+ jasmine.util.htmlEscape = function(str) {
655
+ if (!str) return str;
656
+ return str.replace(/&/g, '&amp;')
657
+ .replace(/</g, '&lt;')
658
+ .replace(/>/g, '&gt;');
659
+ };
660
+
661
+ jasmine.util.argsToArray = function(args) {
662
+ var arrayOfArgs = [];
663
+ for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
664
+ return arrayOfArgs;
665
+ };
666
+
667
+ jasmine.util.extend = function(destination, source) {
668
+ for (var property in source) destination[property] = source[property];
669
+ return destination;
670
+ };
671
+
672
+ /**
673
+ * Environment for Jasmine
674
+ *
675
+ * @constructor
676
+ */
677
+ jasmine.Env = function() {
678
+ this.currentSpec = null;
679
+ this.currentSuite = null;
680
+ this.currentRunner_ = new jasmine.Runner(this);
681
+
682
+ this.reporter = new jasmine.MultiReporter();
683
+
684
+ this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
685
+ this.lastUpdate = 0;
686
+ this.specFilter = function() {
687
+ return true;
688
+ };
689
+
690
+ this.nextSpecId_ = 0;
691
+ this.nextSuiteId_ = 0;
692
+ this.equalityTesters_ = [];
693
+
694
+ // wrap matchers
695
+ this.matchersClass = function() {
696
+ jasmine.Matchers.apply(this, arguments);
697
+ };
698
+ jasmine.util.inherit(this.matchersClass, jasmine.Matchers);
699
+
700
+ for (var methodName in jasmine.Matchers.prototype) {
701
+ var orig = jasmine.Matchers.prototype[methodName];
702
+ this.matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
703
+ }
704
+ };
705
+
706
+
707
+ jasmine.Env.prototype.setTimeout = jasmine.setTimeout;
708
+ jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;
709
+ jasmine.Env.prototype.setInterval = jasmine.setInterval;
710
+ jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
711
+
712
+ /**
713
+ * @returns an object containing jasmine version build info, if set.
714
+ */
715
+ jasmine.Env.prototype.version = function () {
716
+ if (jasmine.version_) {
717
+ return jasmine.version_;
718
+ } else {
719
+ throw new Error('Version not set');
720
+ }
721
+ };
722
+
723
+ /**
724
+ * @returns a sequential integer starting at 0
725
+ */
726
+ jasmine.Env.prototype.nextSpecId = function () {
727
+ return this.nextSpecId_++;
728
+ };
729
+
730
+ /**
731
+ * @returns a sequential integer starting at 0
732
+ */
733
+ jasmine.Env.prototype.nextSuiteId = function () {
734
+ return this.nextSuiteId_++;
735
+ };
736
+
737
+ /**
738
+ * Register a reporter to receive status updates from Jasmine.
739
+ * @param {jasmine.Reporter} reporter An object which will receive status updates.
740
+ */
741
+ jasmine.Env.prototype.addReporter = function(reporter) {
742
+ this.reporter.addReporter(reporter);
743
+ };
744
+
745
+ jasmine.Env.prototype.execute = function() {
746
+ this.currentRunner_.execute();
747
+ };
748
+
749
+ jasmine.Env.prototype.describe = function(description, specDefinitions) {
750
+ var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
751
+
752
+ var parentSuite = this.currentSuite;
753
+ if (parentSuite) {
754
+ parentSuite.add(suite);
755
+ } else {
756
+ this.currentRunner_.add(suite);
757
+ }
758
+
759
+ this.currentSuite = suite;
760
+
761
+ specDefinitions.call(suite);
762
+
763
+ this.currentSuite = parentSuite;
764
+
765
+ return suite;
766
+ };
767
+
768
+ jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
769
+ if (this.currentSuite) {
770
+ this.currentSuite.beforeEach(beforeEachFunction);
771
+ } else {
772
+ this.currentRunner_.beforeEach(beforeEachFunction);
773
+ }
774
+ };
775
+
776
+ jasmine.Env.prototype.currentRunner = function () {
777
+ return this.currentRunner_;
778
+ };
779
+
780
+ jasmine.Env.prototype.afterEach = function(afterEachFunction) {
781
+ if (this.currentSuite) {
782
+ this.currentSuite.afterEach(afterEachFunction);
783
+ } else {
784
+ this.currentRunner_.afterEach(afterEachFunction);
785
+ }
786
+
787
+ };
788
+
789
+ jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
790
+ return {
791
+ execute: function() {
792
+ }
793
+ };
794
+ };
795
+
796
+ jasmine.Env.prototype.it = function(description, func) {
797
+ var spec = new jasmine.Spec(this, this.currentSuite, description);
798
+ this.currentSuite.add(spec);
799
+ this.currentSpec = spec;
800
+ spec.pending = false;
801
+
802
+ if (func) {
803
+ spec.runs(func);
804
+ } else {
805
+ spec.pending = true;
806
+ }
807
+
808
+ return spec;
809
+ };
810
+
811
+ jasmine.Env.prototype.xit = function(description, func) {
812
+ var spec = this.it(description, func);
813
+ spec.pending = -1;
814
+ return spec;
815
+ };
816
+
817
+ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
818
+ if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
819
+ return true;
820
+ }
821
+
822
+ a.__Jasmine_been_here_before__ = b;
823
+ b.__Jasmine_been_here_before__ = a;
824
+
825
+ var hasKey = function(obj, keyName) {
826
+ return obj != null && obj[keyName] !== jasmine.undefined;
827
+ };
828
+
829
+ for (var property in b) {
830
+ if (!hasKey(a, property) && hasKey(b, property)) {
831
+ mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
832
+ }
833
+ }
834
+ for (property in a) {
835
+ if (!hasKey(b, property) && hasKey(a, property)) {
836
+ mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
837
+ }
838
+ }
839
+ for (property in b) {
840
+ if (property == '__Jasmine_been_here_before__') continue;
841
+ if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) {
842
+ mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual.");
843
+ }
844
+ }
845
+
846
+ if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) {
847
+ mismatchValues.push("arrays were not the same length");
848
+ }
849
+
850
+ delete a.__Jasmine_been_here_before__;
851
+ delete b.__Jasmine_been_here_before__;
852
+ return (mismatchKeys.length == 0 && mismatchValues.length == 0);
853
+ };
854
+
855
+ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
856
+ mismatchKeys = mismatchKeys || [];
857
+ mismatchValues = mismatchValues || [];
858
+
859
+ if (a === b) return true;
860
+
861
+ if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
862
+ return (a == jasmine.undefined && b == jasmine.undefined);
863
+ }
864
+
865
+ if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
866
+ return a === b;
867
+ }
868
+
869
+ if (a instanceof Date && b instanceof Date) {
870
+ return a.getTime() == b.getTime();
871
+ }
872
+
873
+ if (a instanceof jasmine.Matchers.Any) {
874
+ return a.matches(b);
875
+ }
876
+
877
+ if (b instanceof jasmine.Matchers.Any) {
878
+ return b.matches(a);
879
+ }
880
+
881
+ if (typeof a === "object" && typeof b === "object") {
882
+ return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
883
+ }
884
+
885
+ for (var i = 0; i < this.equalityTesters_.length; i++) {
886
+ var equalityTester = this.equalityTesters_[i];
887
+ var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
888
+ if (result !== jasmine.undefined) return result;
889
+ }
890
+
891
+ //Straight check
892
+ return (a === b);
893
+ };
894
+
895
+ jasmine.Env.prototype.contains_ = function(haystack, needle) {
896
+ if (jasmine.isArray_(haystack)) {
897
+ for (var i = 0; i < haystack.length; i++) {
898
+ if (this.equals_(haystack[i], needle)) return true;
899
+ }
900
+ return false;
901
+ }
902
+ return haystack.indexOf(needle) >= 0;
903
+ };
904
+
905
+ jasmine.Env.prototype.addEqualityTester = function(equalityTester) {
906
+ this.equalityTesters_.push(equalityTester);
907
+ };
908
+ /** No-op base class for Jasmine reporters.
909
+ *
910
+ * @constructor
911
+ */
912
+ jasmine.Reporter = function() {
913
+ };
914
+
915
+ //noinspection JSUnusedLocalSymbols
916
+ jasmine.Reporter.prototype.reportRunnerStarting = function(runner) {
917
+ };
918
+
919
+ //noinspection JSUnusedLocalSymbols
920
+ jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
921
+ };
922
+
923
+ //noinspection JSUnusedLocalSymbols
924
+ jasmine.Reporter.prototype.reportSuiteResults = function(suite) {
925
+ };
926
+
927
+ //noinspection JSUnusedLocalSymbols
928
+ jasmine.Reporter.prototype.reportSpecResults = function(spec) {
929
+ };
930
+
931
+ //noinspection JSUnusedLocalSymbols
932
+ jasmine.Reporter.prototype.log = function(str) {
933
+ };
934
+
935
+ /**
936
+ * Blocks are functions with executable code that make up a spec.
937
+ *
938
+ * @constructor
939
+ * @param {jasmine.Env} env
940
+ * @param {Function} func
941
+ * @param {jasmine.Spec} spec
942
+ */
943
+ jasmine.Block = function(env, func, spec) {
944
+ this.env = env;
945
+ this.func = func;
946
+ this.spec = spec;
947
+ };
948
+
949
+ jasmine.Block.prototype.execute = function(onComplete) {
950
+ try {
951
+ if(!this.spec.pending ||
952
+ (this.is_after && this.spec.is_before_ran)){
953
+ if(this.is_before){
954
+ this.spec.is_before_ran = true;
955
+ }
956
+ this.func.apply(this.spec);
957
+ }
958
+ } catch (e) {
959
+ if(e instanceof jasmine.pending_){
960
+ this.spec.pending = true;
961
+ } else if (e instanceof jasmine.eventually_){
962
+ throw e;
963
+ } else {
964
+ this.spec && this.spec.fail(e);
965
+ }
966
+ }
967
+ onComplete();
968
+ };
969
+ /** JavaScript API reporter.
970
+ *
971
+ * @constructor
972
+ */
973
+ jasmine.JsApiReporter = function() {
974
+ this.started = false;
975
+ this.finished = false;
976
+ this.suites_ = [];
977
+ this.results_ = {};
978
+ };
979
+
980
+ jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
981
+ this.started = true;
982
+ var suites = runner.suites();
983
+ for (var i = 0; i < suites.length; i++) {
984
+ var suite = suites[i];
985
+ this.suites_.push(this.summarize_(suite));
986
+ }
987
+ };
988
+
989
+ jasmine.JsApiReporter.prototype.suites = function() {
990
+ return this.suites_;
991
+ };
992
+
993
+ jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
994
+ var isSuite = suiteOrSpec instanceof jasmine.Suite;
995
+ var summary = {
996
+ id: suiteOrSpec.id,
997
+ name: suiteOrSpec.description,
998
+ type: isSuite ? 'suite' : 'spec',
999
+ children: []
1000
+ };
1001
+ if (isSuite) {
1002
+ var specs = suiteOrSpec.specs();
1003
+ for (var i = 0; i < specs.length; i++) {
1004
+ summary.children.push(this.summarize_(specs[i]));
1005
+ }
1006
+ }
1007
+ return summary;
1008
+ };
1009
+
1010
+ jasmine.JsApiReporter.prototype.results = function() {
1011
+ return this.results_;
1012
+ };
1013
+
1014
+ jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) {
1015
+ return this.results_[specId];
1016
+ };
1017
+
1018
+ //noinspection JSUnusedLocalSymbols
1019
+ jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) {
1020
+ this.finished = true;
1021
+ };
1022
+
1023
+ //noinspection JSUnusedLocalSymbols
1024
+ jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) {
1025
+ };
1026
+
1027
+ //noinspection JSUnusedLocalSymbols
1028
+ jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
1029
+ this.results_[spec.id] = {
1030
+ messages: spec.results().getItems(),
1031
+ result: spec.results().failedCount > 0 ? "failed" : "passed"
1032
+ };
1033
+ };
1034
+
1035
+ //noinspection JSUnusedLocalSymbols
1036
+ jasmine.JsApiReporter.prototype.log = function(str) {
1037
+ };
1038
+
1039
+ jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
1040
+ var results = {};
1041
+ for (var i = 0; i < specIds.length; i++) {
1042
+ var specId = specIds[i];
1043
+ results[specId] = this.summarizeResult_(this.results_[specId]);
1044
+ }
1045
+ return results;
1046
+ };
1047
+
1048
+ jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
1049
+ var summaryMessages = [];
1050
+ var messagesLength = result.messages.length
1051
+ for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
1052
+ var resultMessage = result.messages[messageIndex];
1053
+ summaryMessages.push({
1054
+ text: resultMessage.text,
1055
+ passed: resultMessage.passed ? resultMessage.passed() : true,
1056
+ type: resultMessage.type,
1057
+ message: resultMessage.message,
1058
+ trace: {
1059
+ stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined
1060
+ }
1061
+ });
1062
+ };
1063
+
1064
+ var summaryResult = {
1065
+ result : result.result,
1066
+ messages : summaryMessages
1067
+ };
1068
+
1069
+ return summaryResult;
1070
+ };
1071
+
1072
+ /**
1073
+ * @constructor
1074
+ * @param {jasmine.Env} env
1075
+ * @param actual
1076
+ * @param {jasmine.Spec} spec
1077
+ */
1078
+ jasmine.Matchers = function(env, actual, spec) {
1079
+ this.env = env;
1080
+ this.actual = actual;
1081
+ this.spec = spec;
1082
+ };
1083
+
1084
+ jasmine.Matchers.pp = function(str) {
1085
+ return jasmine.util.htmlEscape(jasmine.pp(str));
1086
+ };
1087
+
1088
+ jasmine.Matchers.prototype.report = function(result, failing_message, details) {
1089
+ var expectationResult = new jasmine.ExpectationResult({
1090
+ passed: result,
1091
+ message: failing_message,
1092
+ details: details
1093
+ });
1094
+ this.spec.addMatcherResult(expectationResult);
1095
+ return result;
1096
+ };
1097
+
1098
+ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
1099
+ return function() {
1100
+ var matcherArgs = jasmine.util.argsToArray(arguments);
1101
+ var result = matcherFunction.apply(this, arguments);
1102
+ var message;
1103
+ // debug("m",matcherFunction+"",this.spec.is_eventual);
1104
+ if (!result && this.spec.is_eventual){
1105
+ // debug('retry');
1106
+ throw new jasmine.eventually_;
1107
+ }
1108
+ if (!result) {
1109
+ if (this.message) {
1110
+ message = this.message.apply(this, arguments);
1111
+ } else {
1112
+ var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
1113
+ message = "Expected " + jasmine.pp(this.actual) + " " + englishyPredicate;
1114
+ if (matcherArgs.length > 0) {
1115
+ for (var i = 0; i < matcherArgs.length; i++) {
1116
+ if (i > 0) message += ",";
1117
+ message += " " + jasmine.pp(matcherArgs[i]);
1118
+ }
1119
+ }
1120
+ message += ".";
1121
+ }
1122
+ }
1123
+ var expectationResult = new jasmine.ExpectationResult({
1124
+ matcherName: matcherName,
1125
+ passed: result,
1126
+ expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0],
1127
+ actual: this.actual,
1128
+ message: message
1129
+ });
1130
+ this.spec.addMatcherResult(expectationResult);
1131
+ return result;
1132
+ };
1133
+ };
1134
+
1135
+
1136
+
1137
+
1138
+ /**
1139
+ * toComplete: synthetic matcher for async test timeouts
1140
+ */
1141
+
1142
+ jasmine.Matchers.prototype.toComplete = function() {
1143
+ return false;
1144
+ };
1145
+
1146
+ /**
1147
+ * toBe: compares the actual to the expected using ===
1148
+ * @param expected
1149
+ */
1150
+
1151
+ jasmine.Matchers.prototype.toBe = function(expected) {
1152
+ return this.actual === expected;
1153
+ };
1154
+
1155
+ /**
1156
+ * toNotBe: compares the actual to the expected using !==
1157
+ * @param expected
1158
+ */
1159
+ jasmine.Matchers.prototype.toNotBe = function(expected) {
1160
+ return this.actual !== expected;
1161
+ };
1162
+
1163
+ /**
1164
+ * toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.
1165
+ *
1166
+ * @param expected
1167
+ */
1168
+
1169
+ jasmine.Matchers.prototype.toEqual = function(expected) {
1170
+ return this.env.equals_(this.actual, expected);
1171
+ };
1172
+
1173
+ /**
1174
+ * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
1175
+ * @param expected
1176
+ */
1177
+ jasmine.Matchers.prototype.toNotEqual = function(expected) {
1178
+ return !this.env.equals_(this.actual, expected);
1179
+ };
1180
+
1181
+ /**
1182
+ * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes
1183
+ * a pattern or a String.
1184
+ *
1185
+ * @param reg_exp
1186
+ */
1187
+ jasmine.Matchers.prototype.toMatch = function(expected) {
1188
+ return new RegExp(expected).test(this.actual);
1189
+ };
1190
+
1191
+ /**
1192
+ * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
1193
+ * @param reg_exp
1194
+ */
1195
+ jasmine.Matchers.prototype.toNotMatch = function(expected) {
1196
+ return !(new RegExp(expected).test(this.actual));
1197
+ };
1198
+
1199
+ /**
1200
+ * Matcher that compares the actual to jasmine.undefined.
1201
+ */
1202
+ jasmine.Matchers.prototype.toBeDefined = function() {
1203
+ return (this.actual !== jasmine.undefined);
1204
+ };
1205
+
1206
+ /**
1207
+ * Matcher that compares the actual to jasmine.undefined.
1208
+ */
1209
+ jasmine.Matchers.prototype.toBeUndefined = function() {
1210
+ return (this.actual === jasmine.undefined);
1211
+ };
1212
+
1213
+ /**
1214
+ * Matcher that compares the actual to null.
1215
+ */
1216
+ jasmine.Matchers.prototype.toBeNull = function() {
1217
+ return (this.actual === null);
1218
+ };
1219
+
1220
+ /**
1221
+ * Matcher that boolean not-nots the actual.
1222
+ */
1223
+ jasmine.Matchers.prototype.toBeTruthy = function() {
1224
+ return !!this.actual;
1225
+ };
1226
+
1227
+
1228
+ /**
1229
+ * Matcher that boolean nots the actual.
1230
+ */
1231
+ jasmine.Matchers.prototype.toBeFalsy = function() {
1232
+ return !this.actual;
1233
+ };
1234
+
1235
+ /**
1236
+ * Matcher that checks to see if the actual, a Jasmine spy, was called.
1237
+ */
1238
+ jasmine.Matchers.prototype.wasCalled = function() {
1239
+ if (arguments.length > 0) {
1240
+ throw new Error('wasCalled does not take arguments, use wasCalledWith');
1241
+ }
1242
+
1243
+ if (!jasmine.isSpy(this.actual)) {
1244
+ throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
1245
+ }
1246
+
1247
+ this.message = function() {
1248
+ return "Expected spy " + this.actual.identity + " to have been called.";
1249
+ };
1250
+
1251
+ return this.actual.wasCalled;
1252
+ };
1253
+
1254
+ /**
1255
+ * Matcher that checks to see if the actual, a Jasmine spy, was not called.
1256
+ */
1257
+ jasmine.Matchers.prototype.wasNotCalled = function() {
1258
+ if (arguments.length > 0) {
1259
+ throw new Error('wasNotCalled does not take arguments');
1260
+ }
1261
+
1262
+ if (!jasmine.isSpy(this.actual)) {
1263
+ throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
1264
+ }
1265
+
1266
+ this.message = function() {
1267
+ return "Expected spy " + this.actual.identity + " to not have been called.";
1268
+ };
1269
+
1270
+ return !this.actual.wasCalled;
1271
+ };
1272
+
1273
+ /**
1274
+ * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.
1275
+ *
1276
+ * @example
1277
+ *
1278
+ */
1279
+ jasmine.Matchers.prototype.wasCalledWith = function() {
1280
+ if (!jasmine.isSpy(this.actual)) {
1281
+ throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
1282
+ }
1283
+
1284
+ this.message = function() {
1285
+ if (this.actual.callCount == 0) {
1286
+ return "Expected spy to have been called with " + jasmine.pp(arguments) + " but it was never called.";
1287
+ } else {
1288
+ return "Expected spy to have been called with " + jasmine.pp(arguments) + " but was called with " + jasmine.pp(this.actual.argsForCall);
1289
+ }
1290
+ };
1291
+
1292
+ return this.env.contains_(this.actual.argsForCall, jasmine.util.argsToArray(arguments));
1293
+ };
1294
+
1295
+ jasmine.Matchers.prototype.wasNotCalledWith = function() {
1296
+ if (!jasmine.isSpy(this.actual)) {
1297
+ throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
1298
+ }
1299
+
1300
+ this.message = function() {
1301
+ return "Expected spy not to have been called with " + jasmine.pp(arguments) + " but it was";
1302
+ };
1303
+
1304
+ return !this.env.contains_(this.actual.argsForCall, jasmine.util.argsToArray(arguments));
1305
+ };
1306
+
1307
+ /**
1308
+ * Matcher that checks that the expected item is an element in the actual Array.
1309
+ *
1310
+ * @param {Object} item
1311
+ */
1312
+ jasmine.Matchers.prototype.toContain = function(expected) {
1313
+ return this.env.contains_(this.actual, expected);
1314
+ };
1315
+
1316
+ /**
1317
+ * Matcher that checks that the expected item is NOT an element in the actual Array.
1318
+ *
1319
+ * @param {Object} item
1320
+ */
1321
+ jasmine.Matchers.prototype.toNotContain = function(expected) {
1322
+ return !this.env.contains_(this.actual, expected);
1323
+ };
1324
+
1325
+ jasmine.Matchers.prototype.toBeLessThan = function(expected) {
1326
+ return this.actual < expected;
1327
+ };
1328
+
1329
+ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
1330
+ return this.actual > expected;
1331
+ };
1332
+
1333
+ /**
1334
+ * Matcher that checks that the expected exception was thrown by the actual.
1335
+ *
1336
+ * @param {String} expectedException
1337
+ */
1338
+ jasmine.Matchers.prototype.toThrow = function(expected) {
1339
+ function getException_(actual, expected) {
1340
+ var exception;
1341
+ if (typeof actual != 'function') {
1342
+ throw new Error('Actual is not a function');
1343
+ }
1344
+ try {
1345
+ actual();
1346
+ } catch (e) {
1347
+ exception = e;
1348
+ }
1349
+ return exception;
1350
+ }
1351
+
1352
+ var result = false;
1353
+ var exception = getException_(this.actual, expected);
1354
+ if (exception) {
1355
+ result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
1356
+ }
1357
+
1358
+ this.message = function(expected) {
1359
+ var exception = getException_(this.actual, expected);
1360
+ if (exception && expected !== jasmine.undefined && (!this.env.equals_(exception.message || exception, expected.message || expected))) {
1361
+ return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception ].join(' ');
1362
+ } else {
1363
+ return "Expected function to throw an exception.";
1364
+ }
1365
+ };
1366
+
1367
+ return result;
1368
+ };
1369
+
1370
+ jasmine.Matchers.Any = function(expectedClass) {
1371
+ this.expectedClass = expectedClass;
1372
+ };
1373
+
1374
+ jasmine.Matchers.Any.prototype.matches = function(other) {
1375
+ if (this.expectedClass == String) {
1376
+ return typeof other == 'string' || other instanceof String;
1377
+ }
1378
+
1379
+ if (this.expectedClass == Number) {
1380
+ return typeof other == 'number' || other instanceof Number;
1381
+ }
1382
+
1383
+ if (this.expectedClass == Function) {
1384
+ return typeof other == 'function' || other instanceof Function;
1385
+ }
1386
+
1387
+ if (this.expectedClass == Object) {
1388
+ return typeof other == 'object';
1389
+ }
1390
+
1391
+ return other instanceof this.expectedClass;
1392
+ };
1393
+
1394
+ jasmine.Matchers.Any.prototype.toString = function() {
1395
+ return '<jasmine.any(' + this.expectedClass + ')>';
1396
+ };
1397
+
1398
+ /**
1399
+ * @constructor
1400
+ */
1401
+ jasmine.MultiReporter = function() {
1402
+ this.subReporters_ = [];
1403
+ };
1404
+ jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter);
1405
+
1406
+ jasmine.MultiReporter.prototype.addReporter = function(reporter) {
1407
+ this.subReporters_.push(reporter);
1408
+ };
1409
+
1410
+ (function() {
1411
+ var functionNames = ["reportRunnerStarting", "reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"];
1412
+ for (var i = 0; i < functionNames.length; i++) {
1413
+ var functionName = functionNames[i];
1414
+ jasmine.MultiReporter.prototype[functionName] = (function(functionName) {
1415
+ return function() {
1416
+ for (var j = 0; j < this.subReporters_.length; j++) {
1417
+ var subReporter = this.subReporters_[j];
1418
+ if (subReporter[functionName]) {
1419
+ subReporter[functionName].apply(subReporter, arguments);
1420
+ }
1421
+ }
1422
+ };
1423
+ })(functionName);
1424
+ }
1425
+ })();
1426
+ /**
1427
+ * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults
1428
+ *
1429
+ * @constructor
1430
+ */
1431
+ jasmine.NestedResults = function() {
1432
+ /**
1433
+ * The total count of results
1434
+ */
1435
+ this.totalCount = 0;
1436
+ /**
1437
+ * Number of passed results
1438
+ */
1439
+ this.passedCount = 0;
1440
+ /**
1441
+ * Number of failed results
1442
+ */
1443
+ this.failedCount = 0;
1444
+ /**
1445
+ * Was this suite/spec skipped?
1446
+ */
1447
+ this.skipped = false;
1448
+ /**
1449
+ * @ignore
1450
+ */
1451
+ this.items_ = [];
1452
+ };
1453
+
1454
+ /**
1455
+ * Roll up the result counts.
1456
+ *
1457
+ * @param result
1458
+ */
1459
+ jasmine.NestedResults.prototype.rollupCounts = function(result) {
1460
+ this.totalCount += result.totalCount;
1461
+ this.passedCount += result.passedCount;
1462
+ this.failedCount += result.failedCount;
1463
+ };
1464
+
1465
+ /**
1466
+ * Tracks a result's message.
1467
+ * @param message
1468
+ */
1469
+ jasmine.NestedResults.prototype.log = function(message) {
1470
+ this.items_.push(new jasmine.MessageResult(message));
1471
+ };
1472
+
1473
+ /**
1474
+ * Getter for the results: message & results.
1475
+ */
1476
+ jasmine.NestedResults.prototype.getItems = function() {
1477
+ return this.items_;
1478
+ };
1479
+
1480
+ /**
1481
+ * Adds a result, tracking counts (total, passed, & failed)
1482
+ * @param {jasmine.ExpectationResult|jasmine.NestedResults} result
1483
+ */
1484
+ jasmine.NestedResults.prototype.addResult = function(result) {
1485
+ if (result.type != 'MessageResult') {
1486
+ if (result.items_) {
1487
+ this.rollupCounts(result);
1488
+ } else {
1489
+ this.totalCount++;
1490
+ if (result.passed()) {
1491
+ this.passedCount++;
1492
+ } else {
1493
+ this.failedCount++;
1494
+ }
1495
+ }
1496
+ }
1497
+ this.items_.push(result);
1498
+ };
1499
+
1500
+ /**
1501
+ * @returns {Boolean} True if <b>everything</b> below passed
1502
+ */
1503
+ jasmine.NestedResults.prototype.passed = function() {
1504
+ return this.passedCount === this.totalCount;
1505
+ };
1506
+
1507
+ jasmine.NestedResults.prototype.block_start = function() {
1508
+ this.block_totalCount = this.totalCount;
1509
+ this.block_passedCount = this.passedCount;
1510
+ this.block_failedCount = this.failedCount;
1511
+ this.block_skipped = this.skipped;
1512
+ this.items_length = this.items_.length;
1513
+ };
1514
+
1515
+ jasmine.NestedResults.prototype.block_finish = function() {
1516
+ };
1517
+
1518
+ jasmine.NestedResults.prototype.block_abort = function() {
1519
+ this.totalCount = this.block_totalCount;
1520
+ this.passedCount = this.block_passedCount;
1521
+ this.failedCount = this.block_failedCount;
1522
+ this.skipped = this.block_skipped;
1523
+ this.items_ = this.items_.slice(0,this.items_length);
1524
+ }
1525
+ /**
1526
+ * Base class for pretty printing for expectation results.
1527
+ */
1528
+ jasmine.PrettyPrinter = function() {
1529
+ this.ppNestLevel_ = 0;
1530
+ };
1531
+
1532
+ /**
1533
+ * Formats a value in a nice, human-readable string.
1534
+ *
1535
+ * @param value
1536
+ */
1537
+ jasmine.PrettyPrinter.prototype.format = function(value) {
1538
+ if (this.ppNestLevel_ > 40) {
1539
+ throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
1540
+ }
1541
+
1542
+ this.ppNestLevel_++;
1543
+ try {
1544
+ if (value === jasmine.undefined) {
1545
+ this.emitScalar('undefined');
1546
+ } else if (value === null) {
1547
+ this.emitScalar('null');
1548
+ } else if (value.navigator /* && value.frames */ && value.setTimeout) {
1549
+ this.emitScalar('<window>');
1550
+ } else if (value instanceof jasmine.Matchers.Any) {
1551
+ this.emitScalar(value.toString());
1552
+ } else if (typeof value === 'string') {
1553
+ this.emitString(value);
1554
+ } else if (jasmine.isSpy(value)) {
1555
+ this.emitScalar("spy on " + value.identity);
1556
+ } else if (value instanceof RegExp) {
1557
+ this.emitScalar(value.toString());
1558
+ } else if (typeof value === 'function') {
1559
+ this.emitScalar('Function');
1560
+ } else if (typeof value.nodeType === 'number') {
1561
+ this.emitScalar('HTMLNode');
1562
+ } else if (value instanceof Date) {
1563
+ this.emitScalar('Date(' + value + ')');
1564
+ } else if (value.__Jasmine_been_here_before__) {
1565
+ this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>');
1566
+ } else if (jasmine.isArray_(value) || typeof value == 'object') {
1567
+ value.__Jasmine_been_here_before__ = true;
1568
+ if (jasmine.isArray_(value)) {
1569
+ this.emitArray(value);
1570
+ } else {
1571
+ this.emitObject(value);
1572
+ }
1573
+ delete value.__Jasmine_been_here_before__;
1574
+ } else {
1575
+ this.emitScalar(value.toString());
1576
+ }
1577
+ } finally {
1578
+ this.ppNestLevel_--;
1579
+ }
1580
+ };
1581
+
1582
+ jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
1583
+ for (var property in obj) {
1584
+ if (property == '__Jasmine_been_here_before__') continue;
1585
+ fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false);
1586
+ }
1587
+ };
1588
+
1589
+ jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_;
1590
+ jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_;
1591
+ jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_;
1592
+ jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_;
1593
+
1594
+ jasmine.StringPrettyPrinter = function() {
1595
+ jasmine.PrettyPrinter.call(this);
1596
+
1597
+ this.string = '';
1598
+ };
1599
+ jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter);
1600
+
1601
+ jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) {
1602
+ this.append(value);
1603
+ };
1604
+
1605
+ jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
1606
+ this.append("'" + value + "'");
1607
+ };
1608
+
1609
+ jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
1610
+ this.append('[ ');
1611
+ for (var i = 0; i < array.length; i++) {
1612
+ if (i > 0) {
1613
+ this.append(', ');
1614
+ }
1615
+ this.format(array[i]);
1616
+ }
1617
+ this.append(' ]');
1618
+ };
1619
+
1620
+ jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
1621
+ var self = this;
1622
+ this.append('{ ');
1623
+ var first = true;
1624
+
1625
+ this.iterateObject(obj, function(property, isGetter) {
1626
+ if (first) {
1627
+ first = false;
1628
+ } else {
1629
+ self.append(', ');
1630
+ }
1631
+
1632
+ self.append(property);
1633
+ self.append(' : ');
1634
+ if (isGetter) {
1635
+ self.append('<getter>');
1636
+ } else {
1637
+ self.format(obj[property]);
1638
+ }
1639
+ });
1640
+
1641
+ this.append(' }');
1642
+ };
1643
+
1644
+ jasmine.StringPrettyPrinter.prototype.append = function(value) {
1645
+ this.string += value;
1646
+ };
1647
+ jasmine.Queue = function(env) {
1648
+ this.env = env;
1649
+ this.blocks = [];
1650
+ this.running = false;
1651
+ this.index = 0;
1652
+ this.offset = 0;
1653
+ this._stopped = 0;
1654
+ };
1655
+
1656
+ jasmine.Queue.prototype.addBefore = function(block) {
1657
+ this.blocks.unshift(block);
1658
+ };
1659
+
1660
+ jasmine.Queue.prototype.add = function(block) {
1661
+ this.blocks.push(block);
1662
+ };
1663
+
1664
+ jasmine.Queue.prototype.insertNext = function(block) {
1665
+ this.blocks.splice((this.index + this.offset + 1), 0, block);
1666
+ this.offset++;
1667
+ };
1668
+
1669
+ jasmine.Queue.prototype.start = function(onComplete) {
1670
+ this.running = true;
1671
+ this.onComplete = onComplete;
1672
+ // debug("next_ !!!");
1673
+ this.next_();
1674
+ };
1675
+
1676
+ jasmine.Queue.prototype._start = function() {
1677
+ var debug = window.console && window.console.debug || window.debug;
1678
+ var self = this;
1679
+ this._stopped--;
1680
+ // debug("start " + this._stopped);
1681
+ if(this._stopped == 0 && !this._signaled){
1682
+ this._signaled = true;
1683
+ // debug("next_ !!");
1684
+ setTimeout(function(){
1685
+ self._signaled = false;
1686
+ self.next_();
1687
+ },0);
1688
+ }
1689
+ if(this._timeout){
1690
+ clearTimeout(this._timeout);
1691
+ this._timeout = jasmine.undefined;
1692
+ }
1693
+ };
1694
+
1695
+ jasmine.Queue.prototype._stop = function(delay) {
1696
+ var debug = window.console && window.console.debug || window.debug;
1697
+ this._stopped++;
1698
+ // debug("stop " + this._stopped);
1699
+ if(this._stopped>0){
1700
+ var self = this;
1701
+ delay = delay || 4000;
1702
+ if(this._timeout){
1703
+ clearTimeout(this._timeout);
1704
+ };
1705
+ this._timeout = setTimeout(function test_timeout(){
1706
+ // debug("failed");
1707
+ self.blocks[0].spec.runs(function(){
1708
+ self.blocks[0].spec.expect("test").toComplete();
1709
+ });
1710
+ self._start();
1711
+ },delay);
1712
+ }
1713
+ };
1714
+
1715
+ jasmine.Queue.prototype._wait_for = function(condition, fn) {
1716
+ var debug = window.console && window.console.debug || window.debug;
1717
+ var self = this;
1718
+ // debug(self.index,self.blocks[self.index],self.blocks[self.index].is_after);
1719
+ self.blocks[0].spec.runs(function(){
1720
+ // debug("queue " , self.blocks[0].spec.description,condition+"");
1721
+ var timeout = function timeout() {
1722
+ if(self._timeout) {
1723
+ // debug("check " , self.blocks[0].spec.description,condition+"");
1724
+ if(condition()){
1725
+ // debug("okay " + self.blocks[0].spec.description);
1726
+ fn && fn();
1727
+ self._start();
1728
+ } else {
1729
+ // debug("retry");
1730
+ setTimeout(timeout,50);
1731
+ }
1732
+ } else {
1733
+ // debug("not going " + condition);
1734
+ // debug("not going " + fn);
1735
+ // debug("not going " + self.blocks[0].spec.description);
1736
+ }
1737
+ };
1738
+ setTimeout(timeout,0);
1739
+ // debug("?",self._stopped,condition+"");
1740
+ self._stop();
1741
+ });
1742
+ self.blocks[self.index+1].is_after = self.blocks[self.index].is_after;
1743
+ };
1744
+
1745
+ jasmine.Queue.prototype.isRunning = function() {
1746
+ return this.running;
1747
+ };
1748
+
1749
+ jasmine.Queue.LOOP_DONT_RECURSE = true;
1750
+
1751
+ jasmine.Queue.prototype.next_ = function() {
1752
+ var debug = window.console && window.console.debug || window.debug;
1753
+ // debug("next");
1754
+ var self = this;
1755
+ var goAgain = true;
1756
+
1757
+ // debug("stopped",this._stopped,self.index,self.blocks.length);
1758
+ while (goAgain && this._stopped <= 0) {
1759
+ goAgain = false;
1760
+
1761
+ if (self.index < self.blocks.length) {
1762
+ var calledSynchronously = true;
1763
+ var completedSynchronously = false;
1764
+
1765
+ var onComplete = function () {
1766
+ if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {
1767
+ completedSynchronously = true;
1768
+ return;
1769
+ }
1770
+
1771
+ /*
1772
+ if( self.blocks[self.index]._anticipate !== jasmine.undefined ) {
1773
+ }
1774
+ */
1775
+
1776
+ self.offset = 0;
1777
+ self.index++;
1778
+
1779
+ var now = new Date().getTime();
1780
+ if(!self._signaled){
1781
+ if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {
1782
+ self.env.lastUpdate = now;
1783
+ // debug("next_ 00");
1784
+ this._signaled = true;
1785
+ self.env.setTimeout(function() {
1786
+ this._signaled = false;
1787
+ self.next_();
1788
+ }, 0);
1789
+ } else {
1790
+ if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {
1791
+ // debug("go again");
1792
+ goAgain = true;
1793
+ } else {
1794
+ // debug("next_ 01");
1795
+ self.next_();
1796
+ }
1797
+ }
1798
+ }
1799
+ };
1800
+
1801
+ var block = self.blocks[self.index];
1802
+ var spec = block.spec;
1803
+ var before = new Date().getTime();
1804
+ var delay = 5000;
1805
+ var runner = function runner() {
1806
+ var saved = spec && spec.is_eventual;
1807
+ try {
1808
+ var now = new Date().getTime();
1809
+ if(spec) {
1810
+ if(now - before < delay){
1811
+ spec.is_eventual = block.is_eventual;
1812
+ spec.block_start();
1813
+ }
1814
+ }
1815
+ block.execute(onComplete);
1816
+ spec && spec.is_eventual&& spec.block_finish();
1817
+ } catch(e) {
1818
+ if(block.is_eventual){
1819
+ spec && spec.block_abort();
1820
+ setTimeout(function(){
1821
+ runner();
1822
+ },50);
1823
+ } else {
1824
+ throw e;
1825
+ }
1826
+ } finally {
1827
+ spec && (spec.is_eventual = saved);
1828
+ }
1829
+ };
1830
+ runner();
1831
+
1832
+ calledSynchronously = false;
1833
+ if (completedSynchronously) {
1834
+ onComplete();
1835
+ }
1836
+
1837
+ } else {
1838
+ self.running = false;
1839
+ if (self.onComplete) {
1840
+ self.onComplete();
1841
+ }
1842
+ }
1843
+ }
1844
+ };
1845
+
1846
+ jasmine.Queue.prototype.results = function() {
1847
+ var results = new jasmine.NestedResults();
1848
+ for (var i = 0; i < this.blocks.length; i++) {
1849
+ if (this.blocks[i].results) {
1850
+ results.addResult(this.blocks[i].results());
1851
+ }
1852
+ }
1853
+ return results;
1854
+ };
1855
+
1856
+
1857
+ /** JasmineReporters.reporter
1858
+ * Base object that will get called whenever a Spec, Suite, or Runner is done. It is up to
1859
+ * descendants of this object to do something with the results (see json_reporter.js)
1860
+ *
1861
+ * @deprecated
1862
+ */
1863
+ jasmine.Reporters = {};
1864
+
1865
+ /**
1866
+ * @deprecated
1867
+ * @param callbacks
1868
+ */
1869
+ jasmine.Reporters.reporter = function(callbacks) {
1870
+ /**
1871
+ * @deprecated
1872
+ * @param callbacks
1873
+ */
1874
+ var that = {
1875
+ callbacks: callbacks || {},
1876
+
1877
+ doCallback: function(callback, results) {
1878
+ if (callback) {
1879
+ callback(results);
1880
+ }
1881
+ },
1882
+
1883
+ reportRunnerResults: function(runner) {
1884
+ that.doCallback(that.callbacks.runnerCallback, runner);
1885
+ },
1886
+ reportSuiteResults: function(suite) {
1887
+ that.doCallback(that.callbacks.suiteCallback, suite);
1888
+ },
1889
+ reportSpecResults: function(spec) {
1890
+ that.doCallback(that.callbacks.specCallback, spec);
1891
+ },
1892
+ log: function (str) {
1893
+ if (this.console && this.console.log) this.console.log(str);
1894
+ }
1895
+ };
1896
+
1897
+ return that;
1898
+ };
1899
+
1900
+ /**
1901
+ * Runner
1902
+ *
1903
+ * @constructor
1904
+ * @param {jasmine.Env} env
1905
+ */
1906
+ jasmine.Runner = function(env) {
1907
+ var self = this;
1908
+ self.env = env;
1909
+ self.queue = new jasmine.Queue(env);
1910
+ self.before_ = [];
1911
+ self.after_ = [];
1912
+ self.suites_ = [];
1913
+ };
1914
+
1915
+ jasmine.Runner.prototype.execute = function() {
1916
+ var self = this;
1917
+ if (self.env.reporter.reportRunnerStarting) {
1918
+ self.env.reporter.reportRunnerStarting(this);
1919
+ }
1920
+ self.queue.start(function () {
1921
+ self.finishCallback();
1922
+ });
1923
+ };
1924
+
1925
+ jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) {
1926
+ beforeEachFunction.typeName = 'beforeEach';
1927
+ this.before_.push(beforeEachFunction);
1928
+ };
1929
+
1930
+ jasmine.Runner.prototype.afterEach = function(afterEachFunction) {
1931
+ afterEachFunction.typeName = 'afterEach';
1932
+ this.after_.push(afterEachFunction);
1933
+ };
1934
+
1935
+
1936
+ jasmine.Runner.prototype.finishCallback = function() {
1937
+ this.env.reporter.reportRunnerResults(this);
1938
+ };
1939
+
1940
+ jasmine.Runner.prototype.addSuite = function(suite) {
1941
+ this.suites_.push(suite);
1942
+ };
1943
+
1944
+ jasmine.Runner.prototype.add = function(block) {
1945
+ if (block instanceof jasmine.Suite) {
1946
+ this.addSuite(block);
1947
+ }
1948
+ this.queue.add(block);
1949
+ };
1950
+
1951
+ jasmine.Runner.prototype.specs = function () {
1952
+ var suites = this.suites();
1953
+ var specs = [];
1954
+ for (var i = 0; i < suites.length; i++) {
1955
+ specs = specs.concat(suites[i].specs());
1956
+ }
1957
+ return specs;
1958
+ };
1959
+
1960
+
1961
+ jasmine.Runner.prototype.suites = function() {
1962
+ return this.suites_;
1963
+ };
1964
+
1965
+ jasmine.Runner.prototype.results = function() {
1966
+ return this.queue.results();
1967
+ };
1968
+ /**
1969
+ * Internal representation of a Jasmine specification, or test.
1970
+ *
1971
+ * @constructor
1972
+ * @param {jasmine.Env} env
1973
+ * @param {jasmine.Suite} suite
1974
+ * @param {String} description
1975
+ */
1976
+ jasmine.Spec = function(env, suite, description) {
1977
+ if (!env) {
1978
+ throw new Error('jasmine.Env() required');
1979
+ }
1980
+ if (!suite) {
1981
+ throw new Error('jasmine.Suite() required');
1982
+ }
1983
+ var spec = this;
1984
+ spec.id = env.nextSpecId ? env.nextSpecId() : null;
1985
+ spec.env = env;
1986
+ spec.suite = suite;
1987
+ spec.description = description;
1988
+ spec.queue = new jasmine.Queue(env);
1989
+
1990
+ spec.afterCallbacks = [];
1991
+ spec.spies_ = [];
1992
+
1993
+ spec.results_ = new jasmine.NestedResults();
1994
+ spec.results_.description = description;
1995
+ spec.matchersClass = null;
1996
+ };
1997
+
1998
+ jasmine.Spec.prototype.getFullName = function() {
1999
+ return this.suite.getFullName() + ' ' + this.description + '.';
2000
+ };
2001
+
2002
+
2003
+ jasmine.Spec.prototype.results = function() {
2004
+ return this.results_;
2005
+ };
2006
+
2007
+ jasmine.Spec.prototype.log = function(message) {
2008
+ return this.results_.log(message);
2009
+ };
2010
+
2011
+ /** @deprecated */
2012
+ jasmine.Spec.prototype.getResults = function() {
2013
+ return this.results_;
2014
+ };
2015
+
2016
+ jasmine.Spec.prototype.runs = function (func) {
2017
+ var block = new jasmine.Block(this.env, func, this);
2018
+ this.addToQueue(block);
2019
+ ( this.pending != -1 ) && ( !this.queue.isRunning() ) && ( this.pending = false );
2020
+ return this;
2021
+ };
2022
+
2023
+ jasmine.Spec.prototype.addToQueue = function (block) {
2024
+ if (this.queue.isRunning()) {
2025
+ this.queue.insertNext(block);
2026
+ } else {
2027
+ this.queue.add(block);
2028
+ }
2029
+ };
2030
+
2031
+ jasmine.Spec.prototype.stop = function(delay){
2032
+ this.queue._stop(delay);
2033
+ };
2034
+
2035
+ jasmine.Spec.prototype.start = function(){
2036
+ this.queue._start();
2037
+ };
2038
+
2039
+ jasmine.Spec.prototype.eventually = function(func){
2040
+ // this.queue._eventually(fn);
2041
+ var block = new jasmine.Block(this.env, func, this);
2042
+ block.is_eventual = true;
2043
+ this.addToQueue(block);
2044
+ ( this.pending != -1 ) && ( this.pending = false );
2045
+ return this;
2046
+ };
2047
+
2048
+ jasmine.Spec.prototype.wait_for = function(condition,fn){
2049
+ this.queue._wait_for(condition,fn);
2050
+ };
2051
+
2052
+ jasmine.Spec.prototype.anticipate = function(number){
2053
+ this._anticipate = number;
2054
+ };
2055
+
2056
+ jasmine.Spec.prototype.addMatcherResult = function(result) {
2057
+ this.results_.addResult(result);
2058
+ };
2059
+
2060
+ jasmine.Spec.prototype.expect = function(actual) {
2061
+ return new (this.getMatchersClass_())(this.env, actual, this);
2062
+ };
2063
+
2064
+ jasmine.Spec.prototype.waits = function(timeout) {
2065
+ var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this);
2066
+ this.addToQueue(waitsFunc);
2067
+ return this;
2068
+ };
2069
+
2070
+ jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, timeoutMessage) {
2071
+ var waitsForFunc = new jasmine.WaitsForBlock(this.env, timeout, latchFunction, timeoutMessage, this);
2072
+ this.addToQueue(waitsForFunc);
2073
+ return this;
2074
+ };
2075
+
2076
+ jasmine.Spec.prototype.fail = function (e) {
2077
+ var expectationResult = new jasmine.ExpectationResult({
2078
+ passed: false,
2079
+ message: e ? jasmine.util.formatException(e) : 'Exception',
2080
+ exception: e
2081
+ });
2082
+ this.results_.addResult(expectationResult);
2083
+ };
2084
+
2085
+ jasmine.Spec.prototype.getMatchersClass_ = function() {
2086
+ return this.matchersClass || this.env.matchersClass;
2087
+ };
2088
+
2089
+ jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
2090
+ var parent = this.getMatchersClass_();
2091
+ var newMatchersClass = function() {
2092
+ parent.apply(this, arguments);
2093
+ };
2094
+ jasmine.util.inherit(newMatchersClass, parent);
2095
+ for (var method in matchersPrototype) {
2096
+ newMatchersClass.prototype[method] = matchersPrototype[method];
2097
+ }
2098
+ this.matchersClass = newMatchersClass;
2099
+ };
2100
+
2101
+ jasmine.Spec.prototype.finishCallback = function() {
2102
+ this.env.reporter.reportSpecResults(this);
2103
+ };
2104
+
2105
+ jasmine.Spec.prototype.finish = function(onComplete) {
2106
+ this.removeAllSpies();
2107
+ this.finishCallback();
2108
+ if (onComplete) {
2109
+ onComplete();
2110
+ }
2111
+ };
2112
+
2113
+ jasmine.Spec.prototype.after = function(doAfter, test) {
2114
+
2115
+ if (this.queue.isRunning()) {
2116
+ this.queue.add(new jasmine.Block(this.env, doAfter, this));
2117
+ } else {
2118
+ this.afterCallbacks.unshift(doAfter);
2119
+ }
2120
+ };
2121
+
2122
+ jasmine.Spec.prototype.execute = function(onComplete) {
2123
+ var spec = this;
2124
+ if (!spec.env.specFilter(spec)) {
2125
+ spec.results_.skipped = true;
2126
+ spec.finish(onComplete);
2127
+ return;
2128
+ }
2129
+ this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...');
2130
+
2131
+ spec.env.currentSpec = spec;
2132
+
2133
+ spec.addBeforesAndAftersToQueue();
2134
+
2135
+ spec.queue.start(function () {
2136
+ spec.finish(onComplete);
2137
+ });
2138
+ };
2139
+
2140
+ jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
2141
+ var runner = this.env.currentRunner();
2142
+ var block;
2143
+ for (var suite = this.suite; suite; suite = suite.parentSuite) {
2144
+ for (var i = 0; i < suite.before_.length; i++) {
2145
+ block = new jasmine.Block(this.env, suite.before_[i], this);
2146
+ block.is_before = true;
2147
+ this.queue.addBefore(block);
2148
+ }
2149
+ }
2150
+ for (var i = 0; i < runner.before_.length; i++) {
2151
+ block = new jasmine.Block(this.env, runner.before_[i], this);
2152
+ block.is_before = true;
2153
+ this.queue.addBefore(block);
2154
+ }
2155
+ for (i = 0; i < this.afterCallbacks.length; i++) {
2156
+ block = new jasmine.Block(this.env, this.afterCallbacks[i], this);
2157
+ block.is_after = true;
2158
+ this.queue.add(block);
2159
+ }
2160
+ for (suite = this.suite; suite; suite = suite.parentSuite) {
2161
+ for (var i = 0; i < suite.after_.length; i++) {
2162
+ block = new jasmine.Block(this.env, suite.after_[i], this);
2163
+ block.is_after = true;
2164
+ this.queue.add(block);
2165
+ }
2166
+ }
2167
+ for (var i = 0; i < runner.after_.length; i++) {
2168
+ block = new jasmine.Block(this.env, runner.after_[i], this);
2169
+ block.is_after = true;
2170
+ this.queue.add(block);
2171
+ }
2172
+ };
2173
+
2174
+ jasmine.Spec.prototype.explodes = function() {
2175
+ throw 'explodes function should not have been called';
2176
+ };
2177
+
2178
+ jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) {
2179
+ if (obj == jasmine.undefined) {
2180
+ throw "spyOn could not find an object to spy upon for " + methodName + "()";
2181
+ }
2182
+
2183
+ if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) {
2184
+ throw methodName + '() method does not exist';
2185
+ }
2186
+
2187
+ if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) {
2188
+ throw new Error(methodName + ' has already been spied upon');
2189
+ }
2190
+
2191
+ var spyObj = jasmine.createSpy(methodName);
2192
+
2193
+ this.spies_.push(spyObj);
2194
+ spyObj.baseObj = obj;
2195
+ spyObj.methodName = methodName;
2196
+ spyObj.originalValue = obj[methodName];
2197
+
2198
+ obj[methodName] = spyObj;
2199
+
2200
+ return spyObj;
2201
+ };
2202
+
2203
+ jasmine.Spec.prototype.removeAllSpies = function() {
2204
+ for (var i = 0; i < this.spies_.length; i++) {
2205
+ var spy = this.spies_[i];
2206
+ spy.baseObj[spy.methodName] = spy.originalValue;
2207
+ }
2208
+ this.spies_ = [];
2209
+ };
2210
+
2211
+ jasmine.Spec.prototype.block_start = function() {
2212
+ this.results_.block_start();
2213
+ };
2214
+
2215
+ jasmine.Spec.prototype.block_finish = function() {
2216
+ this.results_.block_finish();
2217
+ };
2218
+
2219
+ jasmine.Spec.prototype.block_abort = function() {
2220
+ this.results_.block_abort();
2221
+ };
2222
+ /**
2223
+ * Internal representation of a Jasmine suite.
2224
+ *
2225
+ * @constructor
2226
+ * @param {jasmine.Env} env
2227
+ * @param {String} description
2228
+ * @param {Function} specDefinitions
2229
+ * @param {jasmine.Suite} parentSuite
2230
+ */
2231
+ jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
2232
+ var self = this;
2233
+ self.id = env.nextSuiteId ? env.nextSuiteId() : null;
2234
+ self.description = description;
2235
+ self.queue = new jasmine.Queue(env);
2236
+ self.parentSuite = parentSuite;
2237
+ self.env = env;
2238
+ self.before_ = [];
2239
+ self.after_ = [];
2240
+ self.specs_ = [];
2241
+ };
2242
+
2243
+ jasmine.Suite.prototype.getFullName = function() {
2244
+ var fullName = this.description;
2245
+ for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
2246
+ fullName = parentSuite.description + ' ' + fullName;
2247
+ }
2248
+ return fullName;
2249
+ };
2250
+
2251
+ jasmine.Suite.prototype.finish = function(onComplete) {
2252
+ this.env.reporter.reportSuiteResults(this);
2253
+ this.finished = true;
2254
+ if (typeof(onComplete) == 'function') {
2255
+ onComplete();
2256
+ }
2257
+ };
2258
+
2259
+ jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {
2260
+ beforeEachFunction.typeName = 'beforeEach';
2261
+ this.before_.push(beforeEachFunction);
2262
+ };
2263
+
2264
+ jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
2265
+ afterEachFunction.typeName = 'afterEach';
2266
+ this.after_.push(afterEachFunction);
2267
+ };
2268
+
2269
+ jasmine.Suite.prototype.results = function() {
2270
+ return this.queue.results();
2271
+ };
2272
+
2273
+ jasmine.Suite.prototype.add = function(block) {
2274
+ if (block instanceof jasmine.Suite) {
2275
+ this.env.currentRunner().addSuite(block);
2276
+ } else {
2277
+ this.specs_.push(block);
2278
+ }
2279
+ this.queue.add(block);
2280
+ };
2281
+
2282
+ jasmine.Suite.prototype.specs = function() {
2283
+ return this.specs_;
2284
+ };
2285
+
2286
+ jasmine.Suite.prototype.execute = function(onComplete) {
2287
+ var self = this;
2288
+ this.queue.start(function () {
2289
+ self.finish(onComplete);
2290
+ });
2291
+ };
2292
+ jasmine.WaitsBlock = function(env, timeout, spec) {
2293
+ this.timeout = timeout;
2294
+ jasmine.Block.call(this, env, null, spec);
2295
+ };
2296
+
2297
+ jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
2298
+
2299
+ jasmine.WaitsBlock.prototype.execute = function (onComplete) {
2300
+ this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
2301
+ this.env.setTimeout(function () {
2302
+ onComplete();
2303
+ }, this.timeout);
2304
+ };
2305
+ jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) {
2306
+ this.timeout = timeout;
2307
+ this.latchFunction = latchFunction;
2308
+ this.message = message;
2309
+ this.totalTimeSpentWaitingForLatch = 0;
2310
+ jasmine.Block.call(this, env, null, spec);
2311
+ };
2312
+
2313
+ jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);
2314
+
2315
+ jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 100;
2316
+
2317
+ jasmine.WaitsForBlock.prototype.execute = function (onComplete) {
2318
+ var self = this;
2319
+ self.env.reporter.log('>> Jasmine waiting for ' + (self.message || 'something to happen'));
2320
+ var latchFunctionResult;
2321
+ try {
2322
+ latchFunctionResult = self.latchFunction.apply(self.spec);
2323
+ } catch (e) {
2324
+ self.spec.fail(e);
2325
+ onComplete();
2326
+ return;
2327
+ }
2328
+
2329
+ if (latchFunctionResult) {
2330
+ onComplete();
2331
+ } else if (self.totalTimeSpentWaitingForLatch >= self.timeout) {
2332
+ var message = 'timed out after ' + self.timeout + ' msec waiting for ' + (self.message || 'something to happen');
2333
+ self.spec.fail({
2334
+ name: 'timeout',
2335
+ message: message
2336
+ });
2337
+ self.spec._next();
2338
+ } else {
2339
+ self.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT;
2340
+ self.env.setTimeout(function () { self.execute(onComplete); }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);
2341
+ }
2342
+ };
2343
+ // Mock setTimeout, clearTimeout
2344
+ // Contributed by Pivotal Computer Systems, www.pivotalsf.com
2345
+
2346
+ jasmine.FakeTimer = function() {
2347
+ this.reset();
2348
+
2349
+ var self = this;
2350
+ self.setTimeout = function(funcToCall, millis) {
2351
+ self.timeoutsMade++;
2352
+ self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false);
2353
+ return self.timeoutsMade;
2354
+ };
2355
+
2356
+ self.setInterval = function(funcToCall, millis) {
2357
+ self.timeoutsMade++;
2358
+ self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true);
2359
+ return self.timeoutsMade;
2360
+ };
2361
+
2362
+ self.clearTimeout = function(timeoutKey) {
2363
+ self.scheduledFunctions[timeoutKey] = jasmine.undefined;
2364
+ };
2365
+
2366
+ self.clearInterval = function(timeoutKey) {
2367
+ self.scheduledFunctions[timeoutKey] = jasmine.undefined;
2368
+ };
2369
+
2370
+ };
2371
+
2372
+ jasmine.FakeTimer.prototype.reset = function() {
2373
+ this.timeoutsMade = 0;
2374
+ this.scheduledFunctions = {};
2375
+ this.nowMillis = 0;
2376
+ };
2377
+
2378
+ jasmine.FakeTimer.prototype.tick = function(millis) {
2379
+ var oldMillis = this.nowMillis;
2380
+ var newMillis = oldMillis + millis;
2381
+ this.runFunctionsWithinRange(oldMillis, newMillis);
2382
+ this.nowMillis = newMillis;
2383
+ };
2384
+
2385
+ jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {
2386
+ var scheduledFunc;
2387
+ var funcsToRun = [];
2388
+ for (var timeoutKey in this.scheduledFunctions) {
2389
+ scheduledFunc = this.scheduledFunctions[timeoutKey];
2390
+ if (scheduledFunc != jasmine.undefined &&
2391
+ scheduledFunc.runAtMillis >= oldMillis &&
2392
+ scheduledFunc.runAtMillis <= nowMillis) {
2393
+ funcsToRun.push(scheduledFunc);
2394
+ this.scheduledFunctions[timeoutKey] = jasmine.undefined;
2395
+ }
2396
+ }
2397
+
2398
+ if (funcsToRun.length > 0) {
2399
+ funcsToRun.sort(function(a, b) {
2400
+ return a.runAtMillis - b.runAtMillis;
2401
+ });
2402
+ for (var i = 0; i < funcsToRun.length; ++i) {
2403
+ try {
2404
+ var funcToRun = funcsToRun[i];
2405
+ this.nowMillis = funcToRun.runAtMillis;
2406
+ funcToRun.funcToCall();
2407
+ if (funcToRun.recurring) {
2408
+ this.scheduleFunction(funcToRun.timeoutKey,
2409
+ funcToRun.funcToCall,
2410
+ funcToRun.millis,
2411
+ true);
2412
+ }
2413
+ } catch(e) {
2414
+ }
2415
+ }
2416
+ this.runFunctionsWithinRange(oldMillis, nowMillis);
2417
+ }
2418
+ };
2419
+
2420
+ jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) {
2421
+ this.scheduledFunctions[timeoutKey] = {
2422
+ runAtMillis: this.nowMillis + millis,
2423
+ funcToCall: funcToCall,
2424
+ recurring: recurring,
2425
+ timeoutKey: timeoutKey,
2426
+ millis: millis
2427
+ };
2428
+ };
2429
+
2430
+ /**
2431
+ * @namespace
2432
+ */
2433
+ jasmine.Clock = {
2434
+ defaultFakeTimer: new jasmine.FakeTimer(),
2435
+
2436
+ reset: function() {
2437
+ jasmine.Clock.assertInstalled();
2438
+ jasmine.Clock.defaultFakeTimer.reset();
2439
+ },
2440
+
2441
+ tick: function(millis) {
2442
+ jasmine.Clock.assertInstalled();
2443
+ jasmine.Clock.defaultFakeTimer.tick(millis);
2444
+ },
2445
+
2446
+ runFunctionsWithinRange: function(oldMillis, nowMillis) {
2447
+ jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis);
2448
+ },
2449
+
2450
+ scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
2451
+ jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring);
2452
+ },
2453
+
2454
+ useMock: function() {
2455
+ var spec = jasmine.getEnv().currentSpec;
2456
+ spec.after(jasmine.Clock.uninstallMock);
2457
+
2458
+ jasmine.Clock.installMock();
2459
+ },
2460
+
2461
+ installMock: function() {
2462
+ jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer;
2463
+ },
2464
+
2465
+ uninstallMock: function() {
2466
+ jasmine.Clock.assertInstalled();
2467
+ jasmine.Clock.installed = jasmine.Clock.real;
2468
+ },
2469
+
2470
+ real: {
2471
+ setTimeout: window.setTimeout,
2472
+ clearTimeout: window.clearTimeout,
2473
+ setInterval: window.setInterval,
2474
+ clearInterval: window.clearInterval
2475
+ },
2476
+
2477
+ assertInstalled: function() {
2478
+ if (jasmine.Clock.installed != jasmine.Clock.defaultFakeTimer) {
2479
+ throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
2480
+ }
2481
+ },
2482
+
2483
+ installed: null
2484
+ };
2485
+ jasmine.Clock.installed = jasmine.Clock.real;
2486
+
2487
+ //else for IE support
2488
+ window.setTimeout = function(funcToCall, millis) {
2489
+ if (jasmine.Clock.installed.setTimeout.apply) {
2490
+ return jasmine.Clock.installed.setTimeout.apply(this, arguments);
2491
+ } else {
2492
+ return jasmine.Clock.installed.setTimeout(funcToCall, millis);
2493
+ }
2494
+ };
2495
+
2496
+ window.setInterval = function(funcToCall, millis) {
2497
+ if (jasmine.Clock.installed.setInterval.apply) {
2498
+ return jasmine.Clock.installed.setInterval.apply(this, arguments);
2499
+ } else {
2500
+ return jasmine.Clock.installed.setInterval(funcToCall, millis);
2501
+ }
2502
+ };
2503
+
2504
+ window.clearTimeout = function(timeoutKey) {
2505
+ if (jasmine.Clock.installed.clearTimeout.apply) {
2506
+ return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
2507
+ } else {
2508
+ return jasmine.Clock.installed.clearTimeout(timeoutKey);
2509
+ }
2510
+ };
2511
+
2512
+ window.clearInterval = function(timeoutKey) {
2513
+ if (jasmine.Clock.installed.clearTimeout.apply) {
2514
+ return jasmine.Clock.installed.clearInterval.apply(this, arguments);
2515
+ } else {
2516
+ return jasmine.Clock.installed.clearInterval(timeoutKey);
2517
+ }
2518
+ };
2519
+
2520
+
2521
+ jasmine.version_= {
2522
+ "major": 0,
2523
+ "minor": 10,
2524
+ "build": 0,
2525
+ "revision": 1264459703
2526
+ };