newjs 1.5.1 → 1.7.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/History.txt +11 -0
  2. data/Manifest.txt +162 -14
  3. data/{README.txt → README.rdoc} +1 -1
  4. data/Rakefile +25 -3
  5. data/app_generators/newjs_iphone/templates/Html/test/assets/jsunittest.js +41 -13
  6. data/app_generators/newjs_iphone/templates/Html/test/assets/unittest.css +4 -0
  7. data/features/development.feature +13 -0
  8. data/features/imported_files_for_generators.feature +19 -0
  9. data/features/steps/common.rb +205 -0
  10. data/features/steps/env.rb +6 -0
  11. data/javascript_test_generators/functional_test/functional_test_generator.rb +9 -1
  12. data/javascript_test_generators/functional_test/templates/test/assets/jshoulda.js +186 -0
  13. data/javascript_test_generators/functional_test/templates/test/test.html.erb +15 -1
  14. data/javascript_test_generators/unit_test/templates/test/assets/jshoulda.js +186 -0
  15. data/javascript_test_generators/unit_test/templates/test/test.html.erb +18 -20
  16. data/javascript_test_generators/unit_test/templates/test/test_jshoulda.html.erb +45 -0
  17. data/javascript_test_generators/unit_test/unit_test_generator.rb +11 -3
  18. data/lib/newjs.rb +3 -2
  19. data/newjs_iphone_generators/page/USAGE +5 -0
  20. data/newjs_iphone_generators/page/page_generator.rb +36 -0
  21. data/newjs_iphone_generators/page/templates/src/name.css.erb +0 -0
  22. data/newjs_iphone_generators/page/templates/src/name.html.erb +13 -0
  23. data/newjs_iphone_generators/page/templates/src/name.js.erb +4 -0
  24. data/newjs_iphone_generators/page/templates/test/fixtures/name.js.erb +5 -0
  25. data/newjs_iphone_generators/page/templates/test/unit/name_test.html.erb +61 -0
  26. data/rack_generators/javascript_test/USAGE +5 -0
  27. data/rack_generators/javascript_test/javascript_test_generator.rb +88 -0
  28. data/rack_generators/javascript_test/templates/assets/jshoulda.js +186 -0
  29. data/rack_generators/javascript_test/templates/assets/jsunittest.js +1004 -0
  30. data/rack_generators/javascript_test/templates/assets/unittest.css +54 -0
  31. data/rack_generators/javascript_test/templates/ext/jquery.js +3408 -0
  32. data/{app_generators/newjs_iphone/templates/Html/test/assets → rack_generators/javascript_test/templates/ext}/prototype.js +56 -122
  33. data/rack_generators/javascript_test/templates/library.js.erb +3 -0
  34. data/rack_generators/javascript_test/templates/test.html.erb +59 -0
  35. data/rack_generators/javascript_test/templates/test_jshoulda.html.erb +48 -0
  36. data/rails_generators/javascript_test/javascript_test_generator.rb +15 -3
  37. data/rails_generators/javascript_test/templates/assets/jshoulda.js +186 -0
  38. data/rails_generators/javascript_test/templates/test_jshoulda.html.erb +48 -0
  39. data/script/console +10 -0
  40. data/script/destroy +1 -1
  41. data/tasks/vendor/update/jshoulda.rake +18 -0
  42. data/tasks/vendor/update/jsunittest.rake +18 -0
  43. data/test/test_functional_test_generator.rb +13 -0
  44. data/test/test_generator_helper.rb +10 -1
  45. data/test/test_page_generator.rb +50 -0
  46. data/test/test_rack_javascript_test.rb +166 -0
  47. data/test/{test_javascript_test_generator.rb → test_rails_javascript_test_generator.rb} +15 -1
  48. data/test/test_unit_test_generator.rb +13 -0
  49. data/vendor/jshoulda/History.txt +108 -0
  50. data/vendor/jshoulda/License.txt +20 -0
  51. data/vendor/jshoulda/README.mdown +34 -0
  52. data/vendor/jshoulda/Rakefile +120 -0
  53. data/vendor/jshoulda/config/javascript_test_autotest.yml.sample +15 -0
  54. data/vendor/jshoulda/dist/jshoulda-0.0.1.js +62 -0
  55. data/vendor/jshoulda/dist/jshoulda-0.0.2.js +72 -0
  56. data/vendor/jshoulda/dist/jshoulda-0.0.3.js +72 -0
  57. data/vendor/jshoulda/dist/jshoulda-1.0.1.js +74 -0
  58. data/vendor/jshoulda/dist/jshoulda-1.0.js +72 -0
  59. data/vendor/jshoulda/dist/jshoulda-1.1.js +110 -0
  60. data/vendor/jshoulda/dist/jshoulda-1.2.1.js +186 -0
  61. data/vendor/jshoulda/dist/jshoulda-1.2.js +141 -0
  62. data/vendor/jshoulda/dist/jshoulda-1.2.x.js +142 -0
  63. data/vendor/jshoulda/dist/jshoulda.js +186 -0
  64. data/vendor/jshoulda/jshoulda/test/basic_test.html +42 -0
  65. data/vendor/jshoulda/lib/jstest.rb +382 -0
  66. data/vendor/jshoulda/lib/protodoc.rb +36 -0
  67. data/vendor/jshoulda/script/destroy +14 -0
  68. data/vendor/jshoulda/script/generate +14 -0
  69. data/vendor/jshoulda/script/js_autotest +1 -0
  70. data/vendor/jshoulda/script/rstakeout +97 -0
  71. data/vendor/jshoulda/site/asset_defaults.yaml +6 -0
  72. data/vendor/jshoulda/site/config.yaml +3 -0
  73. data/vendor/jshoulda/site/content/content.html +27 -0
  74. data/vendor/jshoulda/site/content/content.yaml +4 -0
  75. data/vendor/jshoulda/site/content/tutorial/tutorial.html +268 -0
  76. data/vendor/jshoulda/site/content/tutorial/tutorial.yaml +4 -0
  77. data/vendor/jshoulda/site/css/blackboard.css +88 -0
  78. data/vendor/jshoulda/site/css/jshoulda_site.css +33 -0
  79. data/vendor/jshoulda/site/css/unittest.css +42 -0
  80. data/vendor/jshoulda/site/example/minimal.html +55 -0
  81. data/vendor/jshoulda/site/js/editable.js +42 -0
  82. data/vendor/jshoulda/site/layouts/default/default.html +29 -0
  83. data/vendor/jshoulda/site/layouts/default/default.yaml +4 -0
  84. data/vendor/jshoulda/site/layouts/home_test/home_test.js +18 -0
  85. data/vendor/jshoulda/site/layouts/home_test/home_test.yaml +4 -0
  86. data/vendor/jshoulda/site/lib/analytics.rb +12 -0
  87. data/vendor/jshoulda/site/lib/default.rb +2 -0
  88. data/vendor/jshoulda/site/lib/example.rb +10 -0
  89. data/vendor/jshoulda/site/lib/hash.rb +11 -0
  90. data/vendor/jshoulda/site/lib/highlight.rb +17 -0
  91. data/vendor/jshoulda/site/page_defaults.yaml +10 -0
  92. data/vendor/jshoulda/site/templates/default/default.html +1 -0
  93. data/vendor/jshoulda/site/templates/default/default.yaml +4 -0
  94. data/vendor/jshoulda/src/HEADER +8 -0
  95. data/vendor/jshoulda/src/jshoulda.js +177 -0
  96. data/vendor/jshoulda/src/jshoulda.js.erb +3 -0
  97. data/vendor/jshoulda/tasks/bundle.rake +12 -0
  98. data/vendor/jshoulda/tasks/demo.rake +9 -0
  99. data/vendor/jshoulda/tasks/deploy.rake +29 -0
  100. data/{tasks → vendor/jshoulda/tasks}/environment.rake +0 -0
  101. data/vendor/jshoulda/tasks/javascript_test_autotest_tasks.rake +45 -0
  102. data/vendor/jshoulda/tasks/site.rake +74 -0
  103. data/vendor/jshoulda/test/assets/jsunittest.js +1004 -0
  104. data/vendor/jshoulda/test/assets/prototype.js +4324 -0
  105. data/{app_generators/newjs_iphone/templates/Html/test/assets/unittest.js → vendor/jshoulda/test/assets/prototype_unittest.js} +15 -9
  106. data/vendor/jshoulda/test/assets/unittest.css +50 -0
  107. data/vendor/jshoulda/test/unit/factory_test.html +82 -0
  108. data/vendor/jshoulda/test/unit/jshoulda2_test.html +85 -0
  109. data/vendor/jshoulda/test/unit/jshoulda_prototype_test.html +87 -0
  110. data/vendor/jshoulda/test/unit/jshoulda_test.html +86 -0
  111. data/vendor/jshoulda/test/unit/merge_methods_test.html +77 -0
  112. data/vendor/jshoulda/test/unit/names_and_count.html +68 -0
  113. data/vendor/jshoulda/test/unit/no_config_test.html +57 -0
  114. data/vendor/jshoulda/test/unit/styles_test.html +77 -0
  115. data/vendor/jshoulda/test/unit/unify_runners.html +69 -0
  116. data/vendor/jshoulda/test/unit/unnamed_context_test.html +67 -0
  117. data/vendor/jsunittest/Capfile +4 -0
  118. data/vendor/jsunittest/History.txt +37 -0
  119. data/{License.txt → vendor/jsunittest/License.txt} +0 -0
  120. data/vendor/jsunittest/README.txt +21 -0
  121. data/vendor/jsunittest/Rakefile +118 -0
  122. data/vendor/jsunittest/config/deploy.rb +20 -0
  123. data/vendor/jsunittest/config/website.yml.sample +2 -0
  124. data/vendor/jsunittest/dist/jsunittest-0.7.2.js +1004 -0
  125. data/vendor/jsunittest/dist/jsunittest.js +1004 -0
  126. data/vendor/jsunittest/dist/unittest.css +54 -0
  127. data/vendor/jsunittest/lib/jstest.rb +390 -0
  128. data/vendor/jsunittest/lib/protodoc.rb +36 -0
  129. data/vendor/jsunittest/script/destroy +14 -0
  130. data/vendor/jsunittest/script/generate +14 -0
  131. data/vendor/jsunittest/script/js_autotest +1 -0
  132. data/vendor/jsunittest/script/rstakeout +97 -0
  133. data/vendor/jsunittest/script/txt2html +75 -0
  134. data/vendor/jsunittest/src/HEADER +8 -0
  135. data/vendor/jsunittest/src/ajax.js +121 -0
  136. data/vendor/jsunittest/src/assertions.js +244 -0
  137. data/vendor/jsunittest/src/common.js +191 -0
  138. data/vendor/jsunittest/src/jsunittest.js +1004 -0
  139. data/vendor/jsunittest/src/logger.js +86 -0
  140. data/vendor/jsunittest/src/message_template.js +17 -0
  141. data/vendor/jsunittest/src/orig/unittest.js +484 -0
  142. data/vendor/jsunittest/src/prototype/event.js +72 -0
  143. data/vendor/jsunittest/src/prototype/template.js +33 -0
  144. data/vendor/jsunittest/src/runner.js +120 -0
  145. data/vendor/jsunittest/src/test_case.js +106 -0
  146. data/vendor/jsunittest/tasks/deploy.rake +29 -0
  147. data/vendor/jsunittest/tasks/environment.rake +7 -0
  148. data/vendor/jsunittest/tasks/javascript_test_autotest_tasks.rake +44 -0
  149. data/vendor/jsunittest/tasks/tmbundle.rake +24 -0
  150. data/vendor/jsunittest/tasks/website.rake +53 -0
  151. data/vendor/jsunittest/test/assets/example_test.html +50 -0
  152. data/{app_generators/newjs/templates → vendor/jsunittest}/test/assets/prototype.js +0 -0
  153. data/vendor/jsunittest/test/assets/unittest.css +54 -0
  154. data/{app_generators/newjs/templates → vendor/jsunittest}/test/assets/unittest.js +0 -0
  155. data/vendor/jsunittest/test/functional/jsunittest_test.html +209 -0
  156. data/vendor/jsunittest/test/unit/assertions_test.html +202 -0
  157. data/vendor/jsunittest/test/unit/common_test.html +61 -0
  158. data/vendor/jsunittest/test/unit/logger_test.html +98 -0
  159. data/vendor/jsunittest/test/unit/message_template_test.html +44 -0
  160. data/vendor/jsunittest/test/unit/runner_test.html +77 -0
  161. data/vendor/jsunittest/test/unit/template_test.html +57 -0
  162. data/vendor/jsunittest/test/unit/test_case_test.html +97 -0
  163. data/vendor/jsunittest/website/dist/jsunittest-0.7.2.js +1004 -0
  164. data/vendor/jsunittest/website/dist/jsunittest-getting-started.tar.gz +0 -0
  165. data/vendor/jsunittest/website/dist/jsunittest-getting-started.zip +0 -0
  166. data/vendor/jsunittest/website/dist/jsunittest-getting-started/assets/jsunittest.js +1004 -0
  167. data/vendor/jsunittest/website/dist/jsunittest-getting-started/assets/unittest.css +54 -0
  168. data/vendor/jsunittest/website/dist/jsunittest-getting-started/example_test.html +50 -0
  169. data/vendor/jsunittest/website/dist/jsunittest.js +1004 -0
  170. data/vendor/jsunittest/website/images/logo_bundle.png +0 -0
  171. data/vendor/jsunittest/website/images/passing_prototypejs_unittest_tests.jpg +0 -0
  172. data/vendor/jsunittest/website/index.html +94 -0
  173. data/vendor/jsunittest/website/index.txt +80 -0
  174. data/vendor/jsunittest/website/javascripts/rounded_corners_lite.inc.js +285 -0
  175. data/vendor/jsunittest/website/stylesheets/screen.css +138 -0
  176. data/vendor/jsunittest/website/template.html.erb +46 -0
  177. data/vendor/jsunittest/website/tmbundle/JavaScript Unit Testing.tmbundle.tar.gz +0 -0
  178. metadata +189 -24
  179. data/config/hoe.rb +0 -75
  180. data/config/requirements.rb +0 -17
  181. data/lib/newjs/version.rb +0 -9
  182. data/tasks/deployment.rake +0 -34
  183. data/tasks/jsunittest/update.rake +0 -18
  184. data/tasks/website.rake +0 -17
