jazrb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +134 -0
  3. data/bin/autojaz +4 -0
  4. data/bin/jazrb +230 -0
  5. data/doc/jasmine/files.html +460 -0
  6. data/doc/jasmine/index.html +322 -0
  7. data/doc/jasmine/symbols/_global_.html +1083 -0
  8. data/doc/jasmine/symbols/jasmine.Block.html +417 -0
  9. data/doc/jasmine/symbols/jasmine.Clock.html +678 -0
  10. data/doc/jasmine/symbols/jasmine.Env.html +1135 -0
  11. data/doc/jasmine/symbols/jasmine.EnvjsReporter.html +328 -0
  12. data/doc/jasmine/symbols/jasmine.JsApiReporter.html +822 -0
  13. data/doc/jasmine/symbols/jasmine.Matchers.html +1106 -0
  14. data/doc/jasmine/symbols/jasmine.MultiReporter.html +394 -0
  15. data/doc/jasmine/symbols/jasmine.NestedResults.html +710 -0
  16. data/doc/jasmine/symbols/jasmine.Reporter.html +574 -0
  17. data/doc/jasmine/symbols/jasmine.Runner.html +710 -0
  18. data/doc/jasmine/symbols/jasmine.Spec.html +1372 -0
  19. data/doc/jasmine/symbols/jasmine.Spy.html +855 -0
  20. data/doc/jasmine/symbols/jasmine.Suite.html +705 -0
  21. data/doc/jasmine/symbols/jasmine.XMLReporter.html +328 -0
  22. data/doc/jasmine/symbols/jasmine.html +1359 -0
  23. data/doc/jasmine/symbols/jasmine.util.html +535 -0
  24. data/doc/jasmine/symbols/src/lib_EnvjsReporter.js.html +149 -0
  25. data/doc/jasmine/symbols/src/lib_TrivialReporter.js.html +127 -0
  26. data/doc/jasmine/symbols/src/lib_XMLReporter.js.html +210 -0
  27. data/doc/jasmine/symbols/src/src_Block.js.html +35 -0
  28. data/doc/jasmine/symbols/src/src_Env.js.html +233 -0
  29. data/doc/jasmine/symbols/src/src_JsApiReporter.js.html +110 -0
  30. data/doc/jasmine/symbols/src/src_Matchers.js.html +399 -0
  31. data/doc/jasmine/symbols/src/src_MultiReporter.js.html +36 -0
  32. data/doc/jasmine/symbols/src/src_NestedResults.js.html +88 -0
  33. data/doc/jasmine/symbols/src/src_PrettyPrinter.js.html +128 -0
  34. data/doc/jasmine/symbols/src/src_Queue.js.html +119 -0
  35. data/doc/jasmine/symbols/src/src_Reporter.js.html +35 -0
  36. data/doc/jasmine/symbols/src/src_Reporters.js.html +51 -0
  37. data/doc/jasmine/symbols/src/src_Runner.js.html +75 -0
  38. data/doc/jasmine/symbols/src/src_Spec.js.html +228 -0
  39. data/doc/jasmine/symbols/src/src_Suite.js.html +77 -0
  40. data/doc/jasmine/symbols/src/src_WaitsBlock.js.html +21 -0
  41. data/doc/jasmine/symbols/src/src_WaitsForBlock.js.html +45 -0
  42. data/doc/jasmine/symbols/src/src_base.js.html +566 -0
  43. data/doc/jasmine/symbols/src/src_mock-timeout.js.html +185 -0
  44. data/doc/jasmine/symbols/src/src_util.js.html +75 -0
  45. data/lib/autotest/discover.rb +3 -0
  46. data/lib/autotest/jazrb.rb +55 -0
  47. data/lib/jazrb/intro.js +46 -0
  48. data/lib/jazrb/jasmine/EnvjsReporter.js +141 -0
  49. data/lib/jazrb/jasmine/TrivialReporter.js +155 -0
  50. data/lib/jazrb/jasmine/XMLReporter.js +241 -0
  51. data/lib/jazrb/jasmine/consolex.js +28 -0
  52. data/lib/jazrb/jasmine/jasmine-0.10.0.js +2526 -0
  53. data/lib/jazrb/jasmine/jasmine.js +2526 -0
  54. data/lib/jazrb/jasmine/json2.js +478 -0
  55. data/lib/jazrb/options.rb +26 -0
  56. data/lib/jazrb/outro.js +3 -0
  57. data/lib/jazrb/qintro.js +113 -0
  58. data/lib/jazrb/qoutro.js +3 -0
  59. data/lib/jazrb/qunit/qunit.css +17 -0
  60. data/lib/jazrb/qunit/qunit.js +1027 -0
  61. data/lib/jazrb.rb +0 -0
  62. data/spec/example/hello_world_spec.js +29 -0
  63. data/spec/example/nested/HelloWorldSpec.js +13 -0
  64. data/spec/example/nested/SpecHelper.js +1 -0
  65. data/spec/example/plain_spec.js +8 -0
  66. data/spec/example/spec_helper.js +1 -0
  67. data/spec/spec_helper.js +18 -0
  68. data/spec/spec_runner.js +143 -0
  69. data/test/jazrb_test.rb +7 -0
  70. data/test/test_helper.rb +10 -0
  71. data/vendor/jasmine/MIT.LICENSE +20 -0
  72. data/vendor/jasmine/README.markdown +479 -0
  73. data/vendor/jasmine/Rakefile +155 -0
  74. data/vendor/jasmine/contrib/ruby/jasmine_runner.rb +334 -0
  75. data/vendor/jasmine/contrib/ruby/jasmine_spec_builder.rb +153 -0
  76. data/vendor/jasmine/contrib/ruby/run.html +47 -0
  77. data/vendor/jasmine/contrib/ruby/spec/jasmine_runner_spec.rb +71 -0
  78. data/vendor/jasmine/doc/files.html +460 -0
  79. data/vendor/jasmine/doc/index.html +322 -0
  80. data/vendor/jasmine/doc/symbols/_global_.html +1083 -0
  81. data/vendor/jasmine/doc/symbols/jasmine.Block.html +417 -0
  82. data/vendor/jasmine/doc/symbols/jasmine.Clock.html +678 -0
  83. data/vendor/jasmine/doc/symbols/jasmine.Env.html +1135 -0
  84. data/vendor/jasmine/doc/symbols/jasmine.EnvjsReporter.html +328 -0
  85. data/vendor/jasmine/doc/symbols/jasmine.JsApiReporter.html +822 -0
  86. data/vendor/jasmine/doc/symbols/jasmine.Matchers.html +1106 -0
  87. data/vendor/jasmine/doc/symbols/jasmine.MultiReporter.html +394 -0
  88. data/vendor/jasmine/doc/symbols/jasmine.NestedResults.html +710 -0
  89. data/vendor/jasmine/doc/symbols/jasmine.Reporter.html +574 -0
  90. data/vendor/jasmine/doc/symbols/jasmine.Runner.html +710 -0
  91. data/vendor/jasmine/doc/symbols/jasmine.Spec.html +1372 -0
  92. data/vendor/jasmine/doc/symbols/jasmine.Spy.html +855 -0
  93. data/vendor/jasmine/doc/symbols/jasmine.Suite.html +705 -0
  94. data/vendor/jasmine/doc/symbols/jasmine.XMLReporter.html +328 -0
  95. data/vendor/jasmine/doc/symbols/jasmine.html +1359 -0
  96. data/vendor/jasmine/doc/symbols/jasmine.util.html +535 -0
  97. data/vendor/jasmine/doc/symbols/src/lib_EnvjsReporter.js.html +149 -0
  98. data/vendor/jasmine/doc/symbols/src/lib_TrivialReporter.js.html +127 -0
  99. data/vendor/jasmine/doc/symbols/src/lib_XMLReporter.js.html +210 -0
  100. data/vendor/jasmine/doc/symbols/src/src_Block.js.html +35 -0
  101. data/vendor/jasmine/doc/symbols/src/src_Env.js.html +233 -0
  102. data/vendor/jasmine/doc/symbols/src/src_JsApiReporter.js.html +110 -0
  103. data/vendor/jasmine/doc/symbols/src/src_Matchers.js.html +399 -0
  104. data/vendor/jasmine/doc/symbols/src/src_MultiReporter.js.html +36 -0
  105. data/vendor/jasmine/doc/symbols/src/src_NestedResults.js.html +88 -0
  106. data/vendor/jasmine/doc/symbols/src/src_PrettyPrinter.js.html +128 -0
  107. data/vendor/jasmine/doc/symbols/src/src_Queue.js.html +119 -0
  108. data/vendor/jasmine/doc/symbols/src/src_Reporter.js.html +35 -0
  109. data/vendor/jasmine/doc/symbols/src/src_Reporters.js.html +51 -0
  110. data/vendor/jasmine/doc/symbols/src/src_Runner.js.html +75 -0
  111. data/vendor/jasmine/doc/symbols/src/src_Spec.js.html +228 -0
  112. data/vendor/jasmine/doc/symbols/src/src_Suite.js.html +77 -0
  113. data/vendor/jasmine/doc/symbols/src/src_WaitsBlock.js.html +21 -0
  114. data/vendor/jasmine/doc/symbols/src/src_WaitsForBlock.js.html +45 -0
  115. data/vendor/jasmine/doc/symbols/src/src_base.js.html +566 -0
  116. data/vendor/jasmine/doc/symbols/src/src_mock-timeout.js.html +185 -0
  117. data/vendor/jasmine/doc/symbols/src/src_util.js.html +75 -0
  118. data/vendor/jasmine/examples/html/example_suite.html +27 -0
  119. data/vendor/jasmine/examples/html/spec/example_suite.js +11 -0
  120. data/vendor/jasmine/examples/ruby/Rakefile +33 -0
  121. data/vendor/jasmine/examples/ruby/spec/example/example_spec.js +11 -0
  122. data/vendor/jasmine/examples/ruby/spec/jasmine_helper.rb +41 -0
  123. data/vendor/jasmine/examples/ruby/spec/jasmine_spec.rb +31 -0
  124. data/vendor/jasmine/examples/ruby/spec/saucelabs.yml +24 -0
  125. data/vendor/jasmine/geminstaller.yml +23 -0
  126. data/vendor/jasmine/images/fail-16.png +0 -0
  127. data/vendor/jasmine/images/fail.png +0 -0
  128. data/vendor/jasmine/images/go-16.png +0 -0
  129. data/vendor/jasmine/images/go.png +0 -0
  130. data/vendor/jasmine/images/pending-16.png +0 -0
  131. data/vendor/jasmine/images/pending.png +0 -0
  132. data/vendor/jasmine/images/question-bk.png +0 -0
  133. data/vendor/jasmine/images/questionbk-16.png +0 -0
  134. data/vendor/jasmine/images/spinner.gif +0 -0
  135. data/vendor/jasmine/jasmine.watchr +70 -0
  136. data/vendor/jasmine/lib/EnvjsReporter.js +141 -0
  137. data/vendor/jasmine/lib/TrivialReporter.js +155 -0
  138. data/vendor/jasmine/lib/XMLReporter.js +241 -0
  139. data/vendor/jasmine/lib/consolex.js +28 -0
  140. data/vendor/jasmine/lib/jasmine-0.10.0.js +2526 -0
  141. data/vendor/jasmine/lib/jasmine.css +86 -0
  142. data/vendor/jasmine/lib/json2.js +478 -0
  143. data/vendor/jasmine/spec/jasmine_helper.rb +44 -0
  144. data/vendor/jasmine/spec/jasmine_spec.rb +31 -0
  145. data/vendor/jasmine/spec/runner.html +43 -0
  146. data/vendor/jasmine/spec/runner.js +78 -0
  147. data/vendor/jasmine/spec/saucelabs.yml +24 -0
  148. data/vendor/jasmine/spec/suites/EnvSpec.js +71 -0
  149. data/vendor/jasmine/spec/suites/ExceptionsSpec.js +107 -0
  150. data/vendor/jasmine/spec/suites/JsApiReporterSpec.js +82 -0
  151. data/vendor/jasmine/spec/suites/MatchersSpec.js +589 -0
  152. data/vendor/jasmine/spec/suites/MockClockSpec.js +34 -0
  153. data/vendor/jasmine/spec/suites/MultiReporterSpec.js +30 -0
  154. data/vendor/jasmine/spec/suites/NestedResultsSpec.js +54 -0
  155. data/vendor/jasmine/spec/suites/PrettyPrintSpec.js +93 -0
  156. data/vendor/jasmine/spec/suites/QueueSpec.js +23 -0
  157. data/vendor/jasmine/spec/suites/ReporterSpec.js +60 -0
  158. data/vendor/jasmine/spec/suites/RunnerSpec.js +258 -0
  159. data/vendor/jasmine/spec/suites/SpecRunningSpec.js +1117 -0
  160. data/vendor/jasmine/spec/suites/SpecSpec.js +110 -0
  161. data/vendor/jasmine/spec/suites/SpySpec.js +187 -0
  162. data/vendor/jasmine/spec/suites/SuiteSpec.js +101 -0
  163. data/vendor/jasmine/spec/suites/TrivialReporterSpec.js +140 -0
  164. data/vendor/jasmine/spec/suites/UtilSpec.js +23 -0
  165. data/vendor/jasmine/src/Block.js +34 -0
  166. data/vendor/jasmine/src/Env.js +236 -0
  167. data/vendor/jasmine/src/JsApiReporter.js +103 -0
  168. data/vendor/jasmine/src/Matchers.js +326 -0
  169. data/vendor/jasmine/src/MultiReporter.js +28 -0
  170. data/vendor/jasmine/src/NestedResults.js +99 -0
  171. data/vendor/jasmine/src/PrettyPrinter.js +122 -0
  172. data/vendor/jasmine/src/Queue.js +210 -0
  173. data/vendor/jasmine/src/Reporter.js +27 -0
  174. data/vendor/jasmine/src/Reporters.js +43 -0
  175. data/vendor/jasmine/src/Runner.js +68 -0
  176. data/vendor/jasmine/src/Spec.js +254 -0
  177. data/vendor/jasmine/src/Suite.js +70 -0
  178. data/vendor/jasmine/src/WaitsBlock.js +13 -0
  179. data/vendor/jasmine/src/WaitsForBlock.js +38 -0
  180. data/vendor/jasmine/src/base.js +604 -0
  181. data/vendor/jasmine/src/mock-timeout.js +177 -0
  182. data/vendor/jasmine/src/util.js +67 -0
  183. data/vendor/jasmine/src/version.json +5 -0
  184. metadata +279 -0
