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,236 @@
1
+ /**
2
+ * Environment for Jasmine
3
+ *
4
+ * @constructor
5
+ */
6
+ jasmine.Env = function() {
7
+ this.currentSpec = null;
8
+ this.currentSuite = null;
9
+ this.currentRunner_ = new jasmine.Runner(this);
10
+
11
+ this.reporter = new jasmine.MultiReporter();
12
+
13
+ this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
14
+ this.lastUpdate = 0;
15
+ this.specFilter = function() {
16
+ return true;
17
+ };
18
+
19
+ this.nextSpecId_ = 0;
20
+ this.nextSuiteId_ = 0;
21
+ this.equalityTesters_ = [];
22
+
23
+ // wrap matchers
24
+ this.matchersClass = function() {
25
+ jasmine.Matchers.apply(this, arguments);
26
+ };
27
+ jasmine.util.inherit(this.matchersClass, jasmine.Matchers);
28
+
29
+ for (var methodName in jasmine.Matchers.prototype) {
30
+ var orig = jasmine.Matchers.prototype[methodName];
31
+ this.matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
32
+ }
33
+ };
34
+
35
+
36
+ jasmine.Env.prototype.setTimeout = jasmine.setTimeout;
37
+ jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;
38
+ jasmine.Env.prototype.setInterval = jasmine.setInterval;
39
+ jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
40
+
41
+ /**
42
+ * @returns an object containing jasmine version build info, if set.
43
+ */
44
+ jasmine.Env.prototype.version = function () {
45
+ if (jasmine.version_) {
46
+ return jasmine.version_;
47
+ } else {
48
+ throw new Error('Version not set');
49
+ }
50
+ };
51
+
52
+ /**
53
+ * @returns a sequential integer starting at 0
54
+ */
55
+ jasmine.Env.prototype.nextSpecId = function () {
56
+ return this.nextSpecId_++;
57
+ };
58
+
59
+ /**
60
+ * @returns a sequential integer starting at 0
61
+ */
62
+ jasmine.Env.prototype.nextSuiteId = function () {
63
+ return this.nextSuiteId_++;
64
+ };
65
+
66
+ /**
67
+ * Register a reporter to receive status updates from Jasmine.
68
+ * @param {jasmine.Reporter} reporter An object which will receive status updates.
69
+ */
70
+ jasmine.Env.prototype.addReporter = function(reporter) {
71
+ this.reporter.addReporter(reporter);
72
+ };
73
+
74
+ jasmine.Env.prototype.execute = function() {
75
+ this.currentRunner_.execute();
76
+ };
77
+
78
+ jasmine.Env.prototype.describe = function(description, specDefinitions) {
79
+ var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
80
+
81
+ var parentSuite = this.currentSuite;
82
+ if (parentSuite) {
83
+ parentSuite.add(suite);
84
+ } else {
85
+ this.currentRunner_.add(suite);
86
+ }
87
+
88
+ this.currentSuite = suite;
89
+
90
+ specDefinitions.call(suite);
91
+
92
+ this.currentSuite = parentSuite;
93
+
94
+ return suite;
95
+ };
96
+
97
+ jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
98
+ if (this.currentSuite) {
99
+ this.currentSuite.beforeEach(beforeEachFunction);
100
+ } else {
101
+ this.currentRunner_.beforeEach(beforeEachFunction);
102
+ }
103
+ };
104
+
105
+ jasmine.Env.prototype.currentRunner = function () {
106
+ return this.currentRunner_;
107
+ };
108
+
109
+ jasmine.Env.prototype.afterEach = function(afterEachFunction) {
110
+ if (this.currentSuite) {
111
+ this.currentSuite.afterEach(afterEachFunction);
112
+ } else {
113
+ this.currentRunner_.afterEach(afterEachFunction);
114
+ }
115
+
116
+ };
117
+
118
+ jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
119
+ return {
120
+ execute: function() {
121
+ }
122
+ };
123
+ };
124
+
125
+ jasmine.Env.prototype.it = function(description, func) {
126
+ var spec = new jasmine.Spec(this, this.currentSuite, description);
127
+ this.currentSuite.add(spec);
128
+ this.currentSpec = spec;
129
+ spec.pending = false;
130
+
131
+ if (func) {
132
+ spec.runs(func);
133
+ } else {
134
+ spec.pending = true;
135
+ }
136
+
137
+ return spec;
138
+ };
139
+
140
+ jasmine.Env.prototype.xit = function(description, func) {
141
+ var spec = this.it(description, func);
142
+ spec.pending = -1;
143
+ return spec;
144
+ };
145
+
146
+ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
147
+ if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
148
+ return true;
149
+ }
150
+
151
+ a.__Jasmine_been_here_before__ = b;
152
+ b.__Jasmine_been_here_before__ = a;
153
+
154
+ var hasKey = function(obj, keyName) {
155
+ return obj != null && obj[keyName] !== jasmine.undefined;
156
+ };
157
+
158
+ for (var property in b) {
159
+ if (!hasKey(a, property) && hasKey(b, property)) {
160
+ mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
161
+ }
162
+ }
163
+ for (property in a) {
164
+ if (!hasKey(b, property) && hasKey(a, property)) {
165
+ mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
166
+ }
167
+ }
168
+ for (property in b) {
169
+ if (property == '__Jasmine_been_here_before__') continue;
170
+ if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) {
171
+ 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.");
172
+ }
173
+ }
174
+
175
+ if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) {
176
+ mismatchValues.push("arrays were not the same length");
177
+ }
178
+
179
+ delete a.__Jasmine_been_here_before__;
180
+ delete b.__Jasmine_been_here_before__;
181
+ return (mismatchKeys.length == 0 && mismatchValues.length == 0);
182
+ };
183
+
184
+ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
185
+ mismatchKeys = mismatchKeys || [];
186
+ mismatchValues = mismatchValues || [];
187
+
188
+ if (a === b) return true;
189
+
190
+ if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
191
+ return (a == jasmine.undefined && b == jasmine.undefined);
192
+ }
193
+
194
+ if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
195
+ return a === b;
196
+ }
197
+
198
+ if (a instanceof Date && b instanceof Date) {
199
+ return a.getTime() == b.getTime();
200
+ }
201
+
202
+ if (a instanceof jasmine.Matchers.Any) {
203
+ return a.matches(b);
204
+ }
205
+
206
+ if (b instanceof jasmine.Matchers.Any) {
207
+ return b.matches(a);
208
+ }
209
+
210
+ if (typeof a === "object" && typeof b === "object") {
211
+ return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
212
+ }
213
+
214
+ for (var i = 0; i < this.equalityTesters_.length; i++) {
215
+ var equalityTester = this.equalityTesters_[i];
216
+ var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
217
+ if (result !== jasmine.undefined) return result;
218
+ }
219
+
220
+ //Straight check
221
+ return (a === b);
222
+ };
223
+
224
+ jasmine.Env.prototype.contains_ = function(haystack, needle) {
225
+ if (jasmine.isArray_(haystack)) {
226
+ for (var i = 0; i < haystack.length; i++) {
227
+ if (this.equals_(haystack[i], needle)) return true;
228
+ }
229
+ return false;
230
+ }
231
+ return haystack.indexOf(needle) >= 0;
232
+ };
233
+
234
+ jasmine.Env.prototype.addEqualityTester = function(equalityTester) {
235
+ this.equalityTesters_.push(equalityTester);
236
+ };
@@ -0,0 +1,103 @@
1
+ /** JavaScript API reporter.
2
+ *
3
+ * @constructor
4
+ */
5
+ jasmine.JsApiReporter = function() {
6
+ this.started = false;
7
+ this.finished = false;
8
+ this.suites_ = [];
9
+ this.results_ = {};
10
+ };
11
+
12
+ jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
13
+ this.started = true;
14
+ var suites = runner.suites();
15
+ for (var i = 0; i < suites.length; i++) {
16
+ var suite = suites[i];
17
+ this.suites_.push(this.summarize_(suite));
18
+ }
19
+ };
20
+
21
+ jasmine.JsApiReporter.prototype.suites = function() {
22
+ return this.suites_;
23
+ };
24
+
25
+ jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
26
+ var isSuite = suiteOrSpec instanceof jasmine.Suite;
27
+ var summary = {
28
+ id: suiteOrSpec.id,
29
+ name: suiteOrSpec.description,
30
+ type: isSuite ? 'suite' : 'spec',
31
+ children: []
32
+ };
33
+ if (isSuite) {
34
+ var specs = suiteOrSpec.specs();
35
+ for (var i = 0; i < specs.length; i++) {
36
+ summary.children.push(this.summarize_(specs[i]));
37
+ }
38
+ }
39
+ return summary;
40
+ };
41
+
42
+ jasmine.JsApiReporter.prototype.results = function() {
43
+ return this.results_;
44
+ };
45
+
46
+ jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) {
47
+ return this.results_[specId];
48
+ };
49
+
50
+ //noinspection JSUnusedLocalSymbols
51
+ jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) {
52
+ this.finished = true;
53
+ };
54
+
55
+ //noinspection JSUnusedLocalSymbols
56
+ jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) {
57
+ };
58
+
59
+ //noinspection JSUnusedLocalSymbols
60
+ jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
61
+ this.results_[spec.id] = {
62
+ messages: spec.results().getItems(),
63
+ result: spec.results().failedCount > 0 ? "failed" : "passed"
64
+ };
65
+ };
66
+
67
+ //noinspection JSUnusedLocalSymbols
68
+ jasmine.JsApiReporter.prototype.log = function(str) {
69
+ };
70
+
71
+ jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
72
+ var results = {};
73
+ for (var i = 0; i < specIds.length; i++) {
74
+ var specId = specIds[i];
75
+ results[specId] = this.summarizeResult_(this.results_[specId]);
76
+ }
77
+ return results;
78
+ };
79
+
80
+ jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
81
+ var summaryMessages = [];
82
+ var messagesLength = result.messages.length
83
+ for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
84
+ var resultMessage = result.messages[messageIndex];
85
+ summaryMessages.push({
86
+ text: resultMessage.text,
87
+ passed: resultMessage.passed ? resultMessage.passed() : true,
88
+ type: resultMessage.type,
89
+ message: resultMessage.message,
90
+ trace: {
91
+ stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined
92
+ }
93
+ });
94
+ };
95
+
96
+ var summaryResult = {
97
+ result : result.result,
98
+ messages : summaryMessages
99
+ };
100
+
101
+ return summaryResult;
102
+ };
103
+
@@ -0,0 +1,326 @@
1
+ /**
2
+ * @constructor
3
+ * @param {jasmine.Env} env
4
+ * @param actual
5
+ * @param {jasmine.Spec} spec
6
+ */
7
+ jasmine.Matchers = function(env, actual, spec) {
8
+ this.env = env;
9
+ this.actual = actual;
10
+ this.spec = spec;
11
+ };
12
+
13
+ jasmine.Matchers.pp = function(str) {
14
+ return jasmine.util.htmlEscape(jasmine.pp(str));
15
+ };
16
+
17
+ jasmine.Matchers.prototype.report = function(result, failing_message, details) {
18
+ var expectationResult = new jasmine.ExpectationResult({
19
+ passed: result,
20
+ message: failing_message,
21
+ details: details
22
+ });
23
+ this.spec.addMatcherResult(expectationResult);
24
+ return result;
25
+ };
26
+
27
+ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
28
+ return function() {
29
+ var matcherArgs = jasmine.util.argsToArray(arguments);
30
+ var result = matcherFunction.apply(this, arguments);
31
+ var message;
32
+ // debug("m",matcherFunction+"",this.spec.is_eventual);
33
+ if (!result && this.spec.is_eventual){
34
+ // debug('retry');
35
+ throw new jasmine.eventually_;
36
+ }
37
+ if (!result) {
38
+ if (this.message) {
39
+ message = this.message.apply(this, arguments);
40
+ } else {
41
+ var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
42
+ message = "Expected " + jasmine.pp(this.actual) + " " + englishyPredicate;
43
+ if (matcherArgs.length > 0) {
44
+ for (var i = 0; i < matcherArgs.length; i++) {
45
+ if (i > 0) message += ",";
46
+ message += " " + jasmine.pp(matcherArgs[i]);
47
+ }
48
+ }
49
+ message += ".";
50
+ }
51
+ }
52
+ var expectationResult = new jasmine.ExpectationResult({
53
+ matcherName: matcherName,
54
+ passed: result,
55
+ expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0],
56
+ actual: this.actual,
57
+ message: message
58
+ });
59
+ this.spec.addMatcherResult(expectationResult);
60
+ return result;
61
+ };
62
+ };
63
+
64
+
65
+
66
+
67
+ /**
68
+ * toComplete: synthetic matcher for async test timeouts
69
+ */
70
+
71
+ jasmine.Matchers.prototype.toComplete = function() {
72
+ return false;
73
+ };
74
+
75
+ /**
76
+ * toBe: compares the actual to the expected using ===
77
+ * @param expected
78
+ */
79
+
80
+ jasmine.Matchers.prototype.toBe = function(expected) {
81
+ return this.actual === expected;
82
+ };
83
+
84
+ /**
85
+ * toNotBe: compares the actual to the expected using !==
86
+ * @param expected
87
+ */
88
+ jasmine.Matchers.prototype.toNotBe = function(expected) {
89
+ return this.actual !== expected;
90
+ };
91
+
92
+ /**
93
+ * toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.
94
+ *
95
+ * @param expected
96
+ */
97
+
98
+ jasmine.Matchers.prototype.toEqual = function(expected) {
99
+ return this.env.equals_(this.actual, expected);
100
+ };
101
+
102
+ /**
103
+ * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
104
+ * @param expected
105
+ */
106
+ jasmine.Matchers.prototype.toNotEqual = function(expected) {
107
+ return !this.env.equals_(this.actual, expected);
108
+ };
109
+
110
+ /**
111
+ * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes
112
+ * a pattern or a String.
113
+ *
114
+ * @param reg_exp
115
+ */
116
+ jasmine.Matchers.prototype.toMatch = function(expected) {
117
+ return new RegExp(expected).test(this.actual);
118
+ };
119
+
120
+ /**
121
+ * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
122
+ * @param reg_exp
123
+ */
124
+ jasmine.Matchers.prototype.toNotMatch = function(expected) {
125
+ return !(new RegExp(expected).test(this.actual));
126
+ };
127
+
128
+ /**
129
+ * Matcher that compares the actual to jasmine.undefined.
130
+ */
131
+ jasmine.Matchers.prototype.toBeDefined = function() {
132
+ return (this.actual !== jasmine.undefined);
133
+ };
134
+
135
+ /**
136
+ * Matcher that compares the actual to jasmine.undefined.
137
+ */
138
+ jasmine.Matchers.prototype.toBeUndefined = function() {
139
+ return (this.actual === jasmine.undefined);
140
+ };
141
+
142
+ /**
143
+ * Matcher that compares the actual to null.
144
+ */
145
+ jasmine.Matchers.prototype.toBeNull = function() {
146
+ return (this.actual === null);
147
+ };
148
+
149
+ /**
150
+ * Matcher that boolean not-nots the actual.
151
+ */
152
+ jasmine.Matchers.prototype.toBeTruthy = function() {
153
+ return !!this.actual;
154
+ };
155
+
156
+
157
+ /**
158
+ * Matcher that boolean nots the actual.
159
+ */
160
+ jasmine.Matchers.prototype.toBeFalsy = function() {
161
+ return !this.actual;
162
+ };
163
+
164
+ /**
165
+ * Matcher that checks to see if the actual, a Jasmine spy, was called.
166
+ */
167
+ jasmine.Matchers.prototype.wasCalled = function() {
168
+ if (arguments.length > 0) {
169
+ throw new Error('wasCalled does not take arguments, use wasCalledWith');
170
+ }
171
+
172
+ if (!jasmine.isSpy(this.actual)) {
173
+ throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
174
+ }
175
+
176
+ this.message = function() {
177
+ return "Expected spy " + this.actual.identity + " to have been called.";
178
+ };
179
+
180
+ return this.actual.wasCalled;
181
+ };
182
+
183
+ /**
184
+ * Matcher that checks to see if the actual, a Jasmine spy, was not called.
185
+ */
186
+ jasmine.Matchers.prototype.wasNotCalled = function() {
187
+ if (arguments.length > 0) {
188
+ throw new Error('wasNotCalled does not take arguments');
189
+ }
190
+
191
+ if (!jasmine.isSpy(this.actual)) {
192
+ throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
193
+ }
194
+
195
+ this.message = function() {
196
+ return "Expected spy " + this.actual.identity + " to not have been called.";
197
+ };
198
+
199
+ return !this.actual.wasCalled;
200
+ };
201
+
202
+ /**
203
+ * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.
204
+ *
205
+ * @example
206
+ *
207
+ */
208
+ jasmine.Matchers.prototype.wasCalledWith = function() {
209
+ if (!jasmine.isSpy(this.actual)) {
210
+ throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
211
+ }
212
+
213
+ this.message = function() {
214
+ if (this.actual.callCount == 0) {
215
+ return "Expected spy to have been called with " + jasmine.pp(arguments) + " but it was never called.";
216
+ } else {
217
+ return "Expected spy to have been called with " + jasmine.pp(arguments) + " but was called with " + jasmine.pp(this.actual.argsForCall);
218
+ }
219
+ };
220
+
221
+ return this.env.contains_(this.actual.argsForCall, jasmine.util.argsToArray(arguments));
222
+ };
223
+
224
+ jasmine.Matchers.prototype.wasNotCalledWith = function() {
225
+ if (!jasmine.isSpy(this.actual)) {
226
+ throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
227
+ }
228
+
229
+ this.message = function() {
230
+ return "Expected spy not to have been called with " + jasmine.pp(arguments) + " but it was";
231
+ };
232
+
233
+ return !this.env.contains_(this.actual.argsForCall, jasmine.util.argsToArray(arguments));
234
+ };
235
+
236
+ /**
237
+ * Matcher that checks that the expected item is an element in the actual Array.
238
+ *
239
+ * @param {Object} item
240
+ */
241
+ jasmine.Matchers.prototype.toContain = function(expected) {
242
+ return this.env.contains_(this.actual, expected);
243
+ };
244
+
245
+ /**
246
+ * Matcher that checks that the expected item is NOT an element in the actual Array.
247
+ *
248
+ * @param {Object} item
249
+ */
250
+ jasmine.Matchers.prototype.toNotContain = function(expected) {
251
+ return !this.env.contains_(this.actual, expected);
252
+ };
253
+
254
+ jasmine.Matchers.prototype.toBeLessThan = function(expected) {
255
+ return this.actual < expected;
256
+ };
257
+
258
+ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
259
+ return this.actual > expected;
260
+ };
261
+
262
+ /**
263
+ * Matcher that checks that the expected exception was thrown by the actual.
264
+ *
265
+ * @param {String} expectedException
266
+ */
267
+ jasmine.Matchers.prototype.toThrow = function(expected) {
268
+ function getException_(actual, expected) {
269
+ var exception;
270
+ if (typeof actual != 'function') {
271
+ throw new Error('Actual is not a function');
272
+ }
273
+ try {
274
+ actual();
275
+ } catch (e) {
276
+ exception = e;
277
+ }
278
+ return exception;
279
+ }
280
+
281
+ var result = false;
282
+ var exception = getException_(this.actual, expected);
283
+ if (exception) {
284
+ result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
285
+ }
286
+
287
+ this.message = function(expected) {
288
+ var exception = getException_(this.actual, expected);
289
+ if (exception && expected !== jasmine.undefined && (!this.env.equals_(exception.message || exception, expected.message || expected))) {
290
+ return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception ].join(' ');
291
+ } else {
292
+ return "Expected function to throw an exception.";
293
+ }
294
+ };
295
+
296
+ return result;
297
+ };
298
+
299
+ jasmine.Matchers.Any = function(expectedClass) {
300
+ this.expectedClass = expectedClass;
301
+ };
302
+
303
+ jasmine.Matchers.Any.prototype.matches = function(other) {
304
+ if (this.expectedClass == String) {
305
+ return typeof other == 'string' || other instanceof String;
306
+ }
307
+
308
+ if (this.expectedClass == Number) {
309
+ return typeof other == 'number' || other instanceof Number;
310
+ }
311
+
312
+ if (this.expectedClass == Function) {
313
+ return typeof other == 'function' || other instanceof Function;
314
+ }
315
+
316
+ if (this.expectedClass == Object) {
317
+ return typeof other == 'object';
318
+ }
319
+
320
+ return other instanceof this.expectedClass;
321
+ };
322
+
323
+ jasmine.Matchers.Any.prototype.toString = function() {
324
+ return '<jasmine.any(' + this.expectedClass + ')>';
325
+ };
326
+
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @constructor
3
+ */
4
+ jasmine.MultiReporter = function() {
5
+ this.subReporters_ = [];
6
+ };
7
+ jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter);
8
+
9
+ jasmine.MultiReporter.prototype.addReporter = function(reporter) {
10
+ this.subReporters_.push(reporter);
11
+ };
12
+
13
+ (function() {
14
+ var functionNames = ["reportRunnerStarting", "reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"];
15
+ for (var i = 0; i < functionNames.length; i++) {
16
+ var functionName = functionNames[i];
17
+ jasmine.MultiReporter.prototype[functionName] = (function(functionName) {
18
+ return function() {
19
+ for (var j = 0; j < this.subReporters_.length; j++) {
20
+ var subReporter = this.subReporters_[j];
21
+ if (subReporter[functionName]) {
22
+ subReporter[functionName].apply(subReporter, arguments);
23
+ }
24
+ }
25
+ };
26
+ })(functionName);
27
+ }
28
+ })();