jasmine-core 1.3.1 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/lib/jasmine-core.rb +14 -1
  2. data/lib/jasmine-core/boot.js +131 -0
  3. data/lib/jasmine-core/boot/boot.js +109 -0
  4. data/lib/jasmine-core/example/spec/PlayerSpec.js +2 -2
  5. data/lib/jasmine-core/example/spec/SpecHelper.js +14 -8
  6. data/lib/jasmine-core/jasmine-html.js +289 -616
  7. data/lib/jasmine-core/jasmine.css +52 -80
  8. data/lib/jasmine-core/jasmine.js +1972 -2211
  9. data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +161 -386
  10. data/lib/jasmine-core/spec/core/AnySpec.js +45 -0
  11. data/lib/jasmine-core/spec/core/CallTrackerSpec.js +105 -0
  12. data/lib/jasmine-core/spec/core/ClockSpec.js +314 -0
  13. data/lib/jasmine-core/spec/core/CustomMatchersSpec.js +96 -97
  14. data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +179 -0
  15. data/lib/jasmine-core/spec/core/EnvSpec.js +454 -102
  16. data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +56 -0
  17. data/lib/jasmine-core/spec/core/ExceptionsSpec.js +15 -126
  18. data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +61 -0
  19. data/lib/jasmine-core/spec/core/ExpectationSpec.js +320 -0
  20. data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +150 -38
  21. data/lib/jasmine-core/spec/core/ObjectContainingSpec.js +64 -0
  22. data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +43 -42
  23. data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +147 -0
  24. data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +40 -0
  25. data/lib/jasmine-core/spec/core/SpecRunningSpec.js +92 -1075
  26. data/lib/jasmine-core/spec/core/SpecSpec.js +215 -95
  27. data/lib/jasmine-core/spec/core/SpySpec.js +28 -196
  28. data/lib/jasmine-core/spec/core/SpyStrategySpec.js +101 -0
  29. data/lib/jasmine-core/spec/core/SuiteSpec.js +216 -106
  30. data/lib/jasmine-core/spec/core/TimerSpec.js +13 -0
  31. data/lib/jasmine-core/spec/core/UtilSpec.js +19 -30
  32. data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +219 -0
  33. data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +51 -0
  34. data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +18 -0
  35. data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +38 -0
  36. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +19 -0
  37. data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +20 -0
  38. data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +36 -0
  39. data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +17 -0
  40. data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +17 -0
  41. data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +38 -0
  42. data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +17 -0
  43. data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +24 -0
  44. data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +28 -0
  45. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +46 -0
  46. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +57 -0
  47. data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +34 -0
  48. data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +280 -0
  49. data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +98 -0
  50. data/lib/jasmine-core/spec/helpers/BrowserFlags.js +19 -0
  51. data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +494 -0
  52. data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +18 -0
  53. data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +8 -8
  54. data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +3 -3
  55. data/lib/jasmine-core/spec/html/QueryStringSpec.js +43 -0
  56. data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +62 -0
  57. data/lib/jasmine-core/spec/node_suite.js +137 -79
  58. data/lib/jasmine-core/spec/performance/performance_test.js +10 -0
  59. data/lib/jasmine-core/spec/support/dev_boot.js +118 -0
  60. data/lib/jasmine-core/version.rb +5 -2
  61. metadata +47 -103
  62. data/lib/jasmine-core/example/SpecRunner.html +0 -54
  63. data/lib/jasmine-core/spec/core/BaseSpec.js +0 -27
  64. data/lib/jasmine-core/spec/core/MatchersSpec.js +0 -1157
  65. data/lib/jasmine-core/spec/core/MockClockSpec.js +0 -38
  66. data/lib/jasmine-core/spec/core/MultiReporterSpec.js +0 -45
  67. data/lib/jasmine-core/spec/core/NestedResultsSpec.js +0 -54
  68. data/lib/jasmine-core/spec/core/QueueSpec.js +0 -23
  69. data/lib/jasmine-core/spec/core/ReporterSpec.js +0 -56
  70. data/lib/jasmine-core/spec/core/RunnerSpec.js +0 -280
  71. data/lib/jasmine-core/spec/core/WaitsForBlockSpec.js +0 -118
  72. data/lib/jasmine-core/spec/html/HTMLReporterSpec.js +0 -209
  73. data/lib/jasmine-core/spec/html/TrivialReporterSpec.js +0 -239
