jasmine-core 2.0.0 → 2.0.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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/lib/console/console.js +27 -22
  3. data/lib/jasmine-core.js +2 -0
  4. data/lib/jasmine-core.rb +6 -2
  5. data/lib/jasmine-core/__init__.py +1 -0
  6. data/lib/jasmine-core/boot.js +1 -1
  7. data/lib/jasmine-core/boot/node_boot.js +71 -0
  8. data/lib/jasmine-core/core.py +60 -0
  9. data/lib/jasmine-core/example/node_example/spec/PlayerSpec.js +60 -0
  10. data/lib/jasmine-core/example/node_example/spec/SpecHelper.js +15 -0
  11. data/lib/jasmine-core/example/node_example/src/Player.js +24 -0
  12. data/lib/jasmine-core/example/node_example/src/Song.js +9 -0
  13. data/lib/jasmine-core/jasmine-html.js +104 -73
  14. data/lib/jasmine-core/jasmine.css +58 -54
  15. data/lib/jasmine-core/jasmine.js +368 -254
  16. data/lib/jasmine-core/node_boot.js +93 -0
  17. data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +12 -0
  18. data/lib/jasmine-core/spec/core/AnySpec.js +1 -0
  19. data/lib/jasmine-core/spec/core/ClockSpec.js +103 -17
  20. data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +1 -1
  21. data/lib/jasmine-core/spec/core/EnvSpec.js +14 -14
  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 +34 -0
  25. data/lib/jasmine-core/spec/core/MockDateSpec.js +179 -0
  26. data/lib/jasmine-core/spec/core/ObjectContainingSpec.js +6 -0
  27. data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +41 -10
  28. data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +130 -31
  29. data/lib/jasmine-core/spec/core/SpecSpec.js +27 -88
  30. data/lib/jasmine-core/spec/core/TimerSpec.js +18 -0
  31. data/lib/jasmine-core/spec/core/integration/EnvSpec.js +20 -2
  32. data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +8 -0
  33. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +2 -1
  34. data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +3 -2
  35. data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +2 -1
  36. data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +4 -2
  37. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +2 -1
  38. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +17 -3
  39. data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +11 -11
  40. data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +5 -5
  41. data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +7 -0
  42. data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +33 -0
  43. data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +155 -35
  44. data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +1 -1
  45. data/lib/jasmine-core/spec/performance/large_object_test.js +36 -0
  46. data/lib/jasmine-core/version.rb +1 -1
  47. metadata +34 -23
  48. data/lib/jasmine-core/spec/node_suite.js +0 -187
  49. data/lib/jasmine-core/spec/support/dev_boot.js +0 -124
@@ -0,0 +1,93 @@
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 = {
32
+ describe: function(description, specDefinitions) {
33
+ return env.describe(description, specDefinitions);
34
+ },
35
+
36
+ xdescribe: function(description, specDefinitions) {
37
+ return env.xdescribe(description, specDefinitions);
38
+ },
39
+
40
+ it: function(desc, func) {
41
+ return env.it(desc, func);
42
+ },
43
+
44
+ xit: function(desc, func) {
45
+ return env.xit(desc, func);
46
+ },
47
+
48
+ beforeEach: function(beforeEachFunction) {
49
+ return env.beforeEach(beforeEachFunction);
50
+ },
51
+
52
+ afterEach: function(afterEachFunction) {
53
+ return env.afterEach(afterEachFunction);
54
+ },
55
+
56
+ expect: function(actual) {
57
+ return env.expect(actual);
58
+ },
59
+
60
+ spyOn: function(obj, methodName) {
61
+ return env.spyOn(obj, methodName);
62
+ },
63
+
64
+ jsApiReporter: new jasmine.JsApiReporter({
65
+ timer: new jasmine.Timer()
66
+ }),
67
+
68
+
69
+ jasmine: jasmine
70
+ };
71
+
72
+ extend(global, jasmineInterface);
73
+
74
+ jasmine.addCustomEqualityTester = function(tester) {
75
+ env.addCustomEqualityTester(tester);
76
+ };
77
+
78
+ jasmine.addMatchers = function(matchers) {
79
+ return env.addMatchers(matchers);
80
+ };
81
+
82
+ jasmine.clock = function() {
83
+ return env.clock;
84
+ };
85
+
86
+ function extend(destination, source) {
87
+ for (var property in source) destination[property] = source[property];
88
+ return destination;
89
+ }
90
+
91
+
92
+ return jasmine;
93
+ };
@@ -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({
@@ -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
  });