@@ -0,0 +1,110 @@
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
+
40
+ it('getFullName returns suite & spec description', function () {
41
+ var spec = new jasmine.Spec(env, suite, 'spec 1');
42
+ expect(spec.getFullName()).toEqual('suite 1 spec 1.')
43
+ });
44
+
45
+ describe('results', function () {
46
+ var spec, results;
47
+ beforeEach(function () {
48
+ spec = new jasmine.Spec(env, suite);
49
+ results = spec.results();
50
+ expect(results.totalCount).toEqual(0);
51
+ spec.runs(function () {
52
+ this.expect(true).toEqual(true);
53
+ this.expect(true).toEqual(true);
54
+ });
55
+ });
56
+
57
+
58
+ it('results shows the total number of expectations for each spec after execution', function () {
59
+ expect(results.totalCount).toEqual(0);
60
+ spec.execute();
61
+ expect(results.totalCount).toEqual(2);
62
+ });
63
+
64
+ it('results shows the number of passed expectations for each spec after execution', function () {
65
+ expect(results.passedCount).toEqual(0);
66
+ spec.execute();
67
+ expect(results.passedCount).toEqual(2);
68
+ });
69
+
70
+ it('results shows the number of failed expectations for each spec after execution', function () {
71
+ spec.runs(function () {
72
+ this.expect(true).toEqual(false);
73
+ });
74
+ expect(results.failedCount).toEqual(0);
75
+ spec.execute();
76
+ expect(results.failedCount).toEqual(1);
77
+ });
78
+
79
+ describe('results.passed', function () {
80
+ it('is true if all spec expectations pass', function () {
81
+ spec.runs(function () {
82
+ this.expect(true).toEqual(true);
83
+ });
84
+ spec.execute();
85
+ expect(results.passed()).toEqual(true);
86
+ });
87
+
88
+ it('is false if one spec expectation fails', function () {
89
+ spec.runs(function () {
90
+ this.expect(true).toEqual(false);
91
+ });
92
+ spec.execute();
93
+ expect(results.passed()).toEqual(false);
94
+ });
95
+
96
+ it('a spec with no expectations will return true', function () {
97
+ var specWithoutExpectations = new jasmine.Spec(env, suite);
98
+ specWithoutExpectations.runs(function() {
99
+
100
+ });
101
+ specWithoutExpectations.execute();
102
+ expect(results.passed()).toEqual(true);
103
+ });
104
+
105
+ it('an unexecuted spec will return true', function () {
106
+ expect(results.passed()).toEqual(true);
107
+ });
108
+ });
109
+ });
110
+ });
@@ -0,0 +1,187 @@
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).wasNotCalled();
173
+ TestClass.someFunction();
174
+ expect(TestClass.someFunction).wasCalled();
175
+ TestClass.someFunction.reset();
176
+ expect(TestClass.someFunction).wasNotCalled();
177
+ expect(TestClass.someFunction.callCount).toEqual(0);
178
+ });
179
+
180
+ it("should create an object with a bunch of spy methods when you call jasmine.createSpyObj()", function() {
181
+ var spyObj = jasmine.createSpyObj('BaseName', ['method1', 'method2']);
182
+ expect(spyObj).toEqual({ method1: jasmine.any(Function), method2: jasmine.any(Function)});
183
+ expect(spyObj.method1.identity).toEqual('BaseName.method1');
184
+ expect(spyObj.method2.identity).toEqual('BaseName.method2');
185
+ });
186
+
187
+ });
@@ -0,0 +1,101 @@
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
+ it('#specs should return all immediate children that are specs.', function () {
18
+ var suite =env.describe('Suite 1', function () {
19
+ env.it('Spec 1', function() {
20
+ this.runs(function () {
21
+ this.expect(true).toEqual(true);
22
+ });
23
+ });
24
+ env.it('Spec 2', function() {
25
+ this.runs(function () {
26
+ this.expect(true).toEqual(true);
27
+ });
28
+ });
29
+ env.describe('Suite 2', function () {
30
+ env.it('Spec 3', function() {
31
+ this.runs(function () {
32
+ this.expect(true).toEqual(true);
33
+ });
34
+ });
35
+ });
36
+ env.it('Spec 4', function() {
37
+ this.runs(function () {
38
+ this.expect(true).toEqual(true);
39
+ });
40
+ });
41
+ });
42
+
43
+ var suiteSpecs = suite.specs();
44
+ expect(suiteSpecs.length).toEqual(3);
45
+ expect(suiteSpecs[0].description).toEqual('Spec 1');
46
+ expect(suiteSpecs[1].description).toEqual('Spec 2');
47
+ expect(suiteSpecs[2].description).toEqual('Spec 4');
48
+ });
49
+
50
+ describe('SpecCount', function () {
51
+
52
+ it('should keep a count of the number of specs that are run', function() {
53
+ var suite = env.describe('one suite description', function () {
54
+ env.it('should be a test', function() {
55
+ this.runs(function () {
56
+ this.expect(true).toEqual(true);
57
+ });
58
+ });
59
+ env.it('should be another test', function() {
60
+ this.runs(function () {
61
+ this.expect(true).toEqual(true);
62
+ });
63
+ });
64
+ env.it('should be a third test', function() {
65
+ this.runs(function () {
66
+ this.expect(true).toEqual(true);
67
+ });
68
+ });
69
+ });
70
+
71
+ expect(suite.specs().length).toEqual(3);
72
+ });
73
+
74
+ it('specCount should be correct even with runs/waits blocks', function() {
75
+ var suite = env.describe('one suite description', function () {
76
+ env.it('should be a test', function() {
77
+ this.runs(function () {
78
+ this.expect(true).toEqual(true);
79
+ });
80
+ });
81
+ env.it('should be another test', function() {
82
+ this.runs(function () {
83
+ this.expect(true).toEqual(true);
84
+ });
85
+ this.waits(10);
86
+ this.runs(function () {
87
+ this.expect(true).toEqual(true);
88
+ });
89
+ });
90
+ env.it('should be a third test', function() {
91
+ this.runs(function () {
92
+ this.expect(true).toEqual(true);
93
+ });
94
+ });
95
+ });
96
+
97
+ expect(suite.specs().length).toEqual(3);
98
+ });
99
+ });
100
+ });
101
+ });
@@ -0,0 +1,140 @@
1
+ describe("TrivialReporter", function() {
2
+ var trivialReporter;
3
+ var body;
4
+
5
+ beforeEach(function() {
6
+ body = document.createElement("body");
7
+ });
8
+
9
+ function fakeSpec(name) {
10
+ return {
11
+ getFullName: function() {
12
+ return name;
13
+ }
14
+ };
15
+ }
16
+
17
+ it("should run only specs beginning with spec parameter", function() {
18
+ var trivialReporter = new jasmine.TrivialReporter({ location: {search: "?spec=run%20this"} });
19
+ expect(trivialReporter.specFilter(fakeSpec("run this"))).toBeTruthy();
20
+ expect(trivialReporter.specFilter(fakeSpec("not the right spec"))).toBeFalsy();
21
+ expect(trivialReporter.specFilter(fakeSpec("not run this"))).toBeFalsy();
22
+ });
23
+
24
+ it("should display empty divs for every suite when the runner is starting", function() {
25
+ var trivialReporter = new jasmine.TrivialReporter({ body: body });
26
+ trivialReporter.reportRunnerStarting({
27
+ suites: function() {
28
+ return [ new jasmine.Suite({}, "suite 1", null, null) ];
29
+ }
30
+ });
31
+
32
+ var divs = body.getElementsByTagName("div");
33
+ expect(divs.length).toEqual(2);
34
+ expect(divs[1].innerHTML).toContain("suite 1");
35
+ });
36
+
37
+ describe('Matcher reporting', function () {
38
+ var getResultMessageDiv = function (body) {
39
+ var divs = body.getElementsByTagName("div");
40
+ for (var i = 0; i < divs.length; i++) {
41
+ if (divs[i].className.match(/resultMessage/)) {
42
+ return divs[i];
43
+ }
44
+ }
45
+ };
46
+
47
+ var runner, spec, fakeTimer;
48
+ beforeEach(function () {
49
+ var env = new jasmine.Env();
50
+ fakeTimer = new jasmine.FakeTimer();
51
+ env.setTimeout = fakeTimer.setTimeout;
52
+ env.clearTimeout = fakeTimer.clearTimeout;
53
+ env.setInterval = fakeTimer.setInterval;
54
+ env.clearInterval = fakeTimer.clearInterval;
55
+ runner = env.currentRunner();
56
+ var suite = new jasmine.Suite(env, 'some suite');
57
+ runner.add(suite);
58
+ spec = new jasmine.Spec(env, suite, 'some spec');
59
+ suite.add(spec);
60
+ var trivialReporter = new jasmine.TrivialReporter({ body: body, location: {search: "?"} });
61
+ env.addReporter(trivialReporter);
62
+ });
63
+
64
+ describe('toContain', function () {
65
+ it('should show actual and expected', function () {
66
+ spec.runs(function () {
67
+ this.expect('foo').toContain('bar');
68
+ });
69
+ runner.execute();
70
+ fakeTimer.tick(0);
71
+
72
+ var resultEl = getResultMessageDiv(body);
73
+ expect(resultEl.innerHTML).toMatch(/foo/);
74
+ expect(resultEl.innerHTML).toMatch(/bar/);
75
+ });
76
+ });
77
+ });
78
+
79
+
80
+ describe("failure messages (integration)", function () {
81
+ var spec, results, expectationResult;
82
+
83
+ beforeEach(function() {
84
+ results = {
85
+ passed: function() {
86
+ return false;
87
+ },
88
+ getItems: function() {
89
+ }};
90
+
91
+ spec = {
92
+ suite: {
93
+ getFullName: function() {
94
+ return "suite 1";
95
+ }
96
+ },
97
+ getFullName: function() {
98
+ return "foo";
99
+ },
100
+ results: function() {
101
+ return results;
102
+ }
103
+ };
104
+
105
+ trivialReporter = new jasmine.TrivialReporter({ body: body });
106
+ trivialReporter.reportRunnerStarting({
107
+ suites: function() {
108
+ return [ new jasmine.Suite({}, "suite 1", null, null) ];
109
+ }
110
+ });
111
+ });
112
+
113
+ it("should add the failure message to the DOM (non-toEquals matchers)", function() {
114
+ expectationResult = new jasmine.ExpectationResult({
115
+ matcherName: "toBeNull", passed: false, message: "Expected 'a' to be null, but it was not"
116
+ });
117
+
118
+ spyOn(results, 'getItems').andReturn([expectationResult]);
119
+
120
+ trivialReporter.reportSpecResults(spec);
121
+
122
+ var divs = body.getElementsByTagName("div");
123
+ expect(divs[3].innerText || divs[3].textContent).toEqual("Expected 'a' to be null, but it was not");
124
+ });
125
+
126
+ it("should add the failure message to the DOM (non-toEquals matchers)", function() {
127
+ expectationResult = new jasmine.ExpectationResult({
128
+ matcherName: "toBeNull", passed: false, message: "Expected '1 < 2' to <b>e null, & it was not"
129
+ });
130
+
131
+ spyOn(results, 'getItems').andReturn([expectationResult]);
132
+
133
+ trivialReporter.reportSpecResults(spec);
134
+
135
+ var divs = body.getElementsByTagName("div");
136
+ expect(divs[3].innerHTML).toEqual("Expected '1 &lt; 2' to &lt;b&gt;e null, &amp; it was not");
137
+ });
138
+ });
139
+
140
+ });
@@ -0,0 +1,23 @@
1
+ describe("jasmine.util", function() {
2
+ describe("extend", function () {
3
+ it("should add properies to a destination object ", function() {
4
+ var destination = {baz: 'baz'};
5
+ jasmine.util.extend(destination, {
6
+ foo: 'foo', bar: 'bar'
7
+ });
8
+ expect(destination).toEqual({foo: 'foo', bar: 'bar', baz: 'baz'});
9
+ });
10
+
11
+ it("should replace properies that already exist on a destination object", function() {
12
+ var destination = {foo: 'foo'};
13
+ jasmine.util.extend(destination, {
14
+ foo: 'bar'
15
+ });
16
+ expect(destination).toEqual({foo: 'bar'});
17
+ jasmine.util.extend(destination, {
18
+ foo: null
19
+ });
20
+ expect(destination).toEqual({foo: null});
21
+ });
22
+ });
23
+ });
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Blocks are functions with executable code that make up a spec.
3
+ *
4
+ * @constructor
5
+ * @param {jasmine.Env} env
6
+ * @param {Function} func
7
+ * @param {jasmine.Spec} spec
8
+ */
9
+ jasmine.Block = function(env, func, spec) {
10
+ this.env = env;
11
+ this.func = func;
12
+ this.spec = spec;
13
+ };
14
+
15
+ jasmine.Block.prototype.execute = function(onComplete) {
16
+ try {
17
+ if(!this.spec.pending ||
18
+ (this.is_after && this.spec.is_before_ran)){
19
+ if(this.is_before){
20
+ this.spec.is_before_ran = true;
21
+ }
22
+ this.func.apply(this.spec);
23
+ }
24
+ } catch (e) {
25
+ if(e instanceof jasmine.pending_){
26
+ this.spec.pending = true;
27
+ } else if (e instanceof jasmine.eventually_){
28
+ throw e;
29
+ } else {
30
+ this.spec && this.spec.fail(e);
31
+ }
32
+ }
33
+ onComplete();
34
+ };