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
@@ -0,0 +1,59 @@
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="<%= reverse_nested_folder %>assets/jsunittest.js" type="text/javascript"></script>
8
+ <% if framework -%>
9
+ <script src="<%= reverse_nested_folder %>../../public/javascripts/ext/<%= framework %>.js" type="text/javascript"></script>
10
+ <% end -%>
11
+ <script src="<%= reverse_nested_folder %>../../public/javascripts/<%= "#{nested_folder}/" if nested_folder %><%= library_name %>.js" type="text/javascript"></script>
12
+
13
+ <link rel="stylesheet" href="<%= reverse_nested_folder %>assets/unittest.css" type="text/css" />
14
+ </head>
15
+ <body>
16
+
17
+ <div id="content">
18
+
19
+ <div id="header">
20
+ <h1>JavaScript unit test file</h1>
21
+ <p>
22
+ This file tests <strong><%= library_name %>.js</strong>.
23
+ </p>
24
+ </div>
25
+
26
+ <!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
27
+ <div id="testlog"></div>
28
+
29
+ <!-- Put sample/test html here -->
30
+ <div id="sample"></div>
31
+ </div>
32
+
33
+ <script type="text/javascript">
34
+ // <![CDATA[
35
+
36
+ new Test.Unit.Runner({
37
+ // replace this with your real tests
38
+ setup: function() {
39
+
40
+ },
41
+
42
+ teardown: function() {
43
+
44
+ },
45
+
46
+ testTruth: function() { with(this) {
47
+ assert(true);
48
+ }}
49
+
50
+ }, {testLog: "testlog"});
51
+ // For each Test.UnitRunner instance, specify the element id where results will be
52
+ // published; e.g. <div id="testlog"/> above.
53
+ // That is, you can have multiple "new Test.Unit.Runner() { ... }" on this page, just
54
+ // create more <div id="testlog2"></div> etc, and pass the element id to the hash above:
55
+ // e.g. {testLog: "testlog2"}
56
+ // ]]>
57
+ </script>
58
+ </body>
59
+ </html>
@@ -0,0 +1,48 @@
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="<%= reverse_nested_folder %>assets/jsunittest.js" type="text/javascript"></script>
8
+ <script src="<%= reverse_nested_folder %>assets/jshoulda.js" type="text/javascript"></script>
9
+ <% if framework -%>
10
+ <script src="<%= reverse_nested_folder %>../../public/javascripts/ext/<%= framework %>.js" type="text/javascript"></script>
11
+ <% end -%>
12
+ <script src="<%= reverse_nested_folder %>../../public/javascripts/<%= "#{nested_folder}/" if nested_folder %><%= library_name %>.js" type="text/javascript"></script>
13
+
14
+ <link rel="stylesheet" href="<%= reverse_nested_folder %>assets/unittest.css" type="text/css" />
15
+ </head>
16
+ <body>
17
+
18
+ <div id="content">
19
+
20
+ <div id="header">
21
+ <h1>JavaScript unit test file</h1>
22
+ <p>
23
+ This file tests <strong><%= library_name %>.js</strong>.
24
+ </p>
25
+ </div>
26
+
27
+ <!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
28
+ <div id="testlog"></div>
29
+
30
+ <!-- Put sample/test html here -->
31
+ <div id="sample"></div>
32
+ </div>
33
+
34
+ <script type="text/javascript">
35
+ // <![CDATA[
36
+ context("<%= module_name %>", {
37
+ setup: function() {
38
+
39
+ }},
40
+ should("run tests", function() {
41
+
42
+ })
43
+ )();
44
+
45
+ // ]]>
46
+ </script>
47
+ </body>
48
+ </html>
@@ -2,11 +2,11 @@ class JavascriptTestGenerator < Rails::Generator::Base
2
2
  DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
3
3
  Config::CONFIG['ruby_install_name'])
4
4
 
5
- default_options :framework => nil, :library => false
5
+ default_options :framework => nil, :test_framework => nil, :library => false
6
6
 
7
7
  attr_reader :path, :name, :library_name, :module_name
8
8
  attr_reader :nested_folder, :reverse_nested_folder
9
- attr_reader :framework, :create_library
9
+ attr_reader :framework, :test_framework, :create_library
10
10
 
11
11
  def initialize(runtime_args, runtime_options = {})
12
12
  super
@@ -37,10 +37,15 @@ class JavascriptTestGenerator < Rails::Generator::Base
37
37
  m.directory "public/javascripts/ext" if framework
38
38
 
39
39
  # Create stubs
40
- m.template "test.html.erb", "test/javascript/#{path}_test.html"
40
+ if test_framework
41
+ m.template "test_#{test_framework}.html.erb", "test/javascript/#{path}_test.html"
42
+ else
43
+ m.template "test.html.erb", "test/javascript/#{path}_test.html"
44
+ end
41
45
  m.template "library.js.erb", "public/javascripts/#{path}.js" if create_library