@@ -5,7 +5,8 @@ describe("Clock", function() {
5
5
  fakeGlobal = { setTimeout: fakeSetTimeout },
6
6
  delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction"]),
7
7
  delayedFn = jasmine.createSpy("delayedFn"),
8
- clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler);
8
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
9
+ clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
9
10
 
10
11
  fakeGlobal.setTimeout(delayedFn, 0);
11
12
 
@@ -26,7 +27,8 @@ describe("Clock", function() {
26
27
  fakeGlobal = { clearTimeout: fakeClearTimeout },
27
28
  delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["removeFunctionWithId"]),
28
29
  delayedFn = jasmine.createSpy("delayedFn"),
29
- clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler);
30
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
31
+ clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
30
32
 
31
33
  fakeGlobal.clearTimeout("foo");
32
34
 
@@ -47,7 +49,8 @@ describe("Clock", function() {
47
49
  fakeGlobal = { setInterval: fakeSetInterval },
48
50
  delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction"]),
49
51
  delayedFn = jasmine.createSpy("delayedFn"),
50
- clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler);
52
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
53
+ clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
51
54
 
52
55
  fakeGlobal.setInterval(delayedFn, 0);
53
56
 
@@ -68,7 +71,8 @@ describe("Clock", function() {
68
71
  fakeGlobal = { clearInterval: fakeClearInterval },
69
72
  delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["removeFunctionWithId"]),
70
73
  delayedFn = jasmine.createSpy("delayedFn"),
71
- clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler);
74
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
75
+ clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
72
76
 
73
77
  fakeGlobal.clearInterval("foo");
74
78
 
@@ -97,7 +101,8 @@ describe("Clock", function() {
97
101
  },
98
102
  delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction", "reset"]),
99
103
  delayedFn = jasmine.createSpy("delayedFn"),
100
- clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler);
104
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
105
+ clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
101
106
 
102
107
  clock.install();
103
108
  clock.uninstall();
@@ -119,7 +124,8 @@ describe("Clock", function() {
119
124
  delayedFunctionScheduler = { scheduleFunction: scheduleFunction },
120
125
  fakeGlobal = { setTimeout: fakeSetTimeout },
121
126
  delayedFn = jasmine.createSpy('delayedFn'),
122
- clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler);
127
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
128
+ clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
123
129
 
124
130
  clock.install();
125
131
  clock.setTimeout(delayedFn, 0, 'a', 'b');
@@ -135,7 +141,8 @@ describe("Clock", function() {
135
141
  delayedFunctionScheduler = {scheduleFunction: scheduleFunction},
136
142
  fakeGlobal = { setTimeout: fakeSetTimeout },
137
143
  delayedFn = jasmine.createSpy('delayedFn'),
138
- clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler),
144
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
145
+ clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate),
139
146
  timeoutId;
140
147
 
141
148
  clock.install();
@@ -149,7 +156,8 @@ describe("Clock", function() {
149
156
  delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['removeFunctionWithId']),
150
157
  fakeGlobal = { setTimeout: fakeClearTimeout },
151
158
  delayedFn = jasmine.createSpy('delayedFn'),
152
- clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler);
159
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
160
+ clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
153
161
 
154
162
  clock.install();
155
163
  clock.clearTimeout(123);
@@ -164,7 +172,8 @@ describe("Clock", function() {
164
172
  delayedFunctionScheduler = {scheduleFunction: scheduleFunction},
165
173
  fakeGlobal = { setInterval: fakeSetInterval },
166
174
  delayedFn = jasmine.createSpy('delayedFn'),
167
- clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler);
175
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
176
+ clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
168
177
 
169
178
  clock.install();
170
179
  clock.setInterval(delayedFn, 0, 'a', 'b');
@@ -180,7 +189,8 @@ describe("Clock", function() {
180
189
  delayedFunctionScheduler = {scheduleFunction: scheduleFunction},
181
190
  fakeGlobal = { setInterval: fakeSetInterval },
182
191
  delayedFn = jasmine.createSpy('delayedFn'),
183
- clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler),
192
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
193
+ clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate),
184
194
  intervalId;
185
195
 
186
196
  clock.install();
@@ -194,7 +204,8 @@ describe("Clock", function() {
194
204
  delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['removeFunctionWithId']),
195
205
  fakeGlobal = { setInterval: clearInterval },
196
206
  delayedFn = jasmine.createSpy('delayedFn'),
197
- clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler);
207
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
208
+ clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
198
209
 
199
210
  clock.install();
200
211
  clock.clearInterval(123);
@@ -220,7 +231,8 @@ describe("Clock", function() {
220
231
  setTimeout: fakeSetTimeout,
221
232
  setInterval: fakeSetInterval
222
233
  },
223
- clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler);
234
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
235
+ clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
224
236
 
225
237
  fakeSetTimeout.apply = null;
226
238
  fakeSetInterval.apply = null;
@@ -249,7 +261,8 @@ describe("Clock (acceptance)", function() {
249
261
  delayedFn3 = jasmine.createSpy('delayedFn3'),
250
262
  recurring1 = jasmine.createSpy('recurring1'),
251
263
  delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
252
- clock = new j$.Clock({setTimeout: setTimeout}, delayedFunctionScheduler);
264
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
265
+ clock = new j$.Clock({setTimeout: setTimeout}, delayedFunctionScheduler, mockDate);
253
266
 
254
267
  clock.install();
255
268
 
@@ -295,7 +308,8 @@ describe("Clock (acceptance)", function() {
295
308
  it("can clear a previously set timeout", function() {
296
309
  var clearedFn = jasmine.createSpy('clearedFn'),
297
310
  delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
298
- clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler),
311
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
312
+ clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler, mockDate),
299
313
  timeoutId;
300
314
 
301
315
  clock.install();
@@ -312,7 +326,8 @@ describe("Clock (acceptance)", function() {
312
326
  it("correctly schedules functions after the Clock has advanced", function() {
313
327
  var delayedFn1 = jasmine.createSpy('delayedFn1'),
314
328
  delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
315
- clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler);
329
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
330
+ clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler, mockDate);
316
331
 
317
332
  clock.install();
318
333
 
@@ -328,7 +343,8 @@ describe("Clock (acceptance)", function() {
328
343
  var delayedFn1 = jasmine.createSpy('delayedFn1'),
329
344
  delayedFn2 = jasmine.createSpy('delayedFn2'),
330
345
  delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
331
- clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler);
346
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
347
+ clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler, mockDate);
332
348
 
333
349
  delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 0); });
334
350
  clock.install();
@@ -346,7 +362,8 @@ describe("Clock (acceptance)", function() {
346
362
  var delayedFn1 = jasmine.createSpy('delayedFn1'),
347
363
  delayedFn2 = jasmine.createSpy('delayedFn2'),
348
364
  delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
349
- clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler);
365
+ mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
366
+ clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler, mockDate);
350
367
 
351
368
  delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 1); });
352
369
  clock.install();
@@ -356,4 +373,73 @@ describe("Clock (acceptance)", function() {
356
373
  expect(delayedFn1).toHaveBeenCalled();
357
374
  expect(delayedFn2).toHaveBeenCalled();
358
375
  });
376
+
377
+ it("does not mock the Date object by default", function() {
378
+ var delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
379
+ global = {Date: Date},
380
+ mockDate = new j$.MockDate(global),
381
+ clock = new j$.Clock({setTimeout: setTimeout}, delayedFunctionScheduler, mockDate);
382
+
383
+ clock.install();
384
+
385
+ expect(global.Date).toEqual(Date);
386
+
387
+ var now = new global.Date().getTime();
388
+
389
+ clock.tick(50);
390
+
391
+ expect(new global.Date().getTime() - now).not.toEqual(50);
392
+ });
393
+
394
+ it("mocks the Date object and sets it to current time", function() {
395
+ var delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
396
+ global = {Date: Date},
397
+ mockDate = new j$.MockDate(global),
398
+ clock = new j$.Clock({setTimeout: setTimeout}, delayedFunctionScheduler, mockDate);
399
+
400
+ clock.install().mockDate();
401
+
402
+ var now = new global.Date().getTime();
403
+
404
+ clock.tick(50);
405
+
406
+ expect(new global.Date().getTime() - now).toEqual(50);
407
+
408
+ var timeoutDate = 0;
409
+ clock.setTimeout(function() {
410
+ timeoutDate = new global.Date().getTime();
411
+ }, 100);
412
+
413
+ clock.tick(100);
414
+
415
+ expect(timeoutDate - now).toEqual(150);
416
+ });
417
+
418
+ it("mocks the Date object and sets it to a given time", function() {
419
+ var delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
420
+ global = {Date: Date},
421
+ mockDate = new j$.MockDate(global),
422
+ clock = new j$.Clock({setTimeout: setTimeout}, delayedFunctionScheduler, mockDate),
423
+ baseTime = new Date(2013, 9, 23);
424
+
425
+
426
+ clock.install().mockDate(baseTime);
427
+
428
+ var now = new global.Date().getTime();
429
+
430
+ expect(now).toEqual(baseTime.getTime());
431
+
432
+ clock.tick(50);
433
+
434
+ expect(new global.Date().getTime()).toEqual(baseTime.getTime() + 50);
435
+
436
+ var timeoutDate = 0;
437
+ clock.setTimeout(function() {
438
+ timeoutDate = new global.Date().getTime();
439
+ }, 100);
440
+
441
+ clock.tick(100);
442
+
443
+ expect(timeoutDate).toEqual(baseTime.getTime() + 150);
444
+ });
359
445
  });
@@ -14,7 +14,7 @@ describe("DelayedFunctionScheduler", function() {
14
14
 
15
15
  it("schedules a string for later execution", function() {
16
16
  var scheduler = new j$.DelayedFunctionScheduler(),
17
- strfn = "horrible = true;";
17
+ strfn = "horrible = true;";
18
18
 
19
19
  scheduler.scheduleFunction(strfn, 0);
20
20
 
@@ -6,20 +6,20 @@ describe("Env", function() {
6
6
  });
7
7
 
8
8
  it('removes all spies when env is executed', function(done) {
9
- originalFoo = function() {},
10
- testObj = {
11
- foo: originalFoo
12
- },
13
- firstSpec = jasmine.createSpy('firstSpec').and.callFake(function() {
14
- env.spyOn(testObj, 'foo');
15
- }),
16
- secondSpec = jasmine.createSpy('secondSpec').and.callFake(function() {
17
- expect(testObj.foo).toBe(originalFoo);
18
- });
19
- env.describe('test suite', function() {
20
- env.it('spec 0', firstSpec);
21
- env.it('spec 1', secondSpec);
22
- });
9
+ var originalFoo = function() {},
10
+ testObj = {
11
+ foo: originalFoo
12
+ },
13
+ firstSpec = jasmine.createSpy('firstSpec').and.callFake(function() {
14
+ env.spyOn(testObj, 'foo');
15
+ }),
16
+ secondSpec = jasmine.createSpy('secondSpec').and.callFake(function() {
17
+ expect(testObj.foo).toBe(originalFoo);
18
+ });
19
+ env.describe('test suite', function() {
20
+ env.it('spec 0', firstSpec);
21
+ env.it('spec 1', secondSpec);
22
+ });
23
23
 
24
24
  var assertions = function() {
25
25
  expect(firstSpec).toHaveBeenCalled();
@@ -35,7 +35,14 @@ describe("ExceptionFormatter", function() {
35
35
  message = exceptionFormatter.message(sampleV8);
36
36
 
37
37
  expect(message).toEqual('A Classic Mistake: you got your foo in my bar');
38
+ });
39
+
40
+ it("formats thrown exceptions that aren't errors", function() {
41
+ var thrown = "crazy error",
42
+ exceptionFormatter = new j$.ExceptionFormatter(),
43
+ message = exceptionFormatter.message(thrown);
38
44
 
45
+ expect(message).toEqual("crazy error thrown");
39
46
  });
40
47
  });
41
48
 
@@ -35,7 +35,7 @@ describe('Exceptions:', function() {
35
35
  env.it('should be a passing test that runs after exceptions are thrown from a async test', secondTest);
36
36
  });
37
37
 
38
- expectations = function() {
38
+ var expectations = function() {
39
39
  expect(secondTest).toHaveBeenCalled();
40
40
  done();
41
41
  };
@@ -55,7 +55,7 @@ describe('Exceptions:', function() {
55
55
  });
56
56
  env.describe("a suite that doesn't throw an exception", secondDescribe);
57
57
 
58
- expectations = function() {
58
+ var expectations = function() {
59
59
  expect(secondDescribe).toHaveBeenCalled();
60
60
  done();
61
61
  };
@@ -193,6 +193,40 @@ describe("Expectation", function() {
193
193
 
194
194
  j$.Expectation.addMatchers(matchers);
195
195
 
196
+ expectation = new j$.Expectation({
197
+ actual: "an actual",
198
+ addExpectationResult: addExpectationResult
199
+ });
200
+
201
+ expectation.toFoo("hello");
202
+
203
+ expect(addExpectationResult).toHaveBeenCalledWith(false, {
204
+ matcherName: "toFoo",
205
+ passed: false,
206
+ expected: "hello",
207
+ actual: "an actual",
208
+ message: "I am a custom message"
209
+ });
210
+ });
211
+
212
+ it("reports a failing result with a custom fail message function to the spec when the comparison fails", function() {
213
+ var matchers = {
214
+ toFoo: function() {
215
+ return {
216
+ compare: function() {
217
+ return {
218
+ pass: false,
219
+ message: function() { return "I am a custom message"; }
220
+ };
221
+ }
222
+ };
223
+ }
224
+ },
225
+ addExpectationResult = jasmine.createSpy("addExpectationResult"),
226
+ expectation;
227
+
228
+ j$.Expectation.addMatchers(matchers);
229
+
196
230
  expectation = new j$.Expectation({
197
231
  matchers: matchers,
198
232
  actual: "an actual",