jasmine-core 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/lib/console/console.js +54 -24
  3. data/lib/jasmine-core/__init__.py +1 -0
  4. data/lib/jasmine-core/boot/boot.js +2 -63
  5. data/lib/jasmine-core/boot/node_boot.js +19 -0
  6. data/lib/jasmine-core/boot.js +3 -64
  7. data/lib/jasmine-core/core.py +60 -0
  8. data/lib/jasmine-core/example/node_example/spec/PlayerSpec.js +60 -0
  9. data/lib/jasmine-core/example/node_example/spec/SpecHelper.js +15 -0
  10. data/lib/jasmine-core/example/node_example/src/Player.js +24 -0
  11. data/lib/jasmine-core/example/node_example/src/Song.js +9 -0
  12. data/lib/jasmine-core/jasmine-html.js +119 -74
  13. data/lib/jasmine-core/jasmine.css +61 -54
  14. data/lib/jasmine-core/jasmine.js +964 -456
  15. data/lib/jasmine-core/json2.js +73 -62
  16. data/lib/jasmine-core/node_boot.js +41 -0
  17. data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +52 -8
  18. data/lib/jasmine-core/spec/core/AnySpec.js +1 -0
  19. data/lib/jasmine-core/spec/core/ClockSpec.js +122 -18
  20. data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +14 -1
  21. data/lib/jasmine-core/spec/core/EnvSpec.js +0 -63
  22. data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +7 -0
  23. data/lib/jasmine-core/spec/core/ExceptionsSpec.js +2 -2
  24. data/lib/jasmine-core/spec/core/ExpectationSpec.js +46 -50
  25. data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +37 -0
  26. data/lib/jasmine-core/spec/core/MockDateSpec.js +200 -0
  27. data/lib/jasmine-core/spec/core/ObjectContainingSpec.js +6 -0
  28. data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +49 -12
  29. data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +184 -60
  30. data/lib/jasmine-core/spec/core/SpecSpec.js +46 -108
  31. data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +55 -0
  32. data/lib/jasmine-core/spec/core/SpySpec.js +10 -0
  33. data/lib/jasmine-core/spec/core/SpyStrategySpec.js +13 -0
  34. data/lib/jasmine-core/spec/core/SuiteSpec.js +143 -11
  35. data/lib/jasmine-core/spec/core/TimerSpec.js +18 -0
  36. data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +34 -32
  37. data/lib/jasmine-core/spec/core/integration/EnvSpec.js +998 -50
  38. data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +279 -3
  39. data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +18 -1
  40. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +2 -1
  41. data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +3 -2
  42. data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +2 -1
  43. data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +4 -2
  44. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +2 -1
  45. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +17 -3
  46. data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +14 -14
  47. data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +5 -5
  48. data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +7 -0
  49. data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +33 -0
  50. data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +183 -35
  51. data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +1 -1
  52. data/lib/jasmine-core/spec/node_suite.js +9 -1
  53. data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +104 -0
  54. data/lib/jasmine-core/spec/performance/large_object_test.js +36 -0
  55. data/lib/jasmine-core/version.rb +1 -1
  56. data/lib/jasmine-core.js +37 -0
  57. data/lib/jasmine-core.rb +6 -2
  58. metadata +23 -9
  59. data/lib/jasmine-core/spec/support/dev_boot.js +0 -124
@@ -1,6 +1,6 @@
1
1
  /*
2
- http://www.JSON.org/json2.js
3
- 2009-08-17
2
+ json2.js
3
+ 2014-02-04
4
4
 
5
5
  Public Domain.
6
6
 
@@ -8,6 +8,14 @@
8
8
 
9
9
  See http://www.JSON.org/js.html
10
10
 
11
+
12
+ This code should be minified before deployment.
13
+ See http://javascript.crockford.com/jsmin.html
14
+
15
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
16
+ NOT CONTROL.
17
+
18
+
11
19
  This file creates a global JSON object containing two methods: stringify
12
20
  and parse.
13
21
 
@@ -136,15 +144,9 @@
136
144
 
137
145
  This is a reference implementation. You are free to copy, modify, or
138
146
  redistribute.
139
-
140
- This code should be minified before deployment.
141
- See http://javascript.crockford.com/jsmin.html
142
-
143
- USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
144
- NOT CONTROL.
145
147
  */
146
148
 
147
- /*jslint evil: true */
149
+ /*jslint evil: true, regexp: true */
148
150
 
149
151
  /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
150
152
  call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
@@ -153,16 +155,16 @@
153
155
  test, toJSON, toString, valueOf
154
156
  */
155
157
 