42
46
 
43
47
  m.file "assets/jsunittest.js", "test/javascript/assets/jsunittest.js"
48
+ m.file "assets/jshoulda.js", "test/javascript/assets/jshoulda.js" if test_framework
44
49
  m.file "assets/unittest.css", "test/javascript/assets/unittest.css"
45
50
  m.file "ext/#{framework}.js", "public/javascripts/ext/#{framework}.js" if framework
46
51
 
@@ -88,10 +93,17 @@ EOS
88
93
  "Include jquery or prototypejs libraries",
89
94
  "Options: jquery, prototype",
90
95
  "Default: none") { |x| options[:framework] = x }
96
+ opts.on("-j", "--jshoulda", String,
97
+ "Use jshoulda test framework") { |x| options[:test_framework] = 'jshoulda' }
98
+ opts.on("-T", "--test-framework=FRAMEWORK", String,
99
+ "Use alternate/extension test framework",
100
+ "Options: jshoulda",
101
+ "Default: none") { |x| options[:test_framework] = x }
91
102
  end
92
103
 
93
104
  def extract_options
94
105
  @framework = options[:framework]
106
+ @test_framework = options[:test_framework]
95
107
  @create_library = options[:library]
96
108
  end
97
109
  end
@@ -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');
@@ -0,0 +1,48 @@
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="<%= reverse_nested_folder %>assets/jsunittest.js" type="text/javascript"></script>
8
+ <script src="<%= reverse_nested_folder %>assets/jshoulda.js" type="text/javascript"></script>
9
+ <% if framework -%>
10
+ <script src="<%= reverse_nested_folder %>../../public/javascripts/ext/<%= framework %>.js" type="text/javascript"></script>
11
+ <% end -%>
12
+ <script src="<%= reverse_nested_folder %>../../public/javascripts/<%= "#{nested_folder}/" if nested_folder %><%= library_name %>.js" type="text/javascript"></script>
13
+
14
+ <link rel="stylesheet" href="<%= reverse_nested_folder %>assets/unittest.css" type="text/css" />
15
+ </head>
16
+ <body>
17
+
18
+ <div id="content">
19
+
20
+ <div id="header">
21
+ <h1>JavaScript unit test file</h1>
22
+ <p>
23
+ This file tests <strong><%= library_name %>.js</strong>.
24
+ </p>
25
+ </div>
26
+
27
+ <!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
28
+ <div id="testlog"></div>
29
+
30
+ <!-- Put sample/test html here -->
31
+ <div id="sample"></div>
32
+ </div>
33
+
34
+ <script type="text/javascript">
35
+ // <![CDATA[
36
+ context("<%= module_name %>", {
37
+ setup: function() {
38
+
39
+ }},
40
+ should("run tests", function() {
41
+
42
+ })
43
+ )();
44
+
45
+ // ]]>
46
+ </script>
47
+ </body>
48
+ </html>
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/newjs.rb'}"
9
+ puts "Loading newjs gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
@@ -1,5 +1,5 @@
1
+ #!/usr/bin/env ruby
1
2
  APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
2
- APP_ROOT = File.join(File.dirname(__FILE__), '..')
3
3
 
4
4
  begin
5
5
  require 'rubigen'
@@ -0,0 +1,18 @@
1
+ namespace 'vendor' do
2
+ namespace 'update' do
3
+ desc "Generates the latest jshoulda dist files into all the generators"
4
+ task :jshoulda do
5
+ require "fileutils"
6
+ FileUtils.mkdir_p(cache = "/tmp/jshoulda")
7
+ target_folders = `find * -name jshoulda.js | grep -v "^vendor" | sed -e "s/jshoulda.js$//"`.split("\n")
8
+
9
+ sh "cd vendor/jshoulda && rake dist"
10
+
11
+ %w[jshoulda.js].each do |f|
12
+ target_folders.each do |folder|
13
+ FileUtils.cp "vendor/jshoulda/dist/#{f}", folder
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ namespace 'vendor' do
2
+ namespace 'update' do
3
+ desc "Generates the latest jsunittest dist files into all the generators"
4
+ task :jsunittest do
5
+ require "fileutils"
6
+ FileUtils.mkdir_p(cache = "/tmp/jsunittest")
7
+ target_folders = `find * -name jsunittest.js | grep -v "^vendor" | sed -e "s/jsunittest.js$//"`.split("\n")
8
+
9
+ sh "cd vendor/jsunittest && rake dist"
10
+
11
+ %w[jsunittest.js unittest.css].each do |f|
12
+ target_folders.each do |folder|
13
+ FileUtils.cp "vendor/jsunittest/dist/#{f}", folder
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end