jasmine-core 2.0.0.rc3 → 2.0.0.rc5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/console/console.js +160 -0
- data/lib/jasmine-core/boot.js +84 -8
- data/lib/jasmine-core/boot/boot.js +84 -8
- data/lib/jasmine-core/jasmine-html.js +6 -3
- data/lib/jasmine-core/jasmine.js +236 -260
- data/lib/jasmine-core/spec/core/AnySpec.js +1 -1
- data/lib/jasmine-core/spec/core/ClockSpec.js +0 -20
- data/lib/jasmine-core/spec/core/CustomMatchersSpec.js +149 -96
- data/lib/jasmine-core/spec/core/EnvSpec.js +7 -39
- data/lib/jasmine-core/spec/core/ExceptionsSpec.js +13 -19
- data/lib/jasmine-core/spec/core/ExpectationSpec.js +74 -1
- data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +0 -1
- data/lib/jasmine-core/spec/core/ObjectContainingSpec.js +1 -1
- data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +28 -20
- data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +1 -1
- data/lib/jasmine-core/spec/core/SpecRunningSpec.js +0 -1
- data/lib/jasmine-core/spec/core/SpecSpec.js +2 -11
- data/lib/jasmine-core/spec/core/SuiteSpec.js +2 -50
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +13 -1
- data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +4 -4
- data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +3 -2
- data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +1 -1
- data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +0 -1
- data/lib/jasmine-core/spec/html/QueryStringSpec.js +1 -1
- data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +1 -1
- data/lib/jasmine-core/spec/node_suite.js +13 -11
- data/lib/jasmine-core/spec/support/dev_boot.js +17 -6
- data/lib/jasmine-core/version.rb +1 -1
- metadata +41 -13
- checksums.yaml +0 -7
@@ -341,24 +341,4 @@ describe("Clock (acceptance)", function() {
|
|
341
341
|
clock.tick();
|
342
342
|
expect(delayedFn2).toHaveBeenCalled();
|
343
343
|
});
|
344
|
-
|
345
|
-
it("calls the global clearTimeout correctly when not installed", function() {
|
346
|
-
var delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['clearTimeout']),
|
347
|
-
global = jasmine.getGlobal(),
|
348
|
-
clock = new j$.Clock(global, delayedFunctionScheduler);
|
349
|
-
|
350
|
-
expect(function() {
|
351
|
-
clock.clearTimeout(123)
|
352
|
-
}).not.toThrow();
|
353
|
-
});
|
354
|
-
|
355
|
-
it("calls the global clearTimeout correctly when not installed", function() {
|
356
|
-
var delayedFunctionScheduler = jasmine.createSpyObj('delayedFunctionScheduler', ['clearTimeout']),
|
357
|
-
global = jasmine.getGlobal(),
|
358
|
-
clock = new j$.Clock(global, delayedFunctionScheduler);
|
359
|
-
|
360
|
-
expect(function() {
|
361
|
-
clock.clearInterval(123)
|
362
|
-
}).not.toThrow();
|
363
|
-
});
|
364
344
|
});
|
@@ -1,96 +1,149 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
1
|
+
describe("Custom Matchers (Integration)", function() {
|
2
|
+
var env;
|
3
|
+
var fakeTimer;
|
4
|
+
|
5
|
+
beforeEach(function() {
|
6
|
+
env = new j$.Env();
|
7
|
+
});
|
8
|
+
|
9
|
+
it("allows adding more matchers local to a spec", function(done) {
|
10
|
+
env.it('spec defining a custom matcher', function() {
|
11
|
+
env.addMatchers({
|
12
|
+
matcherForSpec: function() {
|
13
|
+
return {
|
14
|
+
compare: function(actual, expected) {
|
15
|
+
return { pass: false, message: "matcherForSpec: actual: " + actual + "; expected: " + expected };
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
});
|
20
|
+
|
21
|
+
env.expect("zzz").matcherForSpec("yyy");
|
22
|
+
});
|
23
|
+
|
24
|
+
env.it("spec without custom matcher defined", function() {
|
25
|
+
expect(env.expect("zzz").matcherForSpec).toBeUndefined();
|
26
|
+
});
|
27
|
+
|
28
|
+
var specDoneSpy = jasmine.createSpy("specDoneSpy");
|
29
|
+
var expectations = function() {
|
30
|
+
var firstSpecResult = specDoneSpy.calls.first().args[0];
|
31
|
+
expect(firstSpecResult.status).toEqual("failed");
|
32
|
+
expect(firstSpecResult.failedExpectations[0].message).toEqual("matcherForSpec: actual: zzz; expected: yyy");
|
33
|
+
done();
|
34
|
+
};
|
35
|
+
env.addReporter({ specDone:specDoneSpy, jasmineDone: expectations});
|
36
|
+
|
37
|
+
env.execute();
|
38
|
+
});
|
39
|
+
|
40
|
+
it("passes the spec if the custom matcher passes", function(done) {
|
41
|
+
env.addMatchers({
|
42
|
+
toBeReal: function() {
|
43
|
+
return { compare: function() { return { pass: true }; } };
|
44
|
+
}
|
45
|
+
});
|
46
|
+
|
47
|
+
env.it("spec using custom matcher", function() {
|
48
|
+
env.expect(true).toBeReal();
|
49
|
+
});
|
50
|
+
|
51
|
+
var specExpectations = function(result) {
|
52
|
+
expect(result.status).toEqual('passed');
|
53
|
+
};
|
54
|
+
|
55
|
+
env.addReporter({ specDone: specExpectations, jasmineDone: done });
|
56
|
+
env.execute();
|
57
|
+
});
|
58
|
+
|
59
|
+
it("uses the negative compare function for a negative comparison, if provided", function(done) {
|
60
|
+
env.addMatchers({
|
61
|
+
toBeReal: function() {
|
62
|
+
return {
|
63
|
+
compare: function() { return { pass: true }; },
|
64
|
+
negativeCompare: function() { return { pass: true }; }
|
65
|
+
};
|
66
|
+
}
|
67
|
+
});
|
68
|
+
|
69
|
+
env.it("spec with custom negative comparison matcher", function() {
|
70
|
+
env.expect(true).not.toBeReal();
|
71
|
+
});
|
72
|
+
|
73
|
+
var specExpectations = function(result) {
|
74
|
+
expect(result.status).toEqual('passed');
|
75
|
+
}
|
76
|
+
|
77
|
+
env.addReporter({ specDone: specExpectations, jasmineDone: done });
|
78
|
+
env.execute();
|
79
|
+
});
|
80
|
+
|
81
|
+
it("generates messages with the same rules as built in matchers absent a custom message", function(done) {
|
82
|
+
env.addMatchers({
|
83
|
+
toBeReal: function() {
|
84
|
+
return {
|
85
|
+
compare: function() {
|
86
|
+
return { pass: false };
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
});
|
91
|
+
|
92
|
+
env.it('spec with an expectation', function() {
|
93
|
+
env.expect("a").toBeReal();
|
94
|
+
});
|
95
|
+
|
96
|
+
var specExpectations = function(result) {
|
97
|
+
expect(result.failedExpectations[0].message).toEqual("Expected 'a' to be real.");
|
98
|
+
};
|
99
|
+
|
100
|
+
env.addReporter({ specDone: specExpectations, jasmineDone: done });
|
101
|
+
env.execute();
|
102
|
+
});
|
103
|
+
|
104
|
+
it("passes the expected and actual arguments to the comparison function", function(done) {
|
105
|
+
var argumentSpy = jasmine.createSpy("argument spy").and.returnValue({ pass: true });
|
106
|
+
env.addMatchers({
|
107
|
+
toBeReal: function() {
|
108
|
+
return { compare: argumentSpy };
|
109
|
+
}
|
110
|
+
});
|
111
|
+
|
112
|
+
env.it('spec with an expectation', function () {
|
113
|
+
env.expect(true).toBeReal();
|
114
|
+
env.expect(true).toBeReal("arg");
|
115
|
+
env.expect(true).toBeReal("arg1", "arg2");
|
116
|
+
});
|
117
|
+
|
118
|
+
var specExpectations = function() {
|
119
|
+
expect(argumentSpy).toHaveBeenCalledWith(true);
|
120
|
+
expect(argumentSpy).toHaveBeenCalledWith(true, "arg");
|
121
|
+
expect(argumentSpy).toHaveBeenCalledWith(true, "arg1", "arg2");
|
122
|
+
};
|
123
|
+
|
124
|
+
env.addReporter({ specDone: specExpectations, jasmineDone: done });
|
125
|
+
env.execute();
|
126
|
+
});
|
127
|
+
|
128
|
+
it("passes the jasmine utility and current equality matchers to the expectation factory", function(done) {
|
129
|
+
var matcherFactory = function() { return { compare: function() { return {pass: true}; }}; },
|
130
|
+
argumentSpy = jasmine.createSpy("argument spy").and.returnValue(matcherFactory),
|
131
|
+
customEqualityFn = function() { return true; };
|
132
|
+
|
133
|
+
env.addCustomEqualityTester(customEqualityFn);
|
134
|
+
env.addMatchers({
|
135
|
+
toBeReal: argumentSpy
|
136
|
+
});
|
137
|
+
|
138
|
+
env.it("spec with expectation", function() {
|
139
|
+
env.expect(true).toBeReal();
|
140
|
+
});
|
141
|
+
|
142
|
+
var specExpectations = function() {
|
143
|
+
expect(argumentSpy).toHaveBeenCalledWith(j$.matchersUtil, [customEqualityFn]);
|
144
|
+
};
|
145
|
+
|
146
|
+
env.addReporter({ specDone: specExpectations, jasmineDone: done });
|
147
|
+
env.execute();
|
148
|
+
});
|
149
|
+
});
|
@@ -3,29 +3,6 @@ describe("Env", function() {
|
|
3
3
|
var env;
|
4
4
|
beforeEach(function() {
|
5
5
|
env = new j$.Env();
|
6
|
-
env.updateInterval = 0;
|
7
|
-
});
|
8
|
-
|
9
|
-
describe('ids', function() {
|
10
|
-
it('nextSpecId should return consecutive integers, starting at 0', function() {
|
11
|
-
expect(env.nextSpecId()).toEqual('spec0');
|
12
|
-
expect(env.nextSpecId()).toEqual('spec1');
|
13
|
-
expect(env.nextSpecId()).toEqual('spec2');
|
14
|
-
});
|
15
|
-
});
|
16
|
-
|
17
|
-
describe("reporting", function() {
|
18
|
-
var fakeReporter;
|
19
|
-
|
20
|
-
beforeEach(function() {
|
21
|
-
fakeReporter = jasmine.createSpyObj("fakeReporter", ["jasmineStarted"]);
|
22
|
-
});
|
23
|
-
|
24
|
-
it("should allow reporters to be registered", function() {
|
25
|
-
env.addReporter(fakeReporter);
|
26
|
-
env.reporter.jasmineStarted();
|
27
|
-
expect(fakeReporter.jasmineStarted).toHaveBeenCalled();
|
28
|
-
});
|
29
6
|
});
|
30
7
|
|
31
8
|
it('removes all spies when env is executed', function(done) {
|
@@ -107,21 +84,6 @@ describe("Env", function() {
|
|
107
84
|
});
|
108
85
|
});
|
109
86
|
|
110
|
-
describe("#catchException", function() {
|
111
|
-
it("returns true if the exception is a pending spec exception", function() {
|
112
|
-
env.catchExceptions(false);
|
113
|
-
|
114
|
-
expect(env.catchException(new Error(j$.Spec.pendingSpecExceptionMessage))).toBe(true);
|
115
|
-
});
|
116
|
-
|
117
|
-
it("returns false if the exception is not a pending spec exception and not catching exceptions", function() {
|
118
|
-
env.catchExceptions(false);
|
119
|
-
|
120
|
-
expect(env.catchException(new Error("external error"))).toBe(false);
|
121
|
-
expect(env.catchException(new Error(j$.Spec.pendingSpecExceptionMessage))).toBe(true);
|
122
|
-
});
|
123
|
-
});
|
124
|
-
|
125
87
|
describe("#pending", function() {
|
126
88
|
it("throws the Pending Spec exception", function() {
|
127
89
|
expect(function() {
|
@@ -130,6 +92,12 @@ describe("Env", function() {
|
|
130
92
|
});
|
131
93
|
});
|
132
94
|
|
95
|
+
describe("#topSuite", function() {
|
96
|
+
it("returns the Jasmine top suite for users to traverse the spec tree", function() {
|
97
|
+
var suite = env.topSuite();
|
98
|
+
expect(suite.description).toEqual('Jasmine__TopLevel__Suite');
|
99
|
+
});
|
100
|
+
});
|
133
101
|
});
|
134
102
|
|
135
103
|
// TODO: move these into a separate file
|
@@ -356,6 +324,7 @@ describe("Env integration", function() {
|
|
356
324
|
env.clock.install();
|
357
325
|
env.clock.setTimeout(delayedFunctionForMockClock, 100);
|
358
326
|
env.clock.tick(100);
|
327
|
+
env.clock.uninstall();
|
359
328
|
});
|
360
329
|
env.it("test without mock clock", function() {
|
361
330
|
env.clock.setTimeout(delayedFunctionForGlobalClock, 100);
|
@@ -444,7 +413,6 @@ describe("Env integration", function() {
|
|
444
413
|
});
|
445
414
|
var suiteResult = reporter.suiteStarted.calls.first().args[0];
|
446
415
|
expect(suiteResult.description).toEqual("A Suite");
|
447
|
-
expect(reporter.jasmineDone).toHaveBeenCalled();
|
448
416
|
|
449
417
|
done();
|
450
418
|
});
|
@@ -3,22 +3,20 @@ describe('Exceptions:', function() {
|
|
3
3
|
|
4
4
|
beforeEach(function() {
|
5
5
|
env = new j$.Env();
|
6
|
-
env.updateInterval = 0;
|
7
6
|
});
|
8
7
|
|
9
8
|
describe('with break on exception', function() {
|
10
9
|
it('should not catch the exception', function() {
|
11
10
|
env.catchExceptions(false);
|
12
|
-
|
11
|
+
env.describe('suite for break on exceptions', function() {
|
13
12
|
env.it('should break when an exception is thrown', function() {
|
14
13
|
throw new Error('I should hit a breakpoint!');
|
15
14
|
});
|
16
15
|
});
|
17
|
-
var runner = env.currentRunner();
|
18
16
|
var dont_change = 'I will never change!';
|
19
17
|
|
20
18
|
try {
|
21
|
-
|
19
|
+
env.execute();
|
22
20
|
dont_change = 'oops I changed';
|
23
21
|
}
|
24
22
|
catch (e) {}
|
@@ -29,36 +27,32 @@ describe('Exceptions:', function() {
|
|
29
27
|
|
30
28
|
describe("with catch on exception", function() {
|
31
29
|
it('should handle exceptions thrown, but continue', function() {
|
32
|
-
var
|
33
|
-
|
30
|
+
var secondTest = jasmine.createSpy('second test');
|
31
|
+
env.describe('Suite for handles exceptions', function () {
|
34
32
|
env.it('should be a test that fails because it throws an exception', function() {
|
35
33
|
throw new Error();
|
36
34
|
});
|
37
|
-
env.it('should be a passing test that runs after exceptions are thrown from a async test',
|
38
|
-
ranSecondTest = true;
|
39
|
-
});
|
35
|
+
env.it('should be a passing test that runs after exceptions are thrown from a async test', secondTest);
|
40
36
|
});
|
41
37
|
|
42
|
-
|
43
|
-
expect(
|
38
|
+
env.execute();
|
39
|
+
expect(secondTest).toHaveBeenCalled();
|
44
40
|
});
|
45
41
|
|
46
42
|
it("should handle exceptions thrown directly in top-level describe blocks and continue", function () {
|
47
|
-
var
|
48
|
-
|
43
|
+
var secondDescribe = jasmine.createSpy("second describe");
|
44
|
+
env.describe("a suite that throws an exception", function () {
|
49
45
|
env.it("is a test that should pass", function () {
|
50
46
|
this.expect(true).toEqual(true);
|
51
47
|
});
|
52
48
|
|
53
49
|
throw new Error("top level error");
|
54
50
|
});
|
55
|
-
|
56
|
-
ranSecondDescribe = true;
|
57
|
-
});
|
51
|
+
env.describe("a suite that doesn't throw an exception", secondDescribe);
|
58
52
|
|
59
|
-
|
60
|
-
expect(
|
53
|
+
env.execute();
|
54
|
+
expect(secondDescribe).toHaveBeenCalled();
|
61
55
|
});
|
62
56
|
});
|
63
|
-
|
64
57
|
});
|
58
|
+
|
@@ -317,4 +317,77 @@ describe("Expectation", function() {
|
|
317
317
|
message: "I am a custom message"
|
318
318
|
});
|
319
319
|
});
|
320
|
-
|
320
|
+
|
321
|
+
it("reports a passing result to the spec when the 'not' comparison passes, given a negativeCompare", function() {
|
322
|
+
var matchers = {
|
323
|
+
toFoo: function() {
|
324
|
+
return {
|
325
|
+
compare: function() { return { pass: true }; },
|
326
|
+
negativeCompare: function() { return { pass: true }; }
|
327
|
+
};
|
328
|
+
}
|
329
|
+
},
|
330
|
+
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
331
|
+
actual = "an actual",
|
332
|
+
expectation;
|
333
|
+
|
334
|
+
j$.Expectation.addMatchers(matchers);
|
335
|
+
|
336
|
+
expectation = new j$.Expectation({
|
337
|
+
matchers: matchers,
|
338
|
+
actual: "an actual",
|
339
|
+
addExpectationResult: addExpectationResult,
|
340
|
+
isNot: true
|
341
|
+
});
|
342
|
+
|
343
|
+
expectation.toFoo("hello");
|
344
|
+
|
345
|
+
expect(addExpectationResult).toHaveBeenCalledWith(true, {
|
346
|
+
matcherName: "toFoo",
|
347
|
+
passed: true,
|
348
|
+
expected: "hello",
|
349
|
+
actual: actual,
|
350
|
+
message: ""
|
351
|
+
});
|
352
|
+
});
|
353
|
+
|
354
|
+
it("reports a failing result and a custom fail message to the spec when the 'not' comparison fails, given a negativeCompare", function() {
|
355
|
+
var matchers = {
|
356
|
+
toFoo: function() {
|
357
|
+
return {
|
358
|
+
compare: function() { return { pass: true }; },
|
359
|
+
negativeCompare: function() {
|
360
|
+
return {
|
361
|
+
pass: false,
|
362
|
+
message: "I'm a custom message"
|
363
|
+
};
|
364
|
+
}
|
365
|
+
};
|
366
|
+
}
|
367
|
+
},
|
368
|
+
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
369
|
+
actual = "an actual",
|
370
|
+
expectation;
|
371
|
+
|
372
|
+
j$.Expectation.addMatchers(matchers);
|
373
|
+
|
374
|
+
expectation = new j$.Expectation({
|
375
|
+
matchers: matchers,
|
376
|
+
actual: "an actual",
|
377
|
+
addExpectationResult: addExpectationResult,
|
378
|
+
isNot: true
|
379
|
+
});
|
380
|
+
|
381
|
+
expectation.toFoo("hello");
|
382
|
+
|
383
|
+
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
384
|
+
matcherName: "toFoo",
|
385
|
+
passed: false,
|
386
|
+
expected: "hello",
|
387
|
+
actual: actual,
|
388
|
+
message: "I'm a custom message"
|
389
|
+
});
|
390
|
+
});
|
391
|
+
|
392
|
+
});
|
393
|
+
|