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
@@ -5,6 +5,9 @@
5
5
  <title>JavaScript unit test file</title>
6
6
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7
7
  <script src="../assets/jsunittest.js" type="text/javascript"></script>
8
+ <% if testing_lib == 'jshoulda' %>
9
+ <script src="../assets/jshoulda.js" type="text/javascript"></script>
10
+ <% end %>
8
11
 
9
12
  <script src="../../dist/<%= dist_name %>.js" type="text/javascript"></script>
10
13
 
@@ -30,7 +33,7 @@
30
33
 
31
34
  <script type="text/javascript">
32
35
  // <![CDATA[
33
-
36
+ <% if testing_lib.nil? %>
34
37
  new Test.Unit.Runner({
35
38
  // replace this with your real tests
36
39
  setup: function() {
@@ -51,6 +54,17 @@
51
54
  // That is, you can have multiple "new Test.Unit.Runner() { ... }" on this page, just
52
55
  // create more <div id="testlog2"></div> etc, and pass the element id to the hash above:
53
56
  // e.g. {testLog: "testlog2"}
57
+ <% elsif testing_lib == 'jshoulda' %>
58
+ context("A context", {
59
+ setup: function() {
60
+
61
+ }
62
+ },
63
+ should("run tests", function() {
64
+ this.assert(true);
65
+ })
66
+ )();
67
+ <% end %>
54
68
  // ]]>
55
69
  </script>
56
70
  </body>
@@ -0,0 +1,186 @@
1
+ /* jShoulda, version 1.2.1
2
+ * (c) 2008 Choan Galvez
3
+ *
4
+ * jShoulda is freely distributable under
5
+ * the terms of an MIT-style license.
6
+ * For details, see the web site: http://jshoulda.scriptia.net
7
+ *
8
+ *--------------------------------------------------------------------------*/
9
+
10
+ var jShoulda = function() {
11
+ // the test runner
12
+ var tr,
13
+ // handle all testcases with the same testrunner
14
+ unique = false,
15
+ // styles definitions
16
+ styles = {};
17
+
18
+ function dummy() {
19
+ };
20
+
21
+ function runQueue(queue, name, before, after, ext) {
22
+ var i, tests;
23
+ for (i = 0; i < queue.length; i += 1) {
24
+ tests = queue[i](name, before, after, ext);
25
+ if (tests)
26
+ tr.tests.push(tests);
27
+ }
28
+ before.pop();
29
+ after.pop();
30
+ }
31
+
32
+ function makeBatch(fn_a) {
33
+ var copy = fn_a.slice(0);
34
+ return function() {
35
+ for (var i = 0; i < copy.length; i += 1) {
36
+ copy[i].call(this);
37
+ }
38
+ };
39
+ }
40
+
41
+ function getContextAlias(prefix) {
42
+ if (prefix) prefix += ' ';
43
+ return function (name, config, args) {
44
+ var queue = Array.prototype.slice.call(arguments, 0);
45
+ var cName = '';
46
+ var obj = {};
47
+ // shift arguments if the first one is a string
48
+ if (typeof queue[0] == 'string') {
49
+ if (name) { cName += prefix; }
50
+ cName += queue.shift();
51
+ }
52
+ if (typeof queue[0] === 'object') {
53
+ obj = queue.shift();
54
+ }
55
+
56
+ obj.before = obj.setup || obj.before || dummy;
57
+ obj.after = obj.teardown || obj.after || dummy;
58
+ var beforeQueue;
59
+ var afterQueue;
60
+ var extensions = merge({}, obj || {});
61
+
62
+ return function(outerName, before, after, ext) {
63
+ // the root context gets no outerName or a configuration object
64
+ // as its first argument
65
+ var prefix = outerName;
66
+ var is_root = !!(outerName == undefined || typeof outerName == 'object');
67
+ if (is_root) {
68
+ tr = (tr && unique) ? tr : new Test.Unit.Runner({}, outerName || {});
69
+ prefix = '';
70
+ }
71
+ // shift arguments if the second one is a
72
+ // configuration object
73
+ beforeQueue = before ? before.push(obj.before) && before : [obj.before];
74
+ afterQueue = after ? after.push(obj.after) && after : [obj.after];
75
+ runQueue(queue, [prefix, cName].join(' ').replace(/^\s+/, ''), beforeQueue, afterQueue, merge(extensions, ext));
76
+ if (is_root) {
77
+ return tr;
78
+ }
79
+ return false; // do not add to the tests queue
80
+ };
81
+ };
82
+ };
83
+
84
+ function merge(sub, sup) {
85
+ for (var i in sup) {
86
+ if (i.search(/^(before|after|setup|teardown)$/) != -1) continue;
87
+ if (sup.hasOwnProperty(i)) {
88
+ sub[i] = sup[i];
89
+ }
90
+ }
91
+ return sub;
92
+ }
93
+
94
+
95
+ function getShouldAlias(connector) {
96
+ return function (name, fn) {
97
+ return function(prefix, before, after, extensions) {
98
+ var beforeBatch = makeBatch(before);
99
+ var afterBatch = makeBatch(after);
100
+ var unit = new Test.Unit.Testcase([prefix, name].join(' ' + connector + ' '), fn, beforeBatch, afterBatch);
101
+ merge(unit, extensions);
102
+ return unit;
103
+ };
104
+ };
105
+ }
106
+
107
+ function setShouldAlias(name, host) {
108
+ var connector = name;
109
+ if (typeof host == 'string') {
110
+ connector = host;
111
+ host = arguments[2];
112
+ }
113
+ host = host || window;
114
+ host[name] = getShouldAlias(connector);
115
+ return jShoulda;
116
+ }
117
+
118
+ function setContextAlias(name, host) {
119
+ var prefix = '';
120
+ if (typeof host == 'string') {
121
+ prefix = host;
122
+ host = arguments[2];
123
+ }
124
+ host = host || window;
125
+ host[name] = getContextAlias(prefix);
126
+ return jShoulda;
127
+ }
128
+
129
+ function useStyle(name) {
130
+ var style, i;
131
+ if (name in styles) {
132
+ style = styles[name];
133
+ if ('context' in style) {
134
+ for (i = 0; i < style.context.length; i += 2) {
135
+ setContextAlias(style.context[i], style.context[i+1]);
136
+ }
137
+ }
138
+ if ('should' in style) {
139
+ for (i = 0; i < style.should.length; i += 2) {
140
+ setShouldAlias(style.should[i], style.should[i+1]);
141
+ }
142
+ }
143
+ if (style.unify) unifyRunners();
144
+ }
145
+ else throw { name: 'UndefinedStyle', message: 'There is not "'+name+'" style defined' };
146
+ return jShoulda;
147
+ }
148
+
149
+ function defineStyle(name, opts, aliases) {
150
+ styles[name] = opts;
151
+ for (var i = 2; i < arguments.length; i += 1) {
152
+ styles[arguments[i]] = opts;
153
+ }
154
+ return jShoulda;
155
+ }
156
+
157
+ function unifyRunners (options) {
158
+ if (options) {
159
+ tr = options instanceof Test.Unit.Runner ? options : new Test.Unit.Runner({}, options || {});
160
+ }
161
+ unique = true;
162
+ return jShoulda;
163
+ }
164
+
165
+ return {
166
+ setShouldAlias : setShouldAlias,
167
+ setContextAlias : setContextAlias,
168
+ unifyRunners : unifyRunners,
169
+ useStyle : useStyle,
170
+ defineStyle: defineStyle
171
+ };
172
+
173
+ }();
174
+
175
+ jShoulda
176
+ .defineStyle('describe', {
177
+ context: [ 'describe', '' ],
178
+ should: [ 'it', '' ],
179
+ unify: false
180
+ }, 'it')
181
+ .defineStyle('context', {
182
+ context : [ 'context', '' ],
183
+ should : [ 'should', 'should' ],
184
+ unify : false
185
+ }, 'should')
186
+ .useStyle('should');
@@ -5,7 +5,6 @@
5
5
  <title>JavaScript unit test file</title>
6
6
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7
7
  <script src="../assets/jsunittest.js" type="text/javascript"></script>
8
-
9
8
  <script src="../../src/<%= library_name %>.js" type="text/javascript"></script>
10
9
 
11
10
  <link rel="stylesheet" href="../assets/unittest.css" type="text/css" />
@@ -30,27 +29,26 @@
30
29
 
31
30
  <script type="text/javascript">
32
31
  // <![CDATA[
33
-
34
- new Test.Unit.Runner({
35
- // replace this with your real tests
36
- setup: function() {
37
-
38
- },
32
+ new Test.Unit.Runner({
33
+ // replace this with your real tests
34
+ setup: function() {
39
35
 
40
- teardown: function() {
41
-
42
- },
36
+ },
37
+
38
+ teardown: function() {
39
+
40
+ },
41
+
42
+ testTruth: function() { with(this) {
43
+ assert(true);
44
+ }}
43
45
 
44
- testTruth: function() { with(this) {
45
- assert(true);
46
- }}
47
-
48
- }, {testLog: "testlog"});
49
- // For each Test.UnitRunner instance, specify the element id where results will be
50
- // published; e.g. <div id="testlog"/> above.
51
- // That is, you can have multiple "new Test.Unit.Runner() { ... }" on this page, just
52
- // create more <div id="testlog2"></div> etc, and pass the element id to the hash above:
53
- // e.g. {testLog: "testlog2"}
46
+ }, {testLog: "testlog"});
47
+ // For each Test.UnitRunner instance, specify the element id where results will be
48
+ // published; e.g. <div id="testlog"/> above.
49
+ // That is, you can have multiple "new Test.Unit.Runner() { ... }" on this page, just
50
+ // create more <div id="testlog2"></div> etc, and pass the element id to the hash above:
51
+ // e.g. {testLog: "testlog2"}
54
52
  // ]]>
55
53
  </script>
56
54
  </body>
@@ -0,0 +1,45 @@
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="../assets/jshoulda.js" type="text/javascript"></script>
9
+ <script src="../../src/<%= library_name %>.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><%= library_name %>.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
+ context("<%= module_name %>", {
34
+ setup: function() {
35
+
36
+ }
37
+ },
38
+ should("run tests", function() {
39
+ this.assert(true);
40
+ })
41
+ )();
42
+ // ]]>
43
+ </script>
44
+ </body>
45
+ </html>
@@ -1,12 +1,13 @@
1
1
  class UnitTestGenerator < RubiGen::Base
2
2
 
3
- attr_reader :name, :library_name
3
+ attr_reader :name, :library_name, :module_name, :test_framework
4
4
 
5
5
  def initialize(runtime_args, runtime_options = {})
6
6
  super
7
7
  usage if args.empty?
8
8
  @name = args.shift
9
9
  @library_name = args.shift || name
10
+ @module_name = library_name.camelcase
10
11
  extract_options
11
12
  end
12
13
 
@@ -15,8 +16,13 @@ class UnitTestGenerator < RubiGen::Base
15
16
  # Ensure appropriate folder(s) exists
16
17
  m.directory 'test/unit'
17
18
 
18
- # Create stubs
19
- m.template "test/test.html.erb", "test/unit/#{name}_test.html"
19
+ if test_framework
20
+ m.directory 'test/assets'
21
+ m.file "test/assets/#{test_framework}.js", "test/assets/#{test_framework}.js", :collision => :skip
22
+ m.template "test/test_#{test_framework}.html.erb", "test/unit/#{name}_test.html"
23
+ else
24
+ m.template "test/test.html.erb", "test/unit/#{name}_test.html"
25
+ end
20
26
  end
21
27
  end
22
28
 
@@ -43,6 +49,7 @@ EOS
43
49
  # "Some comment about this option",
44
50
  # "Default: none") { |options[:author]| }
45
51
  # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
52
+ opts.on("-j", "--jshoulda", "Use jshoulda test framework") { |v| options[:test_framework] = 'jshoulda'}
46
53
  end
47
54
 
48
55
  def extract_options
@@ -50,5 +57,6 @@ EOS
50
57
  # Templates can access these value via the attr_reader-generated methods, but not the
51
58
  # raw instance variable value.
52
59
  # @author = options[:author]
60
+ @test_framework = options[:test_framework]
53
61
  end
54
62
  end
@@ -1,7 +1,8 @@
1
- $:.unshift File.dirname(__FILE__)
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
2
3
 
3
4
  module Newjs
4
-
5
+ VERSION = '1.7.0'
5
6
  end
6
7
 
7
8
  require 'newjs/jstest'
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,36 @@
1
+ class PageGenerator < RubiGen::Base
2
+
3
+ attr_reader :name, :module_name
4
+
5
+ def initialize(runtime_args, runtime_options = {})
6
+ super
7
+ usage if args.empty?
8
+ @name = args.shift
9
+ @module_name = @name.camelcase
10
+ end
11
+
12
+ def manifest
13
+ record do |m|
14
+ m.directory 'src'
15
+ m.directory 'test/unit'
16
+ m.directory 'test/fixtures'
17
+
18
+ ["src/name.css.erb", "src/name.html.erb", "src/name.js.erb",
19
+ "test/unit/name_test.html.erb", "test/fixtures/name.js.erb"].each do |file|
20
+ target_name = file.gsub(/name/, name).gsub(/.erb/,'')
21
+ m.template file, target_name
22
+ end
23
+ end
24
+ end
25
+
26
+ protected
27
+ def banner
28
+ <<-EOS
29
+ Creates a page with a loadData() JavaScript method
30
+ to load data from Objective-C. This page would be
31
+ used in a WebKit view to show some static data.
32
+
33
+ USAGE: #{$0} #{spec.name} name
34
+ EOS
35
+ end
36
+ end
@@ -0,0 +1,13 @@
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
4
+ <title><%= module_name %></title>
5
+ <script src="<%= name %>.js"></script>
6
+ <link rel="stylesheet" href="<%= name %>.css" />
7
+ </head>
8
+ <body>
9
+ <div id="<%= name %>">
10
+
11
+ </div>
12
+ </body>
13
+ </html>
@@ -0,0 +1,4 @@
1
+ var <%= module_name %> = <%= module_name %> || {};
2
+ <%= module_name %>.loadData = function(data) {
3
+
4
+ };
@@ -0,0 +1,5 @@
1
+ function initialFixtureData() {
2
+ return {
3
+
4
+ };
5
+ };