@@ -86,15 +86,17 @@ Test.Unit.Logger = Class.create({
86
86
  initialize: function(element) {
87
87
  this.element = $(element);
88
88
  if (this.element) this._createLogTable();
89
+ this.tbody = $(this.element.getElementsByTagName('tbody')[0]);
89
90
  },
90
91
 
91
92
  start: function(testName) {
92
93
  if (!this.element) return;
93
- this.element.down('tbody').insert('<tr><td>' + testName + '</td><td></td><td></td></tr>');
94
+ this.tbody.insert('<tr><td>' + testName + '</td><td></td><td></td></tr>');
94
95
  },
95
96
 
96
97
  setStatus: function(status) {
97
- this.getLastLogLine().addClassName(status).down('td', 1).update(status);
98
+ this.getLastLogLine().addClassName(status);
99
+ $(this.getLastLogLine().getElementsByTagName('td')[1]).update(status);
98
100
  },
99
101
 
100
102
  finish: function(status, summary) {
@@ -110,15 +112,20 @@ Test.Unit.Logger = Class.create({
110
112
 
111
113
  summary: function(summary) {
112
114
  if (!this.element) return;
113
- this.element.down('div').update(this._toHTML(summary));
115
+ var div = $(this.element.getElementsByTagName('div')[0]);
116
+ div.update(this._toHTML(summary));
114
117
  },
115
118
 
116
119
  getLastLogLine: function() {
117
- return this.element.select('tr').last()
120
+ //return this.element.descendants('tr').last();
121
+ var trs = this.element.getElementsByTagName('tr');
122
+ return $(trs[trs.length - 1]);
118
123
  },
119
124
 
120
125
  getMessageCell: function() {
121
126
  return this.getLastLogLine().down('td', 2);
127
+ var tds = this.getLastLogLine().getElementsByTagName('td');
128
+ return $(tds[2]);
122
129
  },
123
130
 
124
131
  _createLogTable: function() {
@@ -144,7 +151,7 @@ Test.Unit.Logger = Class.create({
144
151
  },
145
152
 
146
153
  _toHTML: function(txt) {
147
- return txt.escapeHTML().replace(/\n/g,"<br/>");
154
+ return txt.escapeHTML().replace(/\n/g,"<br />");
148
155
  }
149
156
  });
150
157
 
@@ -155,12 +162,12 @@ Test.Unit.Runner = Class.create({
155
162
  }, arguments[1] || {});
156
163
 
157
164
  options.resultsURL = this.queryParams.resultsURL;
158
- options.testLog = $(options.testLog);
159
165
 
160
166
  this.tests = this.getTests(testcases);
161
167
  this.currentTest = 0;
162
- this.logger = new Test.Unit.Logger(options.testLog);
168
+
163
169
  Event.observe(window, "load", function() {
170
+ this.logger = new Test.Unit.Logger($(options.testLog));
164
171
  this.runTests.bind(this).delay(0.1);
165
172
  }.bind(this));
166
173
  },
@@ -445,7 +452,7 @@ Test.Unit.Assertions = {
445
452
  },
446
453
 
447
454
  assertElementsMatch: function() {
448
- var pass = true, expressions = $A(arguments), elements = $A(expressions.shift());
455
+ var message, pass = true, expressions = $A(arguments), elements = $A(expressions.shift());
449
456
  if (elements.length != expressions.length) {
450
457
  message = this.buildMessage('assertElementsMatch', 'size mismatch: ? elements, ? expressions (?).', elements.length, expressions.length, expressions);
451
458
  this.flunk(message);
@@ -553,4 +560,3 @@ Test.Unit.Testcase = Class.create(Test.Unit.Assertions, {
553
560
  return timeTaken;
554
561
  }
555
562
  });
556
-
@@ -0,0 +1,50 @@
1
+ body, div, p, h1, h2, h3, ul, ol, span, a, table, td, form, img, li {
2
+ font-family: sans-serif;
3
+ }
4
+
5
+ body {
6
+ font-size:0.8em;
7
+ }
8
+
9
+ #log {
10
+ padding-bottom: 1em;
11
+ border-bottom: 2px solid #000;
12
+ margin-bottom: 2em;
13
+ }
14
+
15
+ .logsummary {
16
+ margin-top: 1em;
17
+ margin-bottom: 1em;
18
+ padding: 1ex;
19
+ border: 1px solid #000;
20
+ font-weight: bold;
21
+ }
22
+
23
+ .logtable {
24
+ width:100%;
25
+ border-collapse: collapse;
26
+ border: 1px dotted #666;
27
+ }
28
+
29
+ .logtable td, .logtable th {
30
+ text-align: left;
31
+ padding: 3px 8px;
32
+ border: 1px dotted #666;
33
+ }
34
+
35
+ .logtable .passed {
36
+ background-color: #cfc;
37
+ }
38
+
39
+ .logtable .failed, .logtable .error {
40
+ background-color: #fcc;
41
+ }
42
+
43
+ .logtable td div.action_buttons {
44
+ display: inline;
45
+ }
46
+
47
+ .logtable td div.action_buttons input {
48
+ margin: 0 5px;
49
+ font-size: 10px;
50
+ }
@@ -0,0 +1,82 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <title>JavaScript unit test file</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7
+ <script src="../assets/jsunittest.js" type="text/javascript"></script>
8
+ <script src="../../src/jshoulda.js" type="text/javascript"></script>
9
+
10
+ <link rel="stylesheet" href="../assets/unittest.css" type="text/css" />
11
+ </head>
12
+ <body>
13
+
14
+ <div id="content">
15
+
16
+ <div id="header">
17
+ <h1>JavaScript unit test file</h1>
18
+ <p>
19
+ This file tests <strong>factory.js</strong>.
20
+ </p>
21
+ </div>
22
+
23
+ <!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
24
+ <div id="testlog"></div>
25
+
26
+ <!-- Put sample/test html here -->
27
+ <div id="sample"></div>
28
+ </div>
29
+
30
+ <script type="text/javascript">
31
+ // <![CDATA[
32
+
33
+ function getPreviousTestWording(tableIndex) {
34
+ tableIndex = tableIndex || 0;
35
+ var rows = document.getElementsByTagName('table')[tableIndex].getElementsByTagName('tbody')[0].getElementsByTagName('tr');
36
+ return rows[rows.length - 2].getElementsByTagName('td')[0].innerHTML.replace(/^\s+|\s+$/g, '').replace(/\s+/, ' ');
37
+ }
38
+
39
+ jShoulda
40
+ .setShouldAlias('shoulda', 'ya shoulda yay')
41
+ .setContextAlias('describe')
42
+ .setShouldAlias('it', '')
43
+ .setShouldAlias('must');
44
+
45
+ describe("jShoulda", {},
46
+ should("expose a setShouldAlias", function() {
47
+ this.assert(typeof jShoulda.setShouldAlias == 'function');
48
+ }),
49
+ shoulda("accept weird connectors", function() {
50
+ this.assert(true);
51
+ }),
52
+ must('use weird wording in the previous test', function() {
53
+ this.assertEqual('jShoulda ya shoulda yay accept weird connectors', getPreviousTestWording());
54
+ }),
55
+ it('really can say what you want', function() {
56
+ this.assertEqual('jShoulda must use weird wording in the previous test', getPreviousTestWording());
57
+ })
58
+ )({testLog: "testlog"});
59
+
60
+
61
+ jShoulda
62
+ .setContextAlias('un', 'Un')
63
+ .setContextAlias('para', 'para')
64
+ .setShouldAlias('deberia', 'debería')
65
+ .unifyRunners();
66
+
67
+ un("Choan",
68
+ para("ser feliz",
69
+ deberia("poder comer melocotones de Calanda todo el año", function() {
70
+ this.assertEqual('yum', 'yum');
71
+ })
72
+ ),
73
+ deberia("sentirse feliz de su trabajo en jShoulda", function() {
74
+ this.assertEqual('Un Choan para ser feliz debería poder comer melocotones de Calanda todo el año', getPreviousTestWording());
75
+ })
76
+ )();
77
+
78
+
79
+ // ]]>
80
+ </script>
81
+ </body>
82
+ </html>
@@ -0,0 +1,85 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <title>JavaScript unit test file</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7
+ <script src="../assets/jsunittest.js" type="text/javascript"></script>
8
+
9
+ <script src="../../src/jshoulda.js" type="text/javascript"></script>
10
+
11
+ <link rel="stylesheet" href="../assets/unittest.css" type="text/css" />
12
+ </head>
13
+ <body>
14
+
15
+ <div id="content">
16
+
17
+ <div id="header">
18
+ <h1>JavaScript unit test file</h1>
19
+ <p>
20
+ This file tests <strong>jshoulda2.js</strong>.
21
+ </p>
22
+ </div>
23
+
24
+ <!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
25
+ <div id="testlog"></div>
26
+
27
+ <!-- Put sample/test html here -->
28
+ <div id="sample"></div>
29
+ </div>
30
+
31
+ <script type="text/javascript">
32
+ // <![CDATA[
33
+
34
+ new Test.Unit.Runner({
35
+ // replace this with your real tests
36
+ setup: function() {
37
+ JsUnitTest.Unit.Testcase = function() {};
38
+ JsUnitTest.Unit.Testcase.prototype.run = function() {};
39
+ JsUnitTest.Unit.Testcase.prototype.status = function() { return "passed" };
40
+ JsUnitTest.Unit.Testcase.prototype.summary = function() { return "summary" };
41
+ JsUnitTest.Unit.Testcase.prototype.assertions = 1;
42
+ JsUnitTest.Unit.Testcase.prototype.failures = 0;
43
+ JsUnitTest.Unit.Testcase.prototype.errors = 0;
44
+ JsUnitTest.Unit.Testcase.prototype.warnings = 0;
45
+ JsUnitTest.Unit.Logger = function() {};
46
+ JsUnitTest.Unit.Logger.prototype.start = function() {};
47
+ JsUnitTest.Unit.Logger.prototype.finish = function() {};
48
+ JsUnitTest.Unit.Logger.prototype.summary = function() {};
49
+ this.runner = context('A context with two empty tests', {},
50
+ should('have just one test', function() {
51
+ }),
52
+ should('then another one', function() {
53
+ })
54
+ )();
55
+ },
56
+
57
+ teardown: function() {
58
+
59
+ },
60
+
61
+ testInitially: function() { with(this) {
62
+ assertEqual(2, runner.tests.length);
63
+ }},
64
+
65
+ testResultsAfterTests: function() { with(this) {
66
+ runner.runTests();
67
+ var results = runner.getResult();
68
+ assertEqual(2, results.assertions);
69
+ assertEqual(0, results.errors);
70
+ assertEqual(0, results.failures);
71
+ assertEqual(0, results.warnings);
72
+ assertEqual("2 tests, 2 assertions, 0 failures, 0 errors, 0 warnings", runner.summary());
73
+ }}
74
+
75
+
76
+ }, {testLog: "testlog"});
77
+ // For each Test.UnitRunner instance, specify the element id where results will be
78
+ // published; e.g. <div id="testlog"/> above.
79
+ // That is, you can have multiple "new Test.Unit.Runner() { ... }" on this page, just
80
+ // create more <div id="testlog2"></div> etc, and pass the element id to the hash above:
81
+ // e.g. {testLog: "testlog2"}
82
+ // ]]>
83
+ </script>
84
+ </body>
85
+ </html>
@@ -0,0 +1,87 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <title>JavaScript unit test file</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7
+ <script src="../assets/prototype.js" type="text/javascript"></script>
8
+ <script src="../assets/prototype_unittest.js" type="text/javascript"></script>
9
+
10
+ <script src="../../src/jshoulda.js" type="text/javascript"></script>
11
+
12
+ <link rel="stylesheet" href="../assets/unittest.css" type="text/css" />
13
+ </head>
14
+ <body>
15
+
16
+ <div id="content">
17
+
18
+ <div id="header">
19
+ <h1>JavaScript unit test file</h1>
20
+ <p>
21
+ This file tests <strong>jshoulda.js</strong>.
22
+ </p>
23
+ </div>
24
+
25
+ <!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
26
+ <div id="testlog"></div>
27
+ <div id="testlog2"></div>
28
+
29
+ </div>
30
+
31
+ <script type="text/javascript">
32
+ // <![CDATA[
33
+
34
+ var runner = context('A test', {},
35
+ should('run', function() {
36
+ this.assert(true);
37
+ })
38
+ )();
39
+
40
+ jShoulda.unifyRunners();
41
+
42
+ context('A context', {
43
+ setup: function() {
44
+ this.runBefore = 1;
45
+ }
46
+ },
47
+ should('run its before setting', function() {
48
+ this.assertEqual(1, this.runBefore);
49
+ }),
50
+ context('which is an inner context', {},
51
+ should('run its parent setup function', function() {
52
+ this.assertEqual(1, this.runBefore);
53
+ })
54
+ ),
55
+ context('which is an inner context with a setup function', {
56
+ setup: function() {
57
+ this.runBefore += 1;
58
+ }
59
+ },
60
+ should('run both setup functions', function() {
61
+ this.assertEqual(2, this.runBefore);
62
+ }),
63
+ context('and creates a DOM node in its before function', {
64
+ before : function() {
65
+ var el = document.createElement('div');
66
+ el.id = 'created-from-test';
67
+ document.body.appendChild(el);
68
+ },
69
+ after : function() {
70
+ document.body.removeChild(document.getElementById('created-from-test'));
71
+ }
72
+ },
73
+ should('get the node created', function() {
74
+ this.assert(document.getElementById('created-from-test'));
75
+ })
76
+ ),
77
+ context('and follows a context with an after function', {},
78
+ should('find a clean way', function() {
79
+ this.assert(!document.getElementById('created-from-test'));
80
+ })
81
+ )
82
+ )
83
+ )();
84
+ // ]]>
85
+ </script>
86
+ </body>
87
+ </html>
@@ -0,0 +1,86 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <title>JavaScript unit test file</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7
+ <script src="../assets/jsunittest.js" type="text/javascript"></script>
8
+
9
+ <script src="../../src/jshoulda.js" type="text/javascript"></script>
10
+
11
+ <link rel="stylesheet" href="../assets/unittest.css" type="text/css" />
12
+ </head>
13
+ <body>
14
+
15
+ <div id="content">
16
+
17
+ <div id="header">
18
+ <h1>JavaScript unit test file</h1>
19
+ <p>
20
+ This file tests <strong>jshoulda.js</strong>.
21
+ </p>
22
+ </div>
23
+
24
+ <!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
25
+ <div id="testlog"></div>
26
+ <div id="testlog2"></div>
27
+
28
+ </div>
29
+
30
+ <script type="text/javascript">
31
+ // <![CDATA[
32
+
33
+ var runner = context('A test', {},
34
+ should('run', function() {
35
+ this.assert(true);
36
+ })
37
+ )();
38
+
39
+ jShoulda.unifyRunners();
40
+
41
+ context('A context', {
42
+ setup: function() {
43
+ this.runBefore = 1;
44
+ }
45
+ },
46
+ should('run its before setting', function() {
47
+ this.assertEqual(1, this.runBefore);
48
+ }),
49
+ context('which is an inner context', {},
50
+ should('run its parent setup function', function() {
51
+ this.assertEqual(1, this.runBefore);
52
+ })
53
+ ),
54
+ context('which is an inner context with a setup function', {
55
+ setup: function() {
56
+ this.runBefore += 1;
57
+ }
58
+ },
59
+ should('run both setup functions', function() {
60
+ this.assertEqual(2, this.runBefore);
61
+ }),
62
+ context('and creates a DOM node in its before function', {
63
+ before : function() {
64
+ var el = document.createElement('div');
65
+ el.id = 'created-from-test';
66
+ document.body.appendChild(el);
67
+ },
68
+ after : function() {
69
+ document.body.removeChild(document.getElementById('created-from-test'));
70
+ }
71
+ },
72
+ should('get the node created', function() {
73
+ this.assert(document.getElementById('created-from-test'));
74
+ })
75
+ ),
76
+ context('and follows a context with an after function', {},
77
+ should('find a clean way', function() {
78
+ this.assert(!document.getElementById('created-from-test'));
79
+ })
80
+ )
81
+ )
82
+ )();
83
+ // ]]>
84
+ </script>
85
+ </body>
86
+ </html>