jasmine 1.0.2.1 → 1.1.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +0 -3
  3. data/README.markdown +7 -1
  4. data/Rakefile +10 -24
  5. data/generators/jasmine/templates/jasmine-example/SpecRunner.html +40 -13
  6. data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +3 -3
  7. data/jasmine.gemspec +18 -8
  8. data/lib/generators/jasmine/templates/lib/tasks/jasmine.rake +8 -2
  9. data/lib/jasmine/base.rb +9 -6
  10. data/lib/jasmine/command_line_tool.rb +1 -1
  11. data/lib/jasmine/firebug/firebug-1.6.2.xpi +0 -0
  12. data/lib/jasmine/firebug/firebug-1.7.0.xpi +0 -0
  13. data/lib/jasmine/firebug/firebug-license.txt +30 -0
  14. data/lib/jasmine/firebug/firebug.rb +30 -0
  15. data/lib/jasmine/selenium_driver.rb +8 -2
  16. data/lib/jasmine/server.rb +4 -7
  17. data/lib/jasmine/tasks/jasmine.rake +15 -6
  18. data/lib/jasmine/version.rb +1 -1
  19. data/spec/fixture/Rakefile +4 -0
  20. data/spec/fixture/spec/example_spec.js +5 -0
  21. data/spec/fixture/src/example.js +3 -0
  22. data/spec/jasmine_command_line_tool_rakeless_spec.rb +20 -0
  23. data/spec/jasmine_rails2_spec.rb +1 -1
  24. data/spec/jasmine_self_test_config.rb +6 -2
  25. data/spec/jasmine_self_test_spec.rb +0 -1
  26. data/spec/server_spec.rb +12 -11
  27. metadata +39 -92
  28. data/.gitmodules +0 -3
  29. data/jasmine/Gemfile +0 -6
  30. data/jasmine/HowToRelease.markdown +0 -29
  31. data/jasmine/MIT.LICENSE +0 -20
  32. data/jasmine/README.markdown +0 -50
  33. data/jasmine/Rakefile +0 -166
  34. data/jasmine/cruise_config.rb +0 -21
  35. data/jasmine/example/SpecRunner.html +0 -27
  36. data/jasmine/example/spec/PlayerSpec.js +0 -58
  37. data/jasmine/example/spec/SpecHelper.js +0 -9
  38. data/jasmine/example/src/Player.js +0 -22
  39. data/jasmine/example/src/Song.js +0 -7
  40. data/jasmine/images/jasmine_favicon.png +0 -0
  41. data/jasmine/jsdoc-template/allclasses.tmpl +0 -17
  42. data/jasmine/jsdoc-template/allfiles.tmpl +0 -56
  43. data/jasmine/jsdoc-template/class.tmpl +0 -646
  44. data/jasmine/jsdoc-template/index.tmpl +0 -39
  45. data/jasmine/jsdoc-template/publish.js +0 -184
  46. data/jasmine/jsdoc-template/static/default.css +0 -162
  47. data/jasmine/jsdoc-template/static/header.html +0 -2
  48. data/jasmine/jsdoc-template/static/index.html +0 -19
  49. data/jasmine/jsdoc-template/symbol.tmpl +0 -35
  50. data/jasmine/jshint/jshint.js +0 -5919
  51. data/jasmine/jshint/run.js +0 -98
  52. data/jasmine/lib/jasmine-html.js +0 -190
  53. data/jasmine/lib/jasmine.css +0 -166
  54. data/jasmine/lib/jasmine.js +0 -2445
  55. data/jasmine/lib/json2.js +0 -478
  56. data/jasmine/spec/node_suite.js +0 -233
  57. data/jasmine/spec/runner.html +0 -82
  58. data/jasmine/spec/suites/BaseSpec.js +0 -27
  59. data/jasmine/spec/suites/CustomMatchersSpec.js +0 -97
  60. data/jasmine/spec/suites/EnvSpec.js +0 -158
  61. data/jasmine/spec/suites/ExceptionsSpec.js +0 -107
  62. data/jasmine/spec/suites/JsApiReporterSpec.js +0 -103
  63. data/jasmine/spec/suites/MatchersSpec.js +0 -795
  64. data/jasmine/spec/suites/MockClockSpec.js +0 -38
  65. data/jasmine/spec/suites/MultiReporterSpec.js +0 -45
  66. data/jasmine/spec/suites/NestedResultsSpec.js +0 -54
  67. data/jasmine/spec/suites/PrettyPrintSpec.js +0 -93
  68. data/jasmine/spec/suites/QueueSpec.js +0 -23
  69. data/jasmine/spec/suites/ReporterSpec.js +0 -56
  70. data/jasmine/spec/suites/RunnerSpec.js +0 -267
  71. data/jasmine/spec/suites/SpecRunningSpec.js +0 -1253
  72. data/jasmine/spec/suites/SpecSpec.js +0 -124
  73. data/jasmine/spec/suites/SpySpec.js +0 -201
  74. data/jasmine/spec/suites/SuiteSpec.js +0 -120
  75. data/jasmine/spec/suites/TrivialConsoleReporterSpec.js +0 -431
  76. data/jasmine/spec/suites/TrivialReporterSpec.js +0 -238
  77. data/jasmine/spec/suites/UtilSpec.js +0 -39
  78. data/jasmine/spec/suites/WaitsForBlockSpec.js +0 -118
  79. data/jasmine/src/Block.js +0 -22
  80. data/jasmine/src/Env.js +0 -264
  81. data/jasmine/src/JsApiReporter.js +0 -102
  82. data/jasmine/src/Matchers.js +0 -354
  83. data/jasmine/src/MultiReporter.js +0 -35
  84. data/jasmine/src/NestedResults.js +0 -80
  85. data/jasmine/src/PrettyPrinter.js +0 -123
  86. data/jasmine/src/Queue.js +0 -99
  87. data/jasmine/src/Reporter.js +0 -31
  88. data/jasmine/src/Runner.js +0 -77
  89. data/jasmine/src/Spec.js +0 -242
  90. data/jasmine/src/Suite.js +0 -82
  91. data/jasmine/src/WaitsBlock.js +0 -15
  92. data/jasmine/src/WaitsForBlock.js +0 -54
  93. data/jasmine/src/base.js +0 -608
  94. data/jasmine/src/console/TrivialConsoleReporter.js +0 -144
  95. data/jasmine/src/html/TrivialReporter.js +0 -190
  96. data/jasmine/src/html/jasmine.css +0 -166
  97. data/jasmine/src/mock-timeout.js +0 -183
  98. data/jasmine/src/util.js +0 -67
  99. data/jasmine/src/version.json +0 -5
