jasmine-core 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -20,6 +20,10 @@ describe("Spec", function() {
20
20
  expect(j$.Spec.isPendingSpecException(e)).toBe(false);
21
21
  });
22
22
 
23
+ it("#isPendingSpecException returns false for thrown values that don't have toString", function() {
24
+ expect(j$.Spec.isPendingSpecException(void 0)).toBe(false);
25
+ });
26
+
23
27
  it("delegates execution to a QueueRunner", function() {
24
28
  var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
25
29
  spec = new j$.Spec({
@@ -171,7 +175,8 @@ describe("Spec", function() {
171
175
  status: 'pending',
172
176
  description: 'with a spec',
173
177
  fullName: 'a suite with a spec',
174
- failedExpectations: []
178
+ failedExpectations: [],
179
+ passedExpectations: []
175
180
  });
176
181
  });
177
182
 
@@ -189,9 +194,9 @@ describe("Spec", function() {
189
194
  expect(done).toHaveBeenCalled();
190
195
  });
191
196
 
192
- it("#status returns passing by default", function() {
193
- var spec = new j$.Spec({fn: jasmine.createSpy("spec body")});
194
- expect(spec.status()).toEqual('passed');
197
+ it("#status returns passing by default", function(){
198
+ var spec = new j$.Spec({ fn: function () {} });
199
+ expect(spec.status()).toBe("passed");
195
200
  });
196
201
 
197
202
  it("#status returns passed if all expectations in the spec have passed", function() {
@@ -207,101 +212,35 @@ describe("Spec", function() {
207
212
  expect(spec.status()).toBe('failed');
208
213
  });
209
214
 
210
- it("can return its full name", function() {
211
- var specNameSpy = jasmine.createSpy('specNameSpy').and.returnValue('expected val');
212
-
213
- var spec = new j$.Spec({
214
- getSpecName: specNameSpy
215
- });
216
-
217
- expect(spec.getFullName()).toBe('expected val');
218
- expect(specNameSpy.calls.mostRecent().args[0].id).toEqual(spec.id);
219
- });
220
-
221
- it("sets a timeout for async functions to keep them from running forever", function() {
222
- var queueRunnerSpy = jasmine.createSpy('queue runner'),
223
- setTimeoutSpy = jasmine.createSpy('setTimeout'),
224
- spec = new j$.Spec({
225
- beforeFns: function() { return [function(done) { }]; },
226
- fn: function(done) { },
227
- afterFns: function() { return [function(done) { }]; },
228
- timer: {
229
- setTimeout: setTimeoutSpy,
230
- clearTimeout: function() {}
231
- },
232
- queueRunnerFactory: queueRunnerSpy
233
- });
234
-
235
- spec.execute();
236
- var fns = queueRunnerSpy.calls.mostRecent().args[0].fns;
237
-
238
- for (var i = 0; i < fns.length; i++) {
239
- fns[i]();
240
- }
241
-
242
- expect(setTimeoutSpy.calls.count()).toEqual(3);
243
- expect(setTimeoutSpy).toHaveBeenCalledWith(jasmine.any(Function), j$.DEFAULT_TIMEOUT_INTERVAL);
244
- });
245
-
246
- it("resets the timeout timer when an async before throws an exception", function() {
247
- var queueRunnerSpy = jasmine.createSpy('queueRunner'),
248
- clearTimeoutSpy = jasmine.createSpy('clear timeout'),
215
+ it("keeps track of passed and failed expectations", function() {
216
+ var resultCallback = jasmine.createSpy('resultCallback'),
249
217
  spec = new j$.Spec({
250
- beforeFns: function() { return [function(done) {}]; },
251
- fn: function() { },
252
- timer: {
253
- setTimeout: function () { return 920; },
254
- clearTimeout: clearTimeoutSpy
255
- },
256
- queueRunnerFactory: queueRunnerSpy
218
+ fn: jasmine.createSpy("spec body"),
219
+ expectationResultFactory: function (data) { return data; },
220
+ queueRunnerFactory: function(attrs) { attrs.onComplete(); },
221
+ resultCallback: resultCallback
257
222
  });
223
+ spec.addExpectationResult(true, 'expectation1');
224
+ spec.addExpectationResult(false, 'expectation2');
258
225
 
259
226
  spec.execute();
260
- queueRunnerSpy.calls.mostRecent().args[0].fns[0]();
261
- queueRunnerSpy.calls.mostRecent().args[0].onException(new Error());
262
227
 
263
- expect(clearTimeoutSpy).toHaveBeenCalledWith(920);
228
+ expect(resultCallback.calls.first().args[0].passedExpectations).toEqual(['expectation1']);
229
+ expect(resultCallback.calls.first().args[0].failedExpectations).toEqual(['expectation2']);
264
230
  });
265
231
 
266
- it("resets the timeout timer when an async spec throws an exception", function() {
267
- var queueRunnerSpy = jasmine.createSpy('queueRunner'),
268
- clearTimeoutSpy = jasmine.createSpy('clear timeout'),
269
- spec = new j$.Spec({
270
- fn: function(done) { },
271
- timer: {
272
- setTimeout: function () { return 920; },
273
- clearTimeout: clearTimeoutSpy
274
- },
275
- queueRunnerFactory: queueRunnerSpy
276
- });
232
+ it("can return its full name", function() {
233
+ var specNameSpy = jasmine.createSpy('specNameSpy').and.returnValue('expected val');
277
234
 
278
- spec.execute();
279
- queueRunnerSpy.calls.mostRecent().args[0].fns[0]();
280
- queueRunnerSpy.calls.mostRecent().args[0].onException(new Error());
235
+ var spec = new j$.Spec({
236
+ getSpecName: specNameSpy
237
+ });
281
238
 
282
- expect(clearTimeoutSpy).toHaveBeenCalledWith(920);
239
+ expect(spec.getFullName()).toBe('expected val');
240
+ expect(specNameSpy.calls.mostRecent().args[0].id).toEqual(spec.id);
283
241
  });
284
242
 
285
- it("resets the timeout timer when an async after spec throws an exception", function() {
286
- var queueRunnerSpy = jasmine.createSpy('queueRunner'),
287
- clearTimeoutSpy = jasmine.createSpy('clear timeout'),
288
- spec = new j$.Spec({
289
- fn: function() { },
290
- afterFns: function() { return [function(done) {}]; },
291
- timer: {
292
- setTimeout: function () { return 920; },
293
- clearTimeout: clearTimeoutSpy
294
- },
295
- queueRunnerFactory: queueRunnerSpy
296
- });
297
-
298
- spec.execute();
299
- queueRunnerSpy.calls.mostRecent().args[0].fns[1]();
300
- queueRunnerSpy.calls.mostRecent().args[0].onException(new Error());
301
-
302
- expect(clearTimeoutSpy).toHaveBeenCalledWith(920);
303
- });
304
- describe("when a spec is marked pending during execution", function() {
243
+ describe("when a spec is marked pending during execution", function() {
305
244
  it("should mark the spec as pending", function() {
306
245
  var fakeQueueRunner = function(opts) {
307
246
  opts.onException(new Error(j$.Spec.pendingSpecExceptionMessage));
@@ -10,4 +10,22 @@ describe("Timer", function() {
10
10
 
11
11
  expect(timer.elapsed()).toEqual(100);
12
12
  });
13
+
14
+ describe("when date is stubbed, perhaps by other testing helpers", function() {
15
+ var origDate = Date;
16
+ beforeEach(function() {
17
+ Date = jasmine.createSpy('date spy');
18
+ });
19
+
20
+ afterEach(function() {
21
+ Date = origDate;
22
+ });
23
+
24
+ it("does not throw even though Date was taken away", function() {
25
+ var timer = new j$.Timer();
26
+
27
+ expect(timer.start).not.toThrow();
28
+ expect(timer.elapsed()).toEqual(jasmine.any(Number));
29
+ });
30
+ });
13
31
  });
@@ -299,10 +299,14 @@ describe("Env integration", function() {
299
299
 
300
300
  it("should wait a specified interval before failing specs haven't called done yet", function(done) {
301
301
  var env = new j$.Env(),
302
- reporter = jasmine.createSpyObj('fakeReporter', [ "specDone" ]);
302
+ reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]);
303
303
 
304
304
  reporter.specDone.and.callFake(function() {
305
305
  expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({status: 'failed'}));
306
+ });
307
+
308
+ reporter.jasmineDone.and.callFake(function() {
309
+ expect(reporter.jasmineDone.calls.count()).toEqual(1);
306
310
  done();
307
311
  });
308
312
 
@@ -311,7 +315,7 @@ describe("Env integration", function() {
311
315
 
312
316
  env.it("async spec that doesn't call done", function(underTestCallback) {
313
317
  env.expect(true).toBeTruthy();
314
- jasmine.getEnv().clock.tick(8415);
318
+ jasmine.getEnv().clock.tick(8416);
315
319
  });
316
320
 
317
321
  env.execute();
@@ -484,5 +488,19 @@ describe("Env integration", function() {
484
488
 
485
489
  env.execute();
486
490
  });
491
+
492
+ it("produces an understandable error message when an 'expect' is used outside of a current spec", function(done) {
493
+ var env = new j$.Env();
494
+
495
+ env.describe("A Suite", function() {
496
+ env.it("an async spec that is actually synchronous", function(underTestCallback) {
497
+ underTestCallback();
498
+ expect(function() { env.expect('a').toEqual('a'); }).toThrowError(/'expect' was used when there was no current spec/);
499
+ done();
500
+ });
501
+ });
502
+
503
+ env.execute();
504
+ });
487
505
  });
488
506
 
@@ -199,6 +199,14 @@ describe("matchersUtil", function() {
199
199
 
200
200
  expect(j$.matchersUtil.contains([1, 2], 2, [customTester])).toBe(true);
201
201
  });
202
+
203
+ it("fails when actual is undefined", function() {
204
+ expect(j$.matchersUtil.contains(undefined, 'A')).toBe(false);
205
+ });
206
+
207
+ it("fails when actual is null", function() {
208
+ expect(j$.matchersUtil.contains(null, 'A')).toBe(false);
209
+ });
202
210
  });
203
211
 
204
212
  describe("buildMessage", function() {
@@ -8,7 +8,8 @@ describe("toBeGreaterThan", function() {
8
8
  });
9
9
 
10
10
  it("fails when actual <= expected", function() {
11
- var matcher = j$.matchers.toBeGreaterThan();
11
+ var matcher = j$.matchers.toBeGreaterThan(),
12
+ result;
12
13
 
13
14
  result = matcher.compare(1, 1);
14
15
  expect(result.pass).toBe(false);
@@ -9,7 +9,8 @@ describe("toBeNaN", function() {
9
9
  });
10
10
 
11
11
  it("fails for anything not a NaN", function() {
12
- var matcher = j$.matchers.toBeNaN();
12
+ var matcher = j$.matchers.toBeNaN(),
13
+ result;
13
14
 
14
15
  result = matcher.compare(1);
15
16
  expect(result.pass).toBe(false);
@@ -31,6 +32,6 @@ describe("toBeNaN", function() {
31
32
  var matcher = j$.matchers.toBeNaN(),
32
33
  result = matcher.compare(0);
33
34
 
34
- expect(result.message).toEqual("Expected 0 to be NaN.");
35
+ expect(result.message()).toEqual("Expected 0 to be NaN.");
35
36
  });
36
37
  });
@@ -9,7 +9,8 @@ describe("toBeUndefined", function() {
9
9
  });
10
10
 
11
11
  it("fails when matching defined values", function() {
12
- var matcher = j$.matchers.toBeUndefined();
12
+ var matcher = j$.matchers.toBeUndefined(),
13
+ result;
13
14
 
14
15
  result = matcher.compare('foo');
15
16
  expect(result.pass).toBe(false);
@@ -3,7 +3,8 @@ describe("toContain", function() {
3
3
  var util = {
4
4
  contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
5
5
  },
6
- matcher = j$.matchers.toContain(util);
6
+ matcher = j$.matchers.toContain(util),
7
+ result;
7
8
 
8
9
  result = matcher.compare("ABC", "B");
9
10
  expect(util.contains).toHaveBeenCalledWith("ABC", "B", []);
@@ -15,7 +16,8 @@ describe("toContain", function() {
15
16
  contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
16
17
  },
17
18
  customEqualityTesters = ['a', 'b'],
18
- matcher = j$.matchers.toContain(util, customEqualityTesters);
19
+ matcher = j$.matchers.toContain(util, customEqualityTesters),
20
+ result;
19
21
 
20
22
  result = matcher.compare("ABC", "B");
21
23
  expect(util.contains).toHaveBeenCalledWith("ABC", "B", ['a', 'b']);
@@ -13,7 +13,8 @@ describe("toHaveBeenCalled", function() {
13
13
 
14
14
  it("fails when the actual was not called", function() {
15
15
  var matcher = j$.matchers.toHaveBeenCalled(),
16
- uncalledSpy = j$.createSpy('uncalled spy');
16
+ uncalledSpy = j$.createSpy('uncalled spy'),
17
+ result;
17
18
 
18
19
  result = matcher.compare(uncalledSpy);
19
20
  expect(result.pass).toBe(false);
@@ -11,7 +11,21 @@ describe("toHaveBeenCalledWith", function() {
11
11
  result = matcher.compare(calledSpy, 'a', 'b');
12
12
 
13
13
  expect(result.pass).toBe(true);
14
- expect(result.message).toEqual("Expected spy called-spy not to have been called with [ 'a', 'b' ] but it was.");
14
+ expect(result.message()).toEqual("Expected spy called-spy not to have been called with [ 'a', 'b' ] but it was.");
15
+ });
16
+
17
+ it("passes through the custom equality testers", function() {
18
+ var util = {
19
+ contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
20
+ },
21
+ customEqualityTesters = [function() { return true; }],
22
+ matcher = j$.matchers.toHaveBeenCalledWith(util, customEqualityTesters),
23
+ calledSpy = j$.createSpy('called-spy');
24
+
25
+ calledSpy('a', 'b');
26
+ matcher.compare(calledSpy, 'a', 'b');
27
+
28
+ expect(util.contains).toHaveBeenCalledWith([['a', 'b']], ['a', 'b'], customEqualityTesters);
15
29
  });
16
30
 
17
31
  it("fails when the actual was not called", function() {
@@ -24,7 +38,7 @@ describe("toHaveBeenCalledWith", function() {
24
38
 
25
39
  result = matcher.compare(uncalledSpy);
26
40
  expect(result.pass).toBe(false);
27
- expect(result.message).toEqual("Expected spy uncalled spy to have been called with [ ] but it was never called.");
41
+ expect(result.message()).toEqual("Expected spy uncalled spy to have been called with [ ] but it was never called.");
28
42
  });
29
43
 
30
44
  it("fails when the actual was called with different parameters", function() {
@@ -40,7 +54,7 @@ describe("toHaveBeenCalledWith", function() {
40
54
  result = matcher.compare(calledSpy, 'a', 'b');
41
55
 
42
56
  expect(result.pass).toBe(false);
43
- expect(result.message).toEqual("Expected spy called spy to have been called with [ 'a', 'b' ] but actual calls were [ 'a' ], [ 'c', 'd' ].");
57
+ expect(result.message()).toEqual("Expected spy called spy to have been called with [ 'a', 'b' ] but actual calls were [ 'a' ], [ 'c', 'd' ].");
44
58
  });
45
59
 
46
60
  it("throws an exception when the actual is not a spy", function() {
@@ -62,7 +62,7 @@ describe("toThrowError", function() {
62
62
 
63
63
  result = matcher.compare(fn);
64
64
  expect(result.pass).toBe(false);
65
- expect(result.message).toEqual("Expected function to throw an Error, but it threw 4.");
65
+ expect(result.message()).toEqual("Expected function to throw an Error, but it threw 4.");
66
66
  });
67
67
 
68
68
  it("fails with the correct message if thrown is a falsy value", function() {
@@ -74,7 +74,7 @@ describe("toThrowError", function() {
74
74
 
75
75
  result = matcher.compare(fn);
76
76
  expect(result.pass).toBe(false);
77
- expect(result.message).toEqual("Expected function to throw an Error, but it threw undefined.");
77
+ expect(result.message()).toEqual("Expected function to throw an Error, but it threw undefined.");
78
78
  });
79
79
 
80
80
  it("passes if thrown is a type of Error, but there is no expected error", function() {
@@ -100,7 +100,7 @@ describe("toThrowError", function() {
100
100
  result = matcher.compare(fn, "foo");
101
101
 
102
102
  expect(result.pass).toBe(true);
103
- expect(result.message).toEqual("Expected function not to throw an exception with message 'foo'.");
103
+ expect(result.message()).toEqual("Expected function not to throw an exception with message 'foo'.");
104
104
  });
105
105
 
106
106
  it("fails if thrown is an Error and the expected is not the same message", function() {
@@ -113,7 +113,7 @@ describe("toThrowError", function() {
113
113
  result = matcher.compare(fn, "bar");
114
114
 
115
115
  expect(result.pass).toBe(false);
116
- expect(result.message).toEqual("Expected function to throw an exception with message 'bar', but it threw an exception with message 'foo'.");
116
+ expect(result.message()).toEqual("Expected function to throw an exception with message 'bar', but it threw an exception with message 'foo'.");
117
117
  });
118
118
 
119
119
  it("passes if thrown is an Error and the expected is a RegExp that matches the message", function() {
@@ -126,7 +126,7 @@ describe("toThrowError", function() {
126
126
  result = matcher.compare(fn, /long/);
127
127
 
128
128
  expect(result.pass).toBe(true);
129
- expect(result.message).toEqual("Expected function not to throw an exception with a message matching /long/.");
129
+ expect(result.message()).toEqual("Expected function not to throw an exception with a message matching /long/.");
130
130
  });
131
131
 
132
132
  it("fails if thrown is an Error and the expected is a RegExp that does not match the message", function() {
@@ -139,7 +139,7 @@ describe("toThrowError", function() {
139
139
  result = matcher.compare(fn, /foo/);
140
140
 
141
141
  expect(result.pass).toBe(false);
142
- expect(result.message).toEqual("Expected function to throw an exception with a message matching /foo/, but it threw an exception with message 'a long message'.");
142
+ expect(result.message()).toEqual("Expected function to throw an exception with a message matching /foo/, but it threw an exception with message 'a long message'.");
143
143
  });
144
144
 
145
145
  it("passes if thrown is an Error and the expected the same Error", function() {
@@ -207,7 +207,7 @@ describe("toThrowError", function() {
207
207
  result = matcher.compare(fn, TypeError, "foo");
208
208
 
209
209
  expect(result.pass).toBe(true);
210
- expect(result.message).toEqual("Expected function not to throw TypeError with message \"foo\".");
210
+ expect(result.message()).toEqual("Expected function not to throw TypeError with message 'foo'.");
211
211
  });
212
212
 
213
213
  it("passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message", function() {
@@ -227,7 +227,7 @@ describe("toThrowError", function() {
227
227
  result = matcher.compare(fn, CustomError, "foo");
228
228
 
229
229
  expect(result.pass).toBe(true);
230
- expect(result.message).toEqual("Expected function not to throw CustomError with message \"foo\".");
230
+ expect(result.message()).toEqual("Expected function not to throw CustomError with message 'foo'.");
231
231
  });
232
232
 
233
233
  it("fails if thrown is a type of Error and the expected is a different Error", function() {
@@ -243,7 +243,7 @@ describe("toThrowError", function() {
243
243
  result = matcher.compare(fn, TypeError, "bar");
244
244
 
245
245
  expect(result.pass).toBe(false);
246
- expect(result.message).toEqual("Expected function to throw TypeError with message \"bar\", but it threw TypeError with message \"foo\".");
246
+ expect(result.message()).toEqual("Expected function to throw TypeError with message 'bar', but it threw TypeError with message 'foo'.");
247
247
  });
248
248
 
249
249
  it("passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message", function() {
@@ -259,7 +259,7 @@ describe("toThrowError", function() {
259
259
  result = matcher.compare(fn, TypeError, /foo/);
260
260
 
261
261
  expect(result.pass).toBe(true);
262
- expect(result.message).toEqual("Expected function not to throw TypeError with message matching /foo/.");
262
+ expect(result.message()).toEqual("Expected function not to throw TypeError with message matching /foo/.");
263
263
  });
264
264
 
265
265
  it("fails if thrown is a type of Error and the expected is a different Error", function() {
@@ -275,6 +275,6 @@ describe("toThrowError", function() {
275
275
  result = matcher.compare(fn, TypeError, /bar/);
276
276
 
277
277
  expect(result.pass).toBe(false);
278
- expect(result.message).toEqual("Expected function to throw TypeError with message matching /bar/, but it threw TypeError with message \"foo\".");
278
+ expect(result.message()).toEqual("Expected function to throw TypeError with message matching /bar/, but it threw TypeError with message 'foo'.");
279
279
  });
280
280
  });
@@ -34,7 +34,7 @@ describe("toThrow", function() {
34
34
  result = matcher.compare(fn);
35
35
 
36
36
  expect(result.pass).toBe(true);
37
- expect(result.message).toEqual("Expected function not to throw, but it threw 5.");
37
+ expect(result.message()).toEqual("Expected function not to throw, but it threw 5.");
38
38
  });
39
39
 
40
40
  it("passes even if what is thrown is falsy", function() {
@@ -46,7 +46,7 @@ describe("toThrow", function() {
46
46
 
47
47
  result = matcher.compare(fn);
48
48
  expect(result.pass).toBe(true);
49
- expect(result.message).toEqual("Expected function not to throw, but it threw undefined.");
49
+ expect(result.message()).toEqual("Expected function not to throw, but it threw undefined.");
50
50
  });
51
51
 
52
52
  it("passes if what is thrown is equivalent to what is expected", function() {
@@ -62,7 +62,7 @@ describe("toThrow", function() {
62
62
  result = matcher.compare(fn, 5);
63
63
 
64
64
  expect(result.pass).toBe(true);
65
- expect(result.message).toEqual("Expected function not to throw 5.");
65
+ expect(result.message()).toEqual("Expected function not to throw 5.");
66
66
  });
67
67
 
68
68
  it("fails if what is thrown is not equivalent to what is expected", function() {
@@ -78,7 +78,7 @@ describe("toThrow", function() {
78
78
  result = matcher.compare(fn, "foo");
79
79
 
80
80
  expect(result.pass).toBe(false);
81
- expect(result.message).toEqual("Expected function to throw 'foo', but it threw 5.");
81
+ expect(result.message()).toEqual("Expected function to throw 'foo', but it threw 5.");
82
82
  });
83
83
 
84
84
  it("fails if what is thrown is not equivalent to undefined", function() {
@@ -94,6 +94,6 @@ describe("toThrow", function() {
94
94
  result = matcher.compare(fn, void 0);
95
95
 
96
96
  expect(result.pass).toBe(false);
97
- expect(result.message).toEqual("Expected function to throw undefined, but it threw 5.");
97
+ expect(result.message()).toEqual("Expected function to throw undefined, but it threw 5.");
98
98
  });
99
99
  });