@@ -1,38 +0,0 @@
1
- describe("MockClock", function () {
2
-
3
- beforeEach(function() {
4
- jasmine.Clock.useMock();
5
- });
6
-
7
- describe("setTimeout", function () {
8
- it("should mock the clock when useMock is in a beforeEach", function() {
9
- var expected = false;
10
- setTimeout(function() {
11
- expected = true;
12
- }, 30000);
13
- expect(expected).toBe(false);
14
- jasmine.Clock.tick(30001);
15
- expect(expected).toBe(true);
16
- });
17
- });
18
-
19
- describe("setInterval", function () {
20
- it("should mock the clock when useMock is in a beforeEach", function() {
21
- var interval = 0;
22
- setInterval(function() {
23
- interval++;
24
- }, 30000);
25
- expect(interval).toEqual(0);
26
- jasmine.Clock.tick(30001);
27
- expect(interval).toEqual(1);
28
- jasmine.Clock.tick(30001);
29
- expect(interval).toEqual(2);
30
- jasmine.Clock.tick(1);
31
- expect(interval).toEqual(2);
32
- });
33
- });
34
-
35
- it("shouldn't complain if you call jasmine.Clock.useMock() more than once", function() {
36
- jasmine.Clock.useMock();
37
- });
38
- });
@@ -1,45 +0,0 @@
1
- describe("jasmine.MultiReporter", function() {
2
- var multiReporter, fakeReporter1, fakeReporter2;
3
-
4
- beforeEach(function() {
5
- multiReporter = new jasmine.MultiReporter();
6
- fakeReporter1 = jasmine.createSpyObj("fakeReporter1", ["reportSpecResults"]);
7
- fakeReporter2 = jasmine.createSpyObj("fakeReporter2", ["reportSpecResults", "reportRunnerStarting"]);
8
- multiReporter.addReporter(fakeReporter1);
9
- multiReporter.addReporter(fakeReporter2);
10
- });
11
-
12
- it("should support all the method calls that jasmine.Reporter supports", function() {
13
- var delegate = {};
14
- multiReporter.addReporter(delegate);
15
-
16
- this.addMatchers({
17
- toDelegateMethod: function(methodName) {
18
- delegate[methodName] = jasmine.createSpy(methodName);
19
- this.actual[methodName]("whatever argument");
20
-
21
- return delegate[methodName].wasCalled &&
22
- delegate[methodName].mostRecentCall.args.length == 1 &&
23
- delegate[methodName].mostRecentCall.args[0] == "whatever argument";
24
- }
25
- });
26
-
27
- expect(multiReporter).toDelegateMethod('reportRunnerStarting');
28
- expect(multiReporter).toDelegateMethod('reportRunnerResults');
29
- expect(multiReporter).toDelegateMethod('reportSuiteResults');
30
- expect(multiReporter).toDelegateMethod('reportSpecStarting');
31
- expect(multiReporter).toDelegateMethod('reportSpecResults');
32
- expect(multiReporter).toDelegateMethod('log');
33
- });
34
-
35
- it("should delegate to any and all subreporters", function() {
36
- multiReporter.reportSpecResults('blah', 'foo');
37
- expect(fakeReporter1.reportSpecResults).toHaveBeenCalledWith('blah', 'foo');
38
- expect(fakeReporter2.reportSpecResults).toHaveBeenCalledWith('blah', 'foo');
39
- });
40
-
41
- it("should quietly skip delegating to any subreporters which lack the given method", function() {
42
- multiReporter.reportRunnerStarting('blah', 'foo');
43
- expect(fakeReporter2.reportRunnerStarting).toHaveBeenCalledWith('blah', 'foo');
44
- });
45
- });
@@ -1,54 +0,0 @@
1
- describe('jasmine.NestedResults', function() {
2
- it('#addResult increments counters', function() {
3
- // Leaf case
4
- var results = new jasmine.NestedResults();
5
-
6
- results.addResult(new jasmine.ExpectationResult({
7
- matcherName: "foo", passed: true, message: 'Passed.', actual: 'bar', expected: 'bar'}
8
- ));
9
-
10
- expect(results.getItems().length).toEqual(1);
11
- expect(results.totalCount).toEqual(1);
12
- expect(results.passedCount).toEqual(1);
13
- expect(results.failedCount).toEqual(0);
14
-
15
- results.addResult(new jasmine.ExpectationResult({
16
- matcherName: "baz", passed: false, message: 'FAIL.', actual: "corge", expected: "quux"
17
- }));
18
-
19
- expect(results.getItems().length).toEqual(2);
20
- expect(results.totalCount).toEqual(2);
21
- expect(results.passedCount).toEqual(1);
22
- expect(results.failedCount).toEqual(1);
23
- });
24
-
25
- it('should roll up counts for nested results', function() {
26
- // Branch case
27
- var leafResultsOne = new jasmine.NestedResults();
28
- leafResultsOne.addResult(new jasmine.ExpectationResult({
29
- matcherName: "toSomething", passed: true, message: 'message', actual: '', expected:''
30
- }));
31
-
32
- leafResultsOne.addResult(new jasmine.ExpectationResult({
33
- matcherName: "toSomethingElse", passed: false, message: 'message', actual: 'a', expected: 'b'
34
- }));
35
-
36
- var leafResultsTwo = new jasmine.NestedResults();
37
- leafResultsTwo.addResult(new jasmine.ExpectationResult({
38
- matcherName: "toSomething", passed: true, message: 'message', actual: '', expected: ''
39
- }));
40
- leafResultsTwo.addResult(new jasmine.ExpectationResult({
41
- matcherName: "toSomethineElse", passed: false, message: 'message', actual: 'c', expected: 'd'
42
- }));
43
-
44
- var branchResults = new jasmine.NestedResults();
45
- branchResults.addResult(leafResultsOne);
46
- branchResults.addResult(leafResultsTwo);
47
-
48
- expect(branchResults.getItems().length).toEqual(2);
49
- expect(branchResults.totalCount).toEqual(4);
50
- expect(branchResults.passedCount).toEqual(2);
51
- expect(branchResults.failedCount).toEqual(2);
52
- });
53
-
54
- });
@@ -1,23 +0,0 @@
1
- describe("jasmine.Queue", function() {
2
- it("should not call itself recursively, so we don't get stack overflow errors", function() {
3
- var queue = new jasmine.Queue(new jasmine.Env());
4
- queue.add(new jasmine.Block(null, function() {}));
5
- queue.add(new jasmine.Block(null, function() {}));
6
- queue.add(new jasmine.Block(null, function() {}));
7
- queue.add(new jasmine.Block(null, function() {}));
8
-
9
- var nestCount = 0;
10
- var maxNestCount = 0;
11
- var nextCallCount = 0;
12
- queue.next_ = function() {
13
- nestCount++;
14
- if (nestCount > maxNestCount) maxNestCount = nestCount;
15
-
16
- jasmine.Queue.prototype.next_.apply(queue, arguments);
17
- nestCount--;
18
- };
19
-
20
- queue.start();
21
- expect(maxNestCount).toEqual(1);
22
- });
23
- });
@@ -1,56 +0,0 @@
1
- describe('jasmine.Reporter', function() {
2
- var env;
3
-
4
-
5
- beforeEach(function() {
6
- env = new jasmine.Env();
7
- env.updateInterval = 0;
8
- });
9
-
10
- it('should get called from the test runner', function() {
11
- env.describe('Suite for JSON Reporter with Callbacks', function () {
12
- env.it('should be a test', function() {
13
- this.runs(function () {
14
- this.expect(true).toEqual(true);
15
- });
16
- });
17
- env.it('should be a failing test', function() {
18
- this.runs(function () {
19
- this.expect(false).toEqual(true);
20
- });
21
- });
22
- });
23
- env.describe('Suite for JSON Reporter with Callbacks 2', function () {
24
- env.it('should be a test', function() {
25
- this.runs(function () {
26
- this.expect(true).toEqual(true);
27
- });
28
- });
29
-
30
- });
31
-
32
- var foo = 0;
33
- var bar = 0;
34
- var baz = 0;
35
-
36
- env.addReporter({
37
- reportSpecResults: function() {
38
- foo++;
39
- },
40
- reportSuiteResults: function() {
41
- bar++;
42
- },
43
- reportRunnerResults: function() {
44
- baz++;
45
- }
46
- });
47
-
48
- var runner = env.currentRunner();
49
- runner.execute();
50
-
51
- expect(foo).toEqual(3); // 'foo was expected to be 3, was ' + foo);
52
- expect(bar).toEqual(2); // 'bar was expected to be 2, was ' + bar);
53
- expect(baz).toEqual(1); // 'baz was expected to be 1, was ' + baz);
54
- });
55
-
56
- });
@@ -1,280 +0,0 @@
1
- describe('RunnerTest', function() {
2
- var fakeTimer;
3
- var env;
4
-
5
- beforeEach(function() {
6
- env = new jasmine.Env();
7
- env.updateInterval = 0;
8
-
9
- fakeTimer = new jasmine.FakeTimer();
10
- env.setTimeout = fakeTimer.setTimeout;
11
- env.clearTimeout = fakeTimer.clearTimeout;
12
- env.setInterval = fakeTimer.setInterval;
13
- env.clearInterval = fakeTimer.clearInterval;
14
- });
15
-
16
- describe('beforeEach', function() {
17
- it('should run before each spec for all suites', function () {
18
- var foo;
19
- env.beforeEach(function () {
20
- foo = 0;
21
- });
22
-
23
- env.describe('suite 1', function () {
24
- env.it('test 1-1', function() {
25
- foo++;
26
- this.expect(foo).toEqual(1);
27
- });
28
- env.it('test 1-2', function() {
29
- foo++;
30
- this.expect(foo).toEqual(1);
31
- });
32
- });
33
-
34
- env.describe('suite 2', function () {
35
- env.it('test 2-1', function() {
36
- foo++;
37
- this.expect(foo).toEqual(1);
38
- });
39
- });
40
-
41
- env.currentRunner().execute();
42
-
43
- var runnerResults = env.currentRunner().results();
44
- expect(runnerResults.totalCount).toEqual(3);
45
- expect(runnerResults.passedCount).toEqual(3);
46
- });
47
-
48
-
49
- it('should provide all specs', function () {
50
- var foo;
51
- env.beforeEach(function () {
52
- foo = 0;
53
- });
54
-
55
- env.describe('suite 1', function () {
56
- env.it('test 1-1', function() {
57
- foo++;
58
- this.expect(foo).toEqual(1);
59
- });
60
- env.it('test 1-2', function() {
61
- foo++;
62
- this.expect(foo).toEqual(1);
63
- });
64
- });
65
-
66
- env.describe('suite 2', function () {
67
- env.it('test 2-1', function() {
68
- foo++;
69
- this.expect(foo).toEqual(1);
70
- });
71
- });
72
-
73
- env.currentRunner().execute();
74
-
75
-
76
- expect(env.currentRunner().specs().length).toEqual(3);
77
- });
78
- });
79
-
80
- describe('afterEach', function() {
81
- it('should run after each spec for all suites', function () {
82
- var foo = 3;
83
- env.afterEach(function () {
84
- foo = foo - 1;
85
- });
86
-
87
- env.describe('suite 1', function () {
88
- env.it('test 1-1', function() {
89
- this.expect(foo).toEqual(3);
90
- });
91
- env.it('test 1-2', function() {
92
- this.expect(foo).toEqual(2);
93
- });
94
- });
95
-
96
- env.describe('suite 2', function () {
97
- env.it('test 2-1', function() {
98
- this.expect(foo).toEqual(1);
99
- });
100
- });
101
-
102
- env.currentRunner().execute();
103
-
104
- var runnerResults = env.currentRunner().results();
105
- expect(runnerResults.totalCount).toEqual(3);
106
- expect(runnerResults.passedCount).toEqual(3);
107
- });
108
-
109
- it('should run after a failing spec', function () {
110
- var afterEach = jasmine.createSpy();
111
- env.afterEach(afterEach);
112
-
113
- env.describe('suite', function () {
114
- env.it('fails', function () {
115
- this.explodes();
116
- });
117
- }).execute();
118
-
119
- expect(afterEach).toHaveBeenCalled();
120
- });
121
- });
122
-
123
-
124
- it('should run child suites and specs and generate results when execute is called', function() {
125
- env.describe('one suite description', function () {
126
- env.it('should be a test', function() {
127
- this.runs(function () {
128
- this.expect(true).toEqual(true);
129
- });
130
- });
131
- });
132
-
133
- env.describe('another suite description', function () {
134
- env.it('should be another test', function() {
135
- this.runs(function () {
136
- this.expect(true).toEqual(false);
137
- });
138
- });
139
- });
140
-
141
- env.currentRunner().execute();
142
-
143
- var runnerResults = env.currentRunner().results();
144
- expect(runnerResults.totalCount).toEqual(2);
145
- expect(runnerResults.passedCount).toEqual(1);
146
- expect(runnerResults.failedCount).toEqual(1);
147
- });
148
-
149
-
150
- it('should ignore suites that have been x\'d', function() {
151
- env.xdescribe('one suite description', function () {
152
- env.it('should be a test', function() {
153
- this.runs(function () {
154
- this.expect(true).toEqual(true);
155
- });
156
- });
157
- });
158
-
159
- env.describe('another suite description', function () {
160
- env.it('should be another test', function() {
161
- this.runs(function () {
162
- this.expect(true).toEqual(false);
163
- });
164
- });
165
- });
166
-
167
- env.currentRunner().execute();
168
-
169
- var runnerResults = env.currentRunner().results();
170
- expect(runnerResults.totalCount).toEqual(1);
171
- expect(runnerResults.passedCount).toEqual(0);
172
- expect(runnerResults.failedCount).toEqual(1);
173
- });
174
-
175
- it('should roll up results from all specs', function() {
176
- env.describe('one suite description', function () {
177
- env.it('should be a test', function() {
178
- this.runs(function () {
179
- this.expect(true).toEqual(true);
180
- });
181
- });
182
- });
183
-
184
- env.describe('another suite description', function () {
185
- env.it('should be another test', function() {
186
- this.runs(function () {
187
- this.expect(true).toEqual(false);
188
- });
189
- });
190
- });
191
-
192
- env.currentRunner().execute();
193
-
194
- var results = env.currentRunner().results();
195
- expect(results.totalCount).toEqual(2);
196
- expect(results.passedCount).toEqual(1);
197
- expect(results.failedCount).toEqual(1);
198
- });
199
-
200
- describe('reporting', function () {
201
- var fakeReporter;
202
- beforeEach(function () {
203
- fakeReporter = jasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting", "reportRunnerResults"]);
204
- env.addReporter(fakeReporter);
205
- });
206
-
207
- it('should report runner results when the runner has completed running', function() {
208
- env.describe('one suite description', function () {
209
- env.it('should be a test', function() {
210
- this.runs(function () {
211
- this.expect(true).toEqual(true);
212
- });
213
- });
214
- });
215
-
216
- env.describe('another suite description', function () {
217
- env.it('should be another test', function() {
218
- this.waits(200);
219
- this.runs(function () {
220
- this.expect(true).toEqual(false);
221
- });
222
- });
223
- });
224
-
225
- env.currentRunner().execute();
226
- expect(fakeReporter.reportRunnerResults).not.toHaveBeenCalled();
227
- fakeTimer.tick(200);
228
- //This blows up the JSApiReporter.
229
- //expect(fakeReporter.reportRunnerResults).toHaveBeenCalledWith(env.currentRunner);
230
- expect(fakeReporter.reportRunnerResults).toHaveBeenCalled();
231
- expect(fakeReporter.reportRunnerResults.mostRecentCall.args[0].results()).toEqual(env.currentRunner().results());
232
- });
233
- });
234
-
235
- it("should report when the tests start running", function() {
236
- var fakeReporter = jasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting"]);
237
- env.addReporter(fakeReporter);
238
-
239
-
240
- var runner = new jasmine.Runner(env);
241
- runner.arbitraryVariable = 'foo';
242
- spyOn(runner.queue, 'start');
243
- expect(fakeReporter.reportRunnerStarting).not.toHaveBeenCalled();
244
- runner.execute();
245
- expect(fakeReporter.reportRunnerStarting).toHaveBeenCalled();
246
- var reportedRunner = fakeReporter.reportRunnerStarting.mostRecentCall.args[0];
247
- expect(reportedRunner.arbitraryVariable).toEqual('foo');
248
- expect(runner.queue.start).toHaveBeenCalled();
249
- });
250
-
251
- describe("when suites are nested", function() {
252
- var suite1, suite2, suite3;
253
-
254
- function suiteNames(suites) {
255
- var suiteDescriptions = [];
256
- for (var i = 0; i < suites.length; i++) {
257
- suiteDescriptions.push(suites[i].getFullName());
258
- }
259
- return suiteDescriptions;
260
- }
261
-
262
- beforeEach(function() {
263
- suite1 = env.describe("suite 1", function() {
264
- suite2 = env.describe("suite 2", function() {
265
- });
266
- });
267
- suite3 = env.describe("suite 3", function() {});
268
- });
269
-
270
- it("#suites should return a flat array of all suites, including nested suites", function() {
271
- var suites = env.currentRunner().suites();
272
- expect(suiteNames(suites)).toEqual([suite1.getFullName(), suite2.getFullName(), suite3.getFullName()]);
273
- });
274
-
275
- it("#topLevelSuites should return a flat array of all top-level suites only", function() {
276
- var suites = env.currentRunner().topLevelSuites();
277
- expect(suiteNames(suites)).toEqual([suite1.getFullName(), suite3.getFullName()]);
278
- });
279
- });
280
- });