@@ -1,124 +0,0 @@
1
- describe('Spec', function () {
2
- var env, suite;
3
- beforeEach(function() {
4
- env = new jasmine.Env();
5
- env.updateInterval = 0;
6
- suite = new jasmine.Suite(env, 'suite 1');
7
- });
8
-
9
- describe('initialization', function () {
10
-
11
- it('should raise an error if an env is not passed', function () {
12
- try {
13
- new jasmine.Spec();
14
- }
15
- catch (e) {
16
- expect(e.message).toEqual('jasmine.Env() required');
17
- }
18
- });
19
-
20
- it('should raise an error if a suite is not passed', function () {
21
- try {
22
- new jasmine.Spec(env);
23
- }
24
- catch (e) {
25
- expect(e.message).toEqual('jasmine.Suite() required');
26
- }
27
- });
28
-
29
- it('should assign sequential ids for specs belonging to the same env', function () {
30
- var spec1 = new jasmine.Spec(env, suite);
31
- var spec2 = new jasmine.Spec(env, suite);
32
- var spec3 = new jasmine.Spec(env, suite);
33
- expect(spec1.id).toEqual(0);
34
- expect(spec2.id).toEqual(1);
35
- expect(spec3.id).toEqual(2);
36
- });
37
- });
38
-
39
- it('getFullName returns suite & spec description', function () {
40
- var spec = new jasmine.Spec(env, suite, 'spec 1');
41
- expect(spec.getFullName()).toEqual('suite 1 spec 1.');
42
- });
43
-
44
- describe('results', function () {
45
- var spec, results;
46
- beforeEach(function () {
47
- spec = new jasmine.Spec(env, suite);
48
- results = spec.results();
49
- expect(results.totalCount).toEqual(0);
50
- spec.runs(function () {
51
- this.expect(true).toEqual(true);
52
- this.expect(true).toEqual(true);
53
- });
54
- });
55
-
56
-
57
- it('results shows the total number of expectations for each spec after execution', function () {
58
- expect(results.totalCount).toEqual(0);
59
- spec.execute();
60
- expect(results.totalCount).toEqual(2);
61
- });
62
-
63
- it('results shows the number of passed expectations for each spec after execution', function () {
64
- expect(results.passedCount).toEqual(0);
65
- spec.execute();
66
- expect(results.passedCount).toEqual(2);
67
- });
68
-
69
- it('results shows the number of failed expectations for each spec after execution', function () {
70
- spec.runs(function () {
71
- this.expect(true).toEqual(false);
72
- });
73
- expect(results.failedCount).toEqual(0);
74
- spec.execute();
75
- expect(results.failedCount).toEqual(1);
76
- });
77
-
78
- describe('results.passed', function () {
79
- it('is true if all spec expectations pass', function () {
80
- spec.runs(function () {
81
- this.expect(true).toEqual(true);
82
- });
83
- spec.execute();
84
- expect(results.passed()).toEqual(true);
85
- });
86
-
87
- it('is false if one spec expectation fails', function () {
88
- spec.runs(function () {
89
- this.expect(true).toEqual(false);
90
- });
91
- spec.execute();
92
- expect(results.passed()).toEqual(false);
93
- });
94
-
95
- it('a spec with no expectations will return true', function () {
96
- var specWithoutExpectations = new jasmine.Spec(env, suite);
97
- specWithoutExpectations.runs(function() {
98
-
99
- });
100
- specWithoutExpectations.execute();
101
- expect(results.passed()).toEqual(true);
102
- });
103
-
104
- it('an unexecuted spec will return true', function () {
105
- expect(results.passed()).toEqual(true);
106
- });
107
- });
108
-
109
- it("includes log messages, which may contain arbitary objects", function() {
110
- spec.runs(function() {
111
- this.log("here's some log message", {key: 'value'}, 123);
112
- });
113
- spec.execute();
114
- var items = results.getItems();
115
- expect(items).toEqual([
116
- jasmine.any(jasmine.ExpectationResult),
117
- jasmine.any(jasmine.ExpectationResult),
118
- jasmine.any(jasmine.MessageResult)
119
- ]);
120
- var logResult = items[2];
121
- expect(logResult.values).toEqual(["here's some log message", {key: 'value'}, 123]);
122
- });
123
- });
124
- });
@@ -1,201 +0,0 @@
1
- describe('Spies', function () {
2
- it('should replace the specified function with a spy object', function() {
3
- var originalFunctionWasCalled = false;
4
- var TestClass = {
5
- someFunction: function() {
6
- originalFunctionWasCalled = true;
7
- }
8
- };
9
- this.spyOn(TestClass, 'someFunction');
10
-
11
- expect(TestClass.someFunction.wasCalled).toEqual(false);
12
- expect(TestClass.someFunction.callCount).toEqual(0);
13
- TestClass.someFunction('foo');
14
- expect(TestClass.someFunction.wasCalled).toEqual(true);
15
- expect(TestClass.someFunction.callCount).toEqual(1);
16
- expect(TestClass.someFunction.mostRecentCall.args).toEqual(['foo']);
17
- expect(TestClass.someFunction.mostRecentCall.object).toEqual(TestClass);
18
- expect(originalFunctionWasCalled).toEqual(false);
19
-
20
- TestClass.someFunction('bar');
21
- expect(TestClass.someFunction.callCount).toEqual(2);
22
- expect(TestClass.someFunction.mostRecentCall.args).toEqual(['bar']);
23
- });
24
-
25
- it('should allow you to view args for a particular call', function() {
26
- var originalFunctionWasCalled = false;
27
- var TestClass = {
28
- someFunction: function() {
29
- originalFunctionWasCalled = true;
30
- }
31
- };
32
- this.spyOn(TestClass, 'someFunction');
33
-
34
- TestClass.someFunction('foo');
35
- TestClass.someFunction('bar');
36
- expect(TestClass.someFunction.calls[0].args).toEqual(['foo']);
37
- expect(TestClass.someFunction.calls[1].args).toEqual(['bar']);
38
- expect(TestClass.someFunction.mostRecentCall.args).toEqual(['bar']);
39
- });
40
-
41
- it('should be possible to call through to the original method, or return a specific result', function() {
42
- var originalFunctionWasCalled = false;
43
- var passedArgs;
44
- var passedObj;
45
- var TestClass = {
46
- someFunction: function() {
47
- originalFunctionWasCalled = true;
48
- passedArgs = arguments;
49
- passedObj = this;
50
- return "return value from original function";
51
- }
52
- };
53
-
54
- this.spyOn(TestClass, 'someFunction').andCallThrough();
55
- var result = TestClass.someFunction('arg1', 'arg2');
56
- expect(result).toEqual("return value from original function");
57
- expect(originalFunctionWasCalled).toEqual(true);
58
- expect(passedArgs).toEqual(['arg1', 'arg2']);
59
- expect(passedObj).toEqual(TestClass);
60
- expect(TestClass.someFunction.wasCalled).toEqual(true);
61
- });
62
-
63
- it('should be possible to return a specific value', function() {
64
- var originalFunctionWasCalled = false;
65
- var TestClass = {
66
- someFunction: function() {
67
- originalFunctionWasCalled = true;
68
- return "return value from original function";
69
- }
70
- };
71
-
72
- this.spyOn(TestClass, 'someFunction').andReturn("some value");
73
- originalFunctionWasCalled = false;
74
- var result = TestClass.someFunction('arg1', 'arg2');
75
- expect(result).toEqual("some value");
76
- expect(originalFunctionWasCalled).toEqual(false);
77
- });
78
-
79
- it('should be possible to throw a specific error', function() {
80
- var originalFunctionWasCalled = false;
81
- var TestClass = {
82
- someFunction: function() {
83
- originalFunctionWasCalled = true;
84
- return "return value from original function";
85
- }
86
- };
87
-
88
- this.spyOn(TestClass, 'someFunction').andThrow(new Error('fake error'));
89
- var exception;
90
- try {
91
- TestClass.someFunction('arg1', 'arg2');
92
- } catch (e) {
93
- exception = e;
94
- }
95
- expect(exception.message).toEqual('fake error');
96
- expect(originalFunctionWasCalled).toEqual(false);
97
- });
98
-
99
- it('should be possible to call a specified function', function() {
100
- var originalFunctionWasCalled = false;
101
- var fakeFunctionWasCalled = false;
102
- var passedArgs;
103
- var passedObj;
104
- var TestClass = {
105
- someFunction: function() {
106
- originalFunctionWasCalled = true;
107
- return "return value from original function";
108
- }
109
- };
110
-
111
- this.spyOn(TestClass, 'someFunction').andCallFake(function() {
112
- fakeFunctionWasCalled = true;
113
- passedArgs = arguments;
114
- passedObj = this;
115
- return "return value from fake function";
116
- });
117
-
118
- var result = TestClass.someFunction('arg1', 'arg2');
119
- expect(result).toEqual("return value from fake function");
120
- expect(originalFunctionWasCalled).toEqual(false);
121
- expect(fakeFunctionWasCalled).toEqual(true);
122
- expect(passedArgs).toEqual(['arg1', 'arg2']);
123
- expect(passedObj).toEqual(TestClass);
124
- expect(TestClass.someFunction.wasCalled).toEqual(true);
125
- });
126
-
127
- it('is torn down when this.removeAllSpies is called', function() {
128
- var originalFunctionWasCalled = false;
129
- var TestClass = {
130
- someFunction: function() {
131
- originalFunctionWasCalled = true;
132
- }
133
- };
134
- this.spyOn(TestClass, 'someFunction');
135
-
136
- TestClass.someFunction('foo');
137
- expect(originalFunctionWasCalled).toEqual(false);
138
-
139
- this.removeAllSpies();
140
-
141
- TestClass.someFunction('foo');
142
- expect(originalFunctionWasCalled).toEqual(true);
143
- });
144
-
145
- it('calls removeAllSpies during spec finish', function() {
146
- var test = new jasmine.Spec(new jasmine.Env(), {}, 'sample test');
147
-
148
- this.spyOn(test, 'removeAllSpies');
149
-
150
- test.finish();
151
-
152
- expect(test.removeAllSpies).wasCalled();
153
- });
154
-
155
- it('throws an exception when some method is spied on twice', function() {
156
- var TestClass = { someFunction: function() {
157
- } };
158
- this.spyOn(TestClass, 'someFunction');
159
- var exception;
160
- try {
161
- this.spyOn(TestClass, 'someFunction');
162
- } catch (e) {
163
- exception = e;
164
- }
165
- expect(exception).toBeDefined();
166
- });
167
-
168
- it('should be able to reset a spy', function() {
169
- var TestClass = { someFunction: function() {} };
170
- this.spyOn(TestClass, 'someFunction');
171
-
172
- expect(TestClass.someFunction).not.toHaveBeenCalled();
173
- TestClass.someFunction();
174
- expect(TestClass.someFunction).toHaveBeenCalled();
175
- TestClass.someFunction.reset();
176
- expect(TestClass.someFunction).not.toHaveBeenCalled();
177
- expect(TestClass.someFunction.callCount).toEqual(0);
178
- });
179
-
180
- describe("createSpyObj", function() {
181
- it("should create an object with a bunch of spy methods when you call jasmine.createSpyObj()", function() {
182
- var spyObj = jasmine.createSpyObj('BaseName', ['method1', 'method2']);
183
- expect(spyObj).toEqual({ method1: jasmine.any(Function), method2: jasmine.any(Function)});
184
- expect(spyObj.method1.identity).toEqual('BaseName.method1');
185
- expect(spyObj.method2.identity).toEqual('BaseName.method2');
186
- });
187
-
188
- it("should throw if you do not pass an array argument", function() {
189
- expect(function() {
190
- jasmine.createSpyObj('BaseName');
191
- }).toThrow('createSpyObj requires a non-empty array of method names to create spies for');
192
- });
193
-
194
- it("should throw if you pass an empty array argument", function() {
195
- expect(function() {
196
- jasmine.createSpyObj('BaseName');
197
- }).toThrow('createSpyObj requires a non-empty array of method names to create spies for');
198
- });
199
- });
200
-
201
- });
@@ -1,120 +0,0 @@
1
- describe('Suite', 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('Specs', function () {
17
- var suite;
18
-
19
- beforeEach(function() {
20
- suite = env.describe('Suite 1', function () {
21
- env.it('Spec 1', function() {
22
- this.runs(function () {
23
- this.expect(true).toEqual(true);
24
- });
25
- });
26
- env.it('Spec 2', function() {
27
- this.runs(function () {
28
- this.expect(true).toEqual(true);
29
- });
30
- });
31
- env.describe('Suite 2', function () {
32
- env.it('Spec 3', function() {
33
- this.runs(function () {
34
- this.expect(true).toEqual(true);
35
- });
36
- });
37
- });
38
- env.it('Spec 4', function() {
39
- this.runs(function () {
40
- this.expect(true).toEqual(true);
41
- });
42
- });
43
- });
44
- });
45
-
46
- it('#specs should return all immediate children that are specs.', function () {
47
- var suiteSpecs = suite.specs();
48
- expect(suiteSpecs.length).toEqual(3);
49
- expect(suiteSpecs[0].description).toEqual('Spec 1');
50
- expect(suiteSpecs[1].description).toEqual('Spec 2');
51
- expect(suiteSpecs[2].description).toEqual('Spec 4');
52
- });
53
-
54
- it("#suites should return all immediate children that are suites.", function() {
55
- var nestedSuites = suite.suites();
56
- expect(nestedSuites.length).toEqual(1);
57
- expect(nestedSuites[0].description).toEqual('Suite 2');
58
- });
59
-
60
- it("#children should return all immediate children including suites and specs.", function() {
61
- var children = suite.children();
62
- expect(children.length).toEqual(4);
63
- expect(children[0].description).toEqual('Spec 1');
64
- expect(children[1].description).toEqual('Spec 2');
65
- expect(children[2].description).toEqual('Suite 2');
66
- expect(children[3].description).toEqual('Spec 4');
67
- });
68
- });
69
-
70
- describe('SpecCount', function () {
71
-
72
- it('should keep a count of the number of specs that are run', function() {
73
- var suite = env.describe('one suite description', function () {
74
- env.it('should be a test', function() {
75
- this.runs(function () {
76
- this.expect(true).toEqual(true);
77
- });
78
- });
79
- env.it('should be another test', function() {
80
- this.runs(function () {
81
- this.expect(true).toEqual(true);
82
- });
83
- });
84
- env.it('should be a third test', function() {
85
- this.runs(function () {
86
- this.expect(true).toEqual(true);
87
- });
88
- });
89
- });
90
-
91
- expect(suite.specs().length).toEqual(3);
92
- });
93
-
94
- it('specCount should be correct even with runs/waits blocks', function() {
95
- var suite = env.describe('one suite description', function () {
96
- env.it('should be a test', function() {
97
- this.runs(function () {
98
- this.expect(true).toEqual(true);
99
- });
100
- });
101
- env.it('should be another test', function() {
102
- this.runs(function () {
103
- this.expect(true).toEqual(true);
104
- });
105
- this.waits(10);
106
- this.runs(function () {
107
- this.expect(true).toEqual(true);
108
- });
109
- });
110
- env.it('should be a third test', function() {
111
- this.runs(function () {
112
- this.expect(true).toEqual(true);
113
- });
114
- });
115
- });
116
-
117
- expect(suite.specs().length).toEqual(3);
118
- });
119
- });
120
- });
@@ -1,431 +0,0 @@
1
- if (jasmine.TrivialConsoleReporter) {
2
- describe("TrivialConsoleReporter", function() {
3
-
4
-
5
- //keep these literal. otherwise the test loses value as a test.
6
- function green(str) { return '\033[32m' + str + '\033[0m'; }
7
- function red(str) { return '\033[31m' + str + '\033[0m'; }
8
- function yellow(str) { return '\033[33m' + str + '\033[0m'; }
9
-
10
- function prefixGreen(str) { return '\033[32m' + str; }
11
- function prefixRed(str) { return '\033[31m' + str; }
12
-
13
- var newline = "\n";
14
-
15
- var passingSpec = { results: function(){ return {passed: function(){return true;}}; } },
16
- failingSpec = { results: function(){ return {passed: function(){return false;}}; } },
17
- skippedSpec = { results: function(){ return {skipped: true}; } },
18
- passingRun = { results: function(){ return {failedCount: 0, items_: [null, null, null]}; } },
19
- failingRun = { results: function(){ return {failedCount: 7, items_: [null, null, null]}; } };
20
-
21
- function repeatedlyInvoke(f, times) { for(var i=0; i<times; i++) f(times+1); }
22
-
23
- function repeat(thing, times) {
24
- var arr = [];
25
- for(var i=0; i<times; i++) arr.push(thing);
26
- return arr;
27
- }
28
-
29
- var fiftyRedFs = repeat(red("F"), 50).join(""),
30
- fiftyGreenDots = repeat(green("."), 50).join("");
31
-
32
- function simulateRun(reporter, specResults, suiteResults, finalRunner, startTime, endTime) {
33
- reporter.reportRunnerStarting();
34
- for(var i=0; i<specResults.length; i++) reporter.reportSpecResults(specResults[i]);
35
- for(i=0; i<suiteResults.length; i++) reporter.reportSuiteResults(suiteResults[i]);
36
- reporter.runnerStartTime = startTime;
37
- reporter.now = function(){return endTime;};
38
- reporter.reportRunnerResults(finalRunner);
39
- }
40
-
41
- beforeEach(function() {
42
- this.out = (function(){
43
- var output = "";
44
- return {
45
- print:function(str) {output += str;},
46
- getOutput:function(){return output;},
47
- clear: function(){output = "";}
48
- };
49
- })();
50
-
51
- this.done = false
52
- var self = this
53
- this.reporter = new jasmine.TrivialConsoleReporter(this.out.print, function(runner){
54
- self.done = true
55
- });
56
- });
57
-
58
-
59
- describe('Integration', function(){
60
- it("prints the proper output under a pass scenario. small numbers.", function(){
61
- simulateRun(this.reporter,
62
- repeat(passingSpec, 3),
63
- [],
64
- {
65
- results:function(){
66
- return {
67
- items_: [null, null, null],
68
- totalCount: 7,
69
- failedCount: 0
70
- };
71
- }
72
- },
73
- 1000,
74
- 1777);
75
-
76
- expect(this.out.getOutput()).toEqual(
77
- [
78
- "Started",
79
- green(".") + green(".") + green("."),
80
- "",
81
- "Finished in 0.777 seconds",
82
- green("3 specs, 7 expectations, 0 failures"),
83
- ""
84
- ].join("\n") + "\n"
85
- );
86
- });
87
-
88
- it("prints the proper output under a pass scenario. large numbers.", function(){
89
- simulateRun(this.reporter,
90
- repeat(passingSpec, 57),
91
- [],
92
- {
93
- results:function(){
94
- return {
95
- items_: [null, null, null],
96
- totalCount: 7,
97
- failedCount: 0
98
- };
99
- }
100
- },
101
- 1000,
102
- 1777);
103
-
104
- expect(this.out.getOutput()).toEqual(
105
- [
106
- "Started",
107
-
108
- green(".") + green(".") + green(".") + green(".") + green(".") + //50 green dots
109
- green(".") + green(".") + green(".") + green(".") + green(".") +
110
- green(".") + green(".") + green(".") + green(".") + green(".") +
111
- green(".") + green(".") + green(".") + green(".") + green(".") +
112
- green(".") + green(".") + green(".") + green(".") + green(".") +
113
- green(".") + green(".") + green(".") + green(".") + green(".") +
114
- green(".") + green(".") + green(".") + green(".") + green(".") +
115
- green(".") + green(".") + green(".") + green(".") + green(".") +
116
- green(".") + green(".") + green(".") + green(".") + green(".") +
117
- green(".") + green(".") + green(".") + green(".") + green(".") + newline +
118
-
119
- green(".") + green(".") + green(".") + green(".") + green(".") + //7 green dots
120
- green(".") + green("."),
121
-
122
- "",
123
- "Finished in 0.777 seconds",
124
- green("3 specs, 7 expectations, 0 failures"),
125
- ""
126
- ].join("\n") + "\n"
127
- );
128
- });
129
-
130
-
131
- it("prints the proper output under a failure scenario.", function(){
132
- simulateRun(this.reporter,
133
- [failingSpec, passingSpec, failingSpec],
134
- [{description:"The oven",
135
- results:function(){
136
- return {
137
- items_:[
138
- {failedCount:2,
139
- description:"heats up",
140
- items_:[
141
- {trace:{stack:"stack trace one\n second line"}},
142
- {trace:{stack:"stack trace two"}}
143
- ]}
144
- ]
145
- };
146
- }},
147
- {description:"The washing machine",
148
- results:function(){
149
- return {
150
- items_:[
151
- {failedCount:2,
152
- description:"washes clothes",
153
- items_:[
154
- {trace:{stack:"stack trace one"}}
155
- ]}
156
- ]
157
- };
158
- }}
159
- ],
160
- {
161
- results:function(){
162
- return {
163
- items_: [null, null, null],
164
- totalCount: 7,
165
- failedCount: 2
166
- };
167
- }
168
- },
169
- 1000,
170
- 1777);
171
-
172
- expect(this.out.getOutput()).toEqual(
173
- [
174
- "Started",
175
- red("F") + green(".") + red("F"),
176
- "",
177
- "The oven heats up",
178
- " stack trace one",
179
- " second line",
180
- " stack trace two",
181
- "",
182
- "The washing machine washes clothes",
183
- " stack trace one",
184
- "",
185
- "Finished in 0.777 seconds",
186
- red("3 specs, 7 expectations, 2 failures"),
187
- ""
188
- ].join("\n") + "\n"
189
- );
190
- });
191
-
192
-
193
- });
194
-
195
- describe('A Test Run', function(){
196
-
197
- describe('Starts', function(){
198
- it("prints Started", function(){
199
- this.reporter.reportRunnerStarting();
200
-
201
- expect(this.out.getOutput()).toEqual(
202
- "Started" + newline
203
- );
204
- });
205
- });
206
-
207
- describe('A spec runs', function(){
208
- it("prints a green dot if the spec passes", function(){
209
- this.reporter.reportSpecResults(passingSpec);
210
-
211
- expect(this.out.getOutput()).toEqual(
212
- green(".")
213
- );
214
- });
215
-
216
- it("prints a red dot if the spec fails", function(){
217
- this.reporter.reportSpecResults(failingSpec);
218
-
219
- expect(this.out.getOutput()).toEqual(
220
- red("F")
221
- );
222
- });
223
-
224
- it("prints a yellow star if the spec was skipped", function(){
225
- this.reporter.reportSpecResults(skippedSpec);
226
-
227
- expect(this.out.getOutput()).toEqual(
228
- yellow("*")
229
- );
230
- });
231
- });
232
-
233
-
234
- describe('Many specs run', function(){
235
- it("starts a new line every 50 specs", function(){
236
- var self = this;
237
- repeatedlyInvoke(function(){self.reporter.reportSpecResults(failingSpec);}, 49);
238
-
239
- expect(this.out.getOutput()).
240
- toEqual(repeat(red("F"), 49).join(""));
241
-
242
- repeatedlyInvoke(function(){self.reporter.reportSpecResults(failingSpec);}, 3);
243
-
244
- expect(this.out.getOutput()).
245
- toEqual(fiftyRedFs + newline +
246
- red("F") + red("F"));
247
-
248
- repeatedlyInvoke(function(){self.reporter.reportSpecResults(failingSpec);}, 48);
249
- repeatedlyInvoke(function(){self.reporter.reportSpecResults(passingSpec);}, 2);
250
-
251
- expect(this.out.getOutput()).
252
- toEqual(fiftyRedFs + newline +
253
- fiftyRedFs + newline +
254
- green(".") + green("."));
255
- });
256
- });
257
-
258
- describe('A suite runs', function(){
259
- it("remembers suite results", function(){
260
- var emptyResults = function(){return {items_:[]};};
261
- this.reporter.reportSuiteResults({description:"Oven", results:emptyResults});
262
- this.reporter.reportSuiteResults({description:"Mixer", results:emptyResults});
263
-
264
- var self = this;
265
- var descriptions = [];
266
- for(var i=0; i<self.reporter.suiteResults.length; i++)
267
- descriptions.push(self.reporter.suiteResults[i].description);
268
-
269
- expect(descriptions).toEqual(["Oven", "Mixer"]);
270
- });
271
-
272
- it("creates a description out of the current suite and any parent suites", function(){
273
- var emptyResults = function(){return {items_:[]};};
274
- var grandparentSuite = {description:"My house", results:emptyResults};
275
- var parentSuite = {description:"kitchen", parentSuite: grandparentSuite, results:emptyResults};
276
- this.reporter.reportSuiteResults({description:"oven", parentSuite: parentSuite, results:emptyResults});
277
-
278
- expect(this.reporter.suiteResults[0].description).toEqual("My house kitchen oven");
279
- });
280
-
281
- it("gathers failing spec results from the suite. the spec must have a description.", function(){
282
- this.reporter.reportSuiteResults({description:"Oven",
283
- results:function(){
284
- return {
285
- items_:[
286
- {failedCount:0, description:"specOne"},
287
- {failedCount:99, description:"specTwo"},
288
- {failedCount:0, description:"specThree"},
289
- {failedCount:88, description:"specFour"},
290
- {failedCount:3}
291
- ]
292
- };
293
- }});
294
-
295
- expect(this.reporter.suiteResults[0].failedSpecResults).
296
- toEqual([
297
- {failedCount:99, description:"specTwo"},
298
- {failedCount:88, description:"specFour"}
299
- ]);
300
- });
301
-
302
- });
303
-
304
- describe('Finishes', function(){
305
-
306
- describe('Spec failure information', function(){
307
-
308
- it("prints suite and spec descriptions together as a sentence", function(){
309
- this.reporter.suiteResults = [
310
- {description:"The oven", failedSpecResults:[
311
- {description:"heats up", items_:[]},
312
- {description:"cleans itself", items_:[]}
313
- ]},
314
- {description:"The mixer", failedSpecResults:[
315
- {description:"blends things together", items_:[]}
316
- ]}
317
- ];
318
-
319
- this.reporter.reportRunnerResults(failingRun);
320
-
321
- expect(this.out.getOutput()).toContain("The oven heats up");
322
- expect(this.out.getOutput()).toContain("The oven cleans itself");
323
- expect(this.out.getOutput()).toContain("The mixer blends things together");
324
- });
325
-
326
- it("prints stack trace of spec failure", function(){
327
- this.reporter.suiteResults = [
328
- {description:"The oven", failedSpecResults:[
329
- {description:"heats up",
330
- items_:[
331
- {trace:{stack:"stack trace one"}},
332
- {trace:{stack:"stack trace two"}}
333
- ]}
334
- ]}
335
- ];
336
-
337
- this.reporter.reportRunnerResults(failingRun);
338
-
339
- expect(this.out.getOutput()).toContain("The oven heats up");
340
- expect(this.out.getOutput()).toContain("stack trace one");
341
- expect(this.out.getOutput()).toContain("stack trace two");
342
- });
343
-
344
- });
345
-
346
- describe('Finished line', function(){
347
-
348
- it("prints the elapsed time in the summary message", function(){
349
- this.reporter.now = function(){return 1000;};
350
- this.reporter.reportRunnerStarting();
351
- this.reporter.now = function(){return 1777;};
352
- this.reporter.reportRunnerResults(passingRun);
353
- expect(this.out.getOutput()).toContain("0.777 seconds");
354
- });
355
-
356
- it("prints round time numbers correctly", function(){
357
- var self = this;
358
- function run(startTime, endTime) {
359
- self.out.clear();
360
- self.reporter.runnerStartTime = startTime;
361
- self.reporter.now = function(){return endTime;};
362
- self.reporter.reportRunnerResults(passingRun);
363
- }
364
-
365
- run(1000, 11000);
366
- expect(this.out.getOutput()).toContain("10 seconds");
367
-
368
- run(1000, 2000);
369
- expect(this.out.getOutput()).toContain("1 seconds");
370
-
371
- run(1000, 1100);
372
- expect(this.out.getOutput()).toContain("0.1 seconds");
373
-
374
- run(1000, 1010);
375
- expect(this.out.getOutput()).toContain("0.01 seconds");
376
-
377
- run(1000, 1001);
378
- expect(this.out.getOutput()).toContain("0.001 seconds");
379
- });
380
-
381
- it("prints the full finished message", function(){
382
- this.reporter.now = function(){return 1000;};
383
- this.reporter.reportRunnerStarting();
384
- this.reporter.now = function(){return 1777;};
385
- this.reporter.reportRunnerResults(failingRun);
386
- expect(this.out.getOutput()).toContain("Finished in 0.777 seconds");
387
- });
388
- });
389
-
390
- describe("specs/expectations/failures summary", function(){
391
- it("prints statistics in green if there were no failures", function() {
392
- this.reporter.reportRunnerResults({
393
- results:function(){return {items_: [null, null, null], totalCount: 7, failedCount: 0};}
394
- });
395
- expect(this.out.getOutput()).
396
- toContain("3 specs, 7 expectations, 0 failures");
397
- });
398
-
399
- it("prints statistics in red if there was a failure", function() {
400
- this.reporter.reportRunnerResults({
401
- results:function(){return {items_: [null, null, null], totalCount: 7, failedCount: 3};}
402
- });
403
- expect(this.out.getOutput()).
404
- toContain("3 specs, 7 expectations, 3 failures");
405
- });
406
-
407
- it("handles pluralization with 1's ones appropriately", function() {
408
- this.reporter.reportRunnerResults({
409
- results:function(){return {items_: [null], totalCount: 1, failedCount: 1};}
410
- });
411
- expect(this.out.getOutput()).
412
- toContain("1 spec, 1 expectation, 1 failure");
413
- });
414
- });
415
-
416
- describe("done callback", function(){
417
- it("calls back when done", function() {
418
- expect(this.done).toBeFalsy();
419
- this.reporter.reportRunnerResults({
420
- results:function(){return {items_: [null, null, null], totalCount: 7, failedCount: 0};}
421
- });
422
- expect(this.done).toBeTruthy();
423
- });
424
- });
425
-
426
- });
427
-
428
- });
429
-
430
- });
431
- }