156
- "use strict";
157
158
 
158
159
  // Create a JSON object only if one does not already exist. We create the
159
160
  // methods in a closure to avoid creating global variables.
160
161
 
161
- if (!this.JSON) {
162
- this.JSON = {};
162
+ if (typeof JSON !== 'object') {
163
+ JSON = {};
163
164
  }
164
165
 
165
166
  (function () {
167
+ 'use strict';
166
168
 
167
169
  function f(n) {
168
170
  // Format integers to have at least two digits.
@@ -171,37 +173,30 @@ if (!this.JSON) {
171
173
 
172
174
  if (typeof Date.prototype.toJSON !== 'function') {
173
175
 
174
- Date.prototype.toJSON = function (key) {
176
+ Date.prototype.toJSON = function () {
175
177
 
176
- return isFinite(this.valueOf()) ?
177
- this.getUTCFullYear() + '-' +
178
- f(this.getUTCMonth() + 1) + '-' +
179
- f(this.getUTCDate()) + 'T' +
180
- f(this.getUTCHours()) + ':' +
181
- f(this.getUTCMinutes()) + ':' +
182
- f(this.getUTCSeconds()) + 'Z' : null;
178
+ return isFinite(this.valueOf())
179
+ ? this.getUTCFullYear() + '-' +
180
+ f(this.getUTCMonth() + 1) + '-' +
181
+ f(this.getUTCDate()) + 'T' +
182
+ f(this.getUTCHours()) + ':' +
183
+ f(this.getUTCMinutes()) + ':' +
184
+ f(this.getUTCSeconds()) + 'Z'
185
+ : null;
183
186
  };
184
187
 
185
- String.prototype.toJSON =
186
- Number.prototype.toJSON =
187
- Boolean.prototype.toJSON = function (key) {
188
- return this.valueOf();
189
- };
188
+ String.prototype.toJSON =
189
+ Number.prototype.toJSON =
190
+ Boolean.prototype.toJSON = function () {
191
+ return this.valueOf();
192
+ };
190
193
  }
191
194
 
192
- var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
193
- escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
195
+ var cx,
196
+ escapable,
194
197
  gap,
195
198
  indent,
196
- meta = { // table of character substitutions
197
- '\b': '\\b',
198
- '\t': '\\t',
199
- '\n': '\\n',
200
- '\f': '\\f',
201
- '\r': '\\r',
202
- '"' : '\\"',
203
- '\\': '\\\\'
204
- },
199
+ meta,
205
200
  rep;
206
201
 
207
202
 
@@ -213,17 +208,17 @@ if (!this.JSON) {
213
208
  // sequences.
214
209
 
215
210
  escapable.lastIndex = 0;
216
- return escapable.test(string) ?
217
- '"' + string.replace(escapable, function (a) {
218
- var c = meta[a];
219
- return typeof c === 'string' ? c :
220
- '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
221
- }) + '"' :
222
- '"' + string + '"';
211
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
212
+ var c = meta[a];
213
+ return typeof c === 'string'
214
+ ? c
215
+ : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
216
+ }) + '"' : '"' + string + '"';
223
217
  }
224
218
 
225
219
 
226
220
  function str(key, holder) {
221
+
227
222
  // Produce a string from holder[key].
228
223
 
229
224
  var i, // The loop counter.
@@ -301,11 +296,11 @@ if (!this.JSON) {
301
296
  // Join all of the elements together, separated with commas, and wrap them in
302
297
  // brackets.
303
298
 
304
- v = partial.length === 0 ? '[]' :
305
- gap ? '[\n' + gap +
306
- partial.join(',\n' + gap) + '\n' +
307
- mind + ']' :
308
- '[' + partial.join(',') + ']';
299
+ v = partial.length === 0
300
+ ? '[]'
301
+ : gap
302
+ ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
303
+ : '[' + partial.join(',') + ']';
309
304
  gap = mind;
310
305
  return v;
311
306
  }
@@ -315,8 +310,8 @@ if (!this.JSON) {
315
310
  if (rep && typeof rep === 'object') {
316
311
  length = rep.length;
317
312
  for (i = 0; i < length; i += 1) {
318
- k = rep[i];
319
- if (typeof k === 'string') {
313
+ if (typeof rep[i] === 'string') {
314
+ k = rep[i];
320
315
  v = str(k, value);
321
316
  if (v) {
322
317
  partial.push(quote(k) + (gap ? ': ' : ':') + v);
@@ -328,7 +323,7 @@ if (!this.JSON) {
328
323
  // Otherwise, iterate through all of the keys in the object.
329
324
 
330
325
  for (k in value) {
331
- if (Object.hasOwnProperty.call(value, k)) {
326
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
332
327
  v = str(k, value);
333
328
  if (v) {
334
329
  partial.push(quote(k) + (gap ? ': ' : ':') + v);
@@ -340,9 +335,11 @@ if (!this.JSON) {
340
335
  // Join all of the member texts together, separated with commas,
341
336
  // and wrap them in braces.
342
337
 
343
- v = partial.length === 0 ? '{}' :
344
- gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
345
- mind + '}' : '{' + partial.join(',') + '}';
338
+ v = partial.length === 0
339
+ ? '{}'
340
+ : gap
341
+ ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
342
+ : '{' + partial.join(',') + '}';
346
343
  gap = mind;
347
344
  return v;
348
345
  }
@@ -351,7 +348,18 @@ if (!this.JSON) {
351
348
  // If the JSON object does not yet have a stringify method, give it one.
352
349
 
353
350
  if (typeof JSON.stringify !== 'function') {
351
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
352
+ meta = { // table of character substitutions
353
+ '\b': '\\b',
354
+ '\t': '\\t',
355
+ '\n': '\\n',
356
+ '\f': '\\f',
357
+ '\r': '\\r',
358
+ '"' : '\\"',
359
+ '\\': '\\\\'
360
+ };
354
361
  JSON.stringify = function (value, replacer, space) {
362
+
355
363
  // The stringify method takes a value and an optional replacer, and an optional
356
364
  // space parameter, and returns a JSON text. The replacer can be a function
357
365
  // that can replace values, or an array of strings that will select the keys.
@@ -382,7 +390,7 @@ if (!this.JSON) {
382
390
  rep = replacer;
383
391
  if (replacer && typeof replacer !== 'function' &&
384
392
  (typeof replacer !== 'object' ||
385
- typeof replacer.length !== 'number')) {
393
+ typeof replacer.length !== 'number')) {
386
394
  throw new Error('JSON.stringify');
387
395
  }
388
396
 
@@ -397,6 +405,7 @@ if (!this.JSON) {
397
405
  // If the JSON object does not yet have a parse method, give it one.
398
406
 
399
407
  if (typeof JSON.parse !== 'function') {
408
+ cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
400
409
  JSON.parse = function (text, reviver) {
401
410
 
402
411
  // The parse method takes a text and an optional reviver function, and returns
@@ -412,7 +421,7 @@ if (!this.JSON) {
412
421
  var k, v, value = holder[key];
413
422
  if (value && typeof value === 'object') {
414
423
  for (k in value) {
415
- if (Object.hasOwnProperty.call(value, k)) {
424
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
416
425
  v = walk(value, k);
417
426
  if (v !== undefined) {
418
427
  value[k] = v;
@@ -430,6 +439,7 @@ if (!this.JSON) {
430
439
  // Unicode characters with escape sequences. JavaScript handles many characters
431
440
  // incorrectly, either silently deleting them, or treating them as line endings.
432
441
 
442
+ text = String(text);
433
443
  cx.lastIndex = 0;
434
444
  if (cx.test(text)) {
435
445
  text = text.replace(cx, function (a) {
@@ -451,10 +461,10 @@ if (!this.JSON) {
451
461
  // we look to see that the remaining characters are only whitespace or ']' or
452
462
  // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
453
463
 
454
- if (/^[\],:{}\s]*$/.
455
- test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
456
- replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
457
- replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
464
+ if (/^[\],:{}\s]*$/
465
+ .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
466
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
467
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
458
468
 
459
469
  // In the third stage we use the eval function to compile the text into a
460
470
  // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
@@ -466,8 +476,9 @@ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
466
476
  // In the optional fourth stage, we recursively walk the new structure, passing
467
477
  // each name/value pair to a reviver function for possible transformation.
468
478
 
469
- return typeof reviver === 'function' ?
470
- walk({'': j}, '') : j;
479
+ return typeof reviver === 'function'
480
+ ? walk({'': j}, '')
481
+ : j;
471
482
  }
472
483
 
473
484
  // If the text is not JSON parseable, then a SyntaxError is thrown.
@@ -0,0 +1,41 @@
1
+ /*
2
+ Copyright (c) 2008-2014 Pivotal Labs
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+ module.exports = function(jasmineRequire) {
24
+ var jasmine = jasmineRequire.core(jasmineRequire);
25
+
26
+ var consoleFns = require('../console/console.js');
27
+ consoleFns.console(consoleFns, jasmine);
28
+
29
+ var env = jasmine.getEnv();
30
+
31
+ var jasmineInterface = jasmineRequire.interface(jasmine, env);
32
+
33
+ extend(global, jasmineInterface);
34
+
35
+ function extend(destination, source) {
36
+ for (var property in source) destination[property] = source[property];
37
+ return destination;
38
+ }
39
+
40
+ return jasmine;
41
+ };
@@ -9,7 +9,7 @@ describe("ConsoleReporter", function() {
9
9
  output += str;
10
10
  },
11
11
  getOutput: function() {
12
- return output;
12
+ return output.replace('ConsoleReporter is deprecated and will be removed in a future version.', '');
13
13
  },
14
14
  clear: function() {
15
15
  output = "";
@@ -80,6 +80,18 @@ describe("ConsoleReporter", function() {
80
80
  expect(out.getOutput()).toEqual("*");
81
81
  });
82
82
 
83
+ it("alerts user if there are no specs", function(){
84
+ var reporter = new j$.ConsoleReporter({
85
+ print: out.print
86
+ });
87
+
88
+ reporter.jasmineStarted();
89
+ out.clear();
90
+ reporter.jasmineDone();
91
+
92
+ expect(out.getOutput()).toMatch(/No specs found/);
93
+ });
94
+
83
95
  it("reports a summary when done (singular spec and time)", function() {
84
96
  var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
85
97
  reporter = new j$.ConsoleReporter({
@@ -159,26 +171,44 @@ describe("ConsoleReporter", function() {
159
171
 
160
172
  out.clear();
161
173
 
162
- reporter.jasmineDone({});
174
+ reporter.jasmineDone();
163
175
 
176
+ expect(out.getOutput()).toMatch(/true to be false/);
164
177
  expect(out.getOutput()).toMatch(/foo bar baz/);
165
178
  });
166
179
 
167
- it("calls the onComplete callback when the suite is done", function() {
168
- var onComplete = jasmine.createSpy('onComplete'),
180
+ describe('onComplete callback', function(){
181
+ var onComplete, reporter;
182
+
183
+ beforeEach(function() {
184
+ onComplete = jasmine.createSpy('onComplete');
169
185
  reporter = new j$.ConsoleReporter({
170
186
  print: out.print,
171
187
  onComplete: onComplete
172
188
  });
189
+ reporter.jasmineStarted();
190
+ });
173
191
 
174
- reporter.jasmineDone({});
192
+ it("is called when the suite is done", function() {
193
+ reporter.jasmineDone();
194
+ expect(onComplete).toHaveBeenCalledWith(true);
195
+ });
175
196
 
176
- expect(onComplete).toHaveBeenCalled();
177
- });
197
+ it('calls it with false if there are spec failures', function() {
198
+ reporter.specDone({status: "failed", failedExpectations: []});
199
+ reporter.jasmineDone();
200
+ expect(onComplete).toHaveBeenCalledWith(false);
201
+ });
178
202
 
203
+ it('calls it with false if there are suite failures', function() {
204
+ reporter.specDone({status: "passed"});
205
+ reporter.suiteDone({failedExpectations: [{ message: 'bananas' }] });
206
+ reporter.jasmineDone();
207
+ expect(onComplete).toHaveBeenCalledWith(false);
208
+ });
209
+ });
179
210
 
180
211
  describe("with color", function() {
181
-
182
212
  it("reports that the suite has started to the console", function() {
183
213
  var reporter = new j$.ConsoleReporter({
184
214
  print: out.print,
@@ -222,5 +252,19 @@ describe("ConsoleReporter", function() {
222
252
 
223
253
  expect(out.getOutput()).toEqual("\x1B[31mF\x1B[0m");
224
254
  });
255
+
256
+ it("displays all afterAll exceptions", function() {
257
+ var reporter = new j$.ConsoleReporter({
258
+ print: out.print,
259
+ showColors: true
260
+ });
261
+
262
+ reporter.suiteDone({ failedExpectations: [{ message: 'After All Exception' }] });
263
+ reporter.suiteDone({ failedExpectations: [{ message: 'Some Other Exception' }] });
264
+ reporter.jasmineDone();
265
+
266
+ expect(out.getOutput()).toMatch(/After All Exception/);
267
+ expect(out.getOutput()).toMatch(/Some Other Exception/);
268
+ });
225
269
  });
226
270
  });
@@ -40,6 +40,7 @@ describe("Any", function() {
40
40
  var any = new j$.Any(Number);
41
41
 
42
42
  expect(any.jasmineToString()).toMatch('<jasmine.any');
43
+ expect(any.jasmineToString()).toMatch('Number');
43
44
  });
44
45
 
45
46
  });