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
@@ -44,6 +44,19 @@ class TestFunctionalTestGenerator < Test::Unit::TestCase
44
44
  end
45
45
  end
46
46
 
47
+ def test_generator_with_jshoulda
48
+ name = "library"
49
+ run_generator('functional_test', [name, '--jshoulda'], sources)
50
+ assert_generated_file("test/assets/jshoulda.js")
51
+ assert_generated_file("test/functional/library_test.html") do |body|
52
+ expected = %Q{src="../assets/jshoulda.js"}
53
+ assert_match(expected, body)
54
+ expected = %Q{context("A context"}
55
+ assert_match(expected, body)
56
+ end
57
+ end
58
+
59
+
47
60
  private
48
61
  def sources
49
62
  [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
@@ -1,4 +1,8 @@
1
- require File.dirname(__FILE__) + '/test_helper'
1
+ begin
2
+ require File.dirname(__FILE__) + '/test_helper'
3
+ rescue LoadError
4
+ require 'test/unit'
5
+ end
2
6
  require 'fileutils'
3
7
 
4
8
  # Must set before requiring generator libs.
@@ -10,6 +14,11 @@ if defined?(APP_ROOT)
10
14
  else
11
15
  APP_ROOT = app_root
12
16
  end
17
+ if defined?(RAILS_ROOT)
18
+ RAILS_ROOT.replace(app_root)
19
+ else
20
+ RAILS_ROOT = app_root
21
+ end
13
22
 
14
23
  begin
15
24
  require 'rubigen'
@@ -0,0 +1,50 @@
1
+ require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
+
3
+
4
+ class TestPageGenerator < Test::Unit::TestCase
5
+ include RubiGen::GeneratorTestHelper
6
+
7
+ def setup
8
+ bare_setup
9
+ end
10
+
11
+ def teardown
12
+ bare_teardown
13
+ end
14
+
15
+ # Some generator-related assertions:
16
+ # assert_generated_file(name, &block) # block passed the file contents
17
+ # assert_directory_exists(name)
18
+ # assert_generated_class(name, &block)
19
+ # assert_generated_module(name, &block)
20
+ # assert_generated_test_for(name, &block)
21
+ # The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
22
+ # assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
23
+ #
24
+ # Other helper methods are:
25
+ # app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
26
+ # bare_setup - place this in setup method to create the APP_ROOT folder for each test
27
+ # bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
28
+
29
+ def test_generator_without_options
30
+ name = "myapp"
31
+ run_generator('page', [name], sources)
32
+ assert_directory_exists "src"
33
+ assert_directory_exists "test"
34
+ assert_generated_file "src/#{name}.html"
35
+ assert_generated_file "src/#{name}.js"
36
+ assert_generated_file "src/#{name}.css"
37
+ assert_generated_file "test/unit/#{name}_test.html"
38
+ assert_generated_file "test/fixtures/#{name}.js"
39
+ end
40
+
41
+ private
42
+ def sources
43
+ [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
44
+ ]
45
+ end
46
+
47
+ def generator_path
48
+ "newjs_iphone_generators"
49
+ end
50
+ end
@@ -0,0 +1,166 @@
1
+ require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
2
+
3
+ class TestRackJavascriptTestGenerator < Test::Unit::TestCase
4
+ include RubiGen::GeneratorTestHelper
5
+
6
+ def setup
7
+ bare_setup
8
+ end
9
+
10
+ def teardown
11
+ bare_teardown
12
+ end
13
+
14
+ # Some generator-related assertions:
15
+ # assert_generated_file(name, &block) # block passed the file contents
16
+ # assert_directory_exists(name)
17
+ # assert_generated_class(name, &block)
18
+ # assert_generated_module(name, &block)
19
+ # assert_generated_test_for(name, &block)
20
+ # The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
21
+ # assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
22
+ #
23
+ # Other helper methods are:
24
+ # app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
25
+ # bare_setup - place this in setup method to create the APP_ROOT folder for each test
26
+ # bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
27
+
28
+ def test_generator_without_options
29
+ name = "mylib"
30
+ run_generator('javascript_test', [name], sources)
31
+ assert_directory_exists "test/javascript/assets"
32
+ assert_directory_exists "vendor/plugins/javascript_unittest"
33
+ assert_directory_exists "script"
34
+ assert_generated_file "test/javascript/assets/jsunittest.js"
35
+ assert_generated_file "test/javascript/assets/unittest.css"
36
+ assert_generated_file "test/javascript/#{name}_test.html" do |body|
37
+ assert_match(%Q{src="assets/jsunittest.js"}, body)
38
+ assert_match(%Q{src="../../public/javascripts/mylib.js"}, body)
39
+ end
40
+ assert_generated_file "script/rstakeout"
41
+ assert_generated_file "script/js_autotest"
42
+ assert_generated_file "config/javascript_test_autotest.yml.sample"
43
+ assert_generated_file "vendor/plugins/javascript_unittest/lib/jstest.rb"
44
+ assert_generated_file "vendor/plugins/javascript_unittest/tasks/runner.rake"
45
+ assert_generated_file "vendor/plugins/javascript_unittest/tasks/autotest.rake"
46
+ assert_generated_file "vendor/plugins/javascript_unittest/README"
47
+ end
48
+
49
+ def test_generator_with_subfolder
50
+ name = "models/mylib"
51
+ run_generator('javascript_test', [name], sources)
52
+ assert_directory_exists "test/javascript/assets"
53
+ assert_directory_exists "test/javascript/models"
54
+ assert_directory_exists "vendor/plugins/javascript_unittest"
55
+ assert_directory_exists "script"
56
+ assert_generated_file "test/javascript/assets/jsunittest.js"
57
+ assert_generated_file "test/javascript/assets/unittest.css"
58
+ assert_generated_file "test/javascript/#{name}_test.html" do |body|
59
+ assert_match(%Q{src="../assets/jsunittest.js"}, body)
60
+ assert_match(%Q{src="../../../public/javascripts/models/mylib.js"}, body)
61
+ end
62
+ assert_generated_file "script/rstakeout"
63
+ assert_generated_file "script/js_autotest"
64
+ assert_generated_file "config/javascript_test_autotest.yml.sample"
65
+ assert_generated_file "vendor/plugins/javascript_unittest/lib/jstest.rb"
66
+ assert_generated_file "vendor/plugins/javascript_unittest/tasks/runner.rake"
67
+ assert_generated_file "vendor/plugins/javascript_unittest/tasks/autotest.rake"
68
+ assert_generated_file "vendor/plugins/javascript_unittest/README"
69
+ end
70
+
71
+ def test_generator_with_framework_jquery
72
+ name = "mylib"
73
+ run_generator('javascript_test', [name], sources, :framework => 'jquery')
74
+ assert_directory_exists "test/javascript/assets"
75
+ assert_directory_exists "public/javascripts/ext"
76
+ assert_directory_exists "vendor/plugins/javascript_unittest"
77
+ assert_directory_exists "script"
78
+ assert_generated_file "public/javascripts/ext/jquery.js"
79
+ assert_generated_file "test/javascript/assets/jsunittest.js"
80
+ assert_generated_file "test/javascript/assets/unittest.css"
81
+ assert_generated_file "test/javascript/#{name}_test.html" do |body|
82
+ assert_match(%Q{src="assets/jsunittest.js"}, body)
83
+ assert_match(%Q{src="../../public/javascripts/ext/jquery.js"}, body)
84
+ assert_match(%Q{src="../../public/javascripts/mylib.js"}, body)
85
+ end
86
+ assert_generated_file "script/rstakeout"
87
+ assert_generated_file "script/js_autotest"
88
+ assert_generated_file "config/javascript_test_autotest.yml.sample"
89
+ assert_generated_file "vendor/plugins/javascript_unittest/lib/jstest.rb"
90
+ assert_generated_file "vendor/plugins/javascript_unittest/tasks/runner.rake"
91
+ assert_generated_file "vendor/plugins/javascript_unittest/tasks/autotest.rake"
92
+ assert_generated_file "vendor/plugins/javascript_unittest/README"
93
+ end
94
+
95
+ def test_generator_with_framework_prototypejs
96
+ name = "mylib"
97
+ run_generator('javascript_test', [name], sources, :framework => 'prototype')
98
+ assert_directory_exists "test/javascript/assets"
99
+ assert_directory_exists "public/javascripts/ext"
100
+ assert_directory_exists "vendor/plugins/javascript_unittest"
101
+ assert_directory_exists "script"
102
+ assert_generated_file "public/javascripts/ext/prototype.js"
103
+ assert_generated_file "test/javascript/assets/jsunittest.js"
104
+ assert_generated_file "test/javascript/assets/unittest.css"
105
+ assert_generated_file "test/javascript/#{name}_test.html" do |body|
106
+ assert_match(%Q{src="assets/jsunittest.js"}, body)
107
+ assert_match(%Q{src="../../public/javascripts/ext/prototype.js"}, body)
108
+ assert_match(%Q{src="../../public/javascripts/mylib.js"}, body)
109
+ end
110
+ assert_generated_file "script/rstakeout"
111
+ assert_generated_file "script/js_autotest"
112
+ assert_generated_file "config/javascript_test_autotest.yml.sample"
113
+ assert_generated_file "vendor/plugins/javascript_unittest/lib/jstest.rb"
114
+ assert_generated_file "vendor/plugins/javascript_unittest/tasks/runner.rake"
115
+ assert_generated_file "vendor/plugins/javascript_unittest/tasks/autotest.rake"
116
+ assert_generated_file "vendor/plugins/javascript_unittest/README"
117
+ end
118
+
119
+ def test_generator_with_jshoulda
120
+ name = "mylib"
121
+ run_generator('javascript_test', [name], sources, :test_framework => 'jshoulda')
122
+ assert_generated_file "test/javascript/assets/jsunittest.js"
123
+ assert_generated_file "test/javascript/assets/jshoulda.js"
124
+ assert_generated_file "test/javascript/assets/unittest.css"
125
+ assert_generated_file "test/javascript/#{name}_test.html" do |body|
126
+ assert_match(%Q{src="assets/jsunittest.js"}, body)
127
+ assert_match(%Q{src="assets/jshoulda.js"}, body)
128
+ assert_match(%Q{src="../../public/javascripts/mylib.js"}, body)
129
+ assert_match(%Q{context("Mylib", \{}, body)
130
+ end
131
+ end
132
+
133
+ def test_generator_and_library
134
+ name = "mylib"
135
+ run_generator('javascript_test', [name], sources, :library => true)
136
+ assert_directory_exists "test/javascript/assets"
137
+ assert_directory_exists "vendor/plugins/javascript_unittest"
138
+ assert_directory_exists "script"
139
+ assert_generated_file "public/javascripts/mylib.js" do |body|
140
+ assert_match("var Mylib = function() {", body)
141
+ end
142
+ assert_generated_file "test/javascript/assets/jsunittest.js"
143
+ assert_generated_file "test/javascript/assets/unittest.css"
144
+ assert_generated_file "test/javascript/#{name}_test.html" do |body|
145
+ assert_match(%Q{src="assets/jsunittest.js"}, body)
146
+ assert_match(%Q{src="../../public/javascripts/mylib.js"}, body)
147
+ end
148
+ assert_generated_file "script/rstakeout"
149
+ assert_generated_file "script/js_autotest"
150
+ assert_generated_file "config/javascript_test_autotest.yml.sample"
151
+ assert_generated_file "vendor/plugins/javascript_unittest/lib/jstest.rb"
152
+ assert_generated_file "vendor/plugins/javascript_unittest/tasks/runner.rake"
153
+ assert_generated_file "vendor/plugins/javascript_unittest/tasks/autotest.rake"
154
+ assert_generated_file "vendor/plugins/javascript_unittest/README"
155
+ end
156
+
157
+ private
158
+ def sources
159
+ [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
160
+ ]
161
+ end
162
+
163
+ def generator_path
164
+ "rack_generators"
165
+ end
166
+ end
@@ -7,7 +7,7 @@ module Rails
7
7
  end
8
8
  end
9
9
 
10
- class TestJavascriptTestGenerator < Test::Unit::TestCase
10
+ class TestRailsJavascriptTestGenerator < Test::Unit::TestCase
11
11
  include RubiGen::GeneratorTestHelper
12
12
 
13
13
  def setup
@@ -123,6 +123,20 @@ class TestJavascriptTestGenerator < Test::Unit::TestCase
123
123
  assert_generated_file "vendor/plugins/javascript_unittest/README"
124
124
  end
125
125
 
126
+ def test_generator_with_jshoulda
127
+ name = "mylib"
128
+ run_generator('javascript_test', [name], sources, :test_framework => 'jshoulda')
129
+ assert_generated_file "test/javascript/assets/jsunittest.js"
130
+ assert_generated_file "test/javascript/assets/jshoulda.js"
131
+ assert_generated_file "test/javascript/assets/unittest.css"
132
+ assert_generated_file "test/javascript/#{name}_test.html" do |body|
133
+ assert_match(%Q{src="assets/jsunittest.js"}, body)
134
+ assert_match(%Q{src="assets/jshoulda.js"}, body)
135
+ assert_match(%Q{src="../../public/javascripts/mylib.js"}, body)
136
+ assert_match(%Q{context("Mylib", \{}, body)
137
+ end
138
+ end
139
+
126
140
  def test_generator_and_library
127
141
  name = "mylib"
128
142
  run_generator('javascript_test', [name], sources, :library => true)
@@ -44,6 +44,19 @@ class TestUnitTestGenerator < Test::Unit::TestCase
44
44
  end
45
45
  end
46
46
 
47
+ def test_generator_with_jshoulda
48
+ name = "library"
49
+ run_generator('unit_test', [name, '--jshoulda'], sources)
50
+ assert_generated_file("test/assets/jshoulda.js")
51
+ assert_generated_file("test/unit/library_test.html") do |body|
52
+ expected = %Q{src="../assets/jshoulda.js"}
53
+ assert_match(expected, body)
54
+ expected = %Q{context("Library"}
55
+ assert_match(expected, body)
56
+ end
57
+ end
58
+
59
+
47
60
  private
48
61
  def sources
49
62
  [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
@@ -0,0 +1,108 @@
1
+ == 1.2.1 2009-02-24
2
+
3
+ * New methods `useStyle` and `defineStyle`. Now for using the pair name "describe/it" all you have to do is
4
+
5
+ jShoulda.useStyle('describe');
6
+
7
+ Predefined styles are 'describe' for "describe/it" pair and 'context' or 'should' for the "context/should" pair.
8
+
9
+ `context` and `should` methods are still exported by default. This may change in next releases.
10
+
11
+ To define new styles, pass a style-name and a configuration object to `jShoulda.defineStyle`. Properties expected in the configuration are:
12
+
13
+ * context: an array containing names and connectors for the exportable _context_ methods
14
+ * should: an array containing names and connectors for the exportable _should_ methods
15
+ * (optional) unify: unify runners when using this style
16
+
17
+ Example:
18
+
19
+ // defining an style (better in an external shared script)
20
+ jShoulda
21
+ .defineStyle('my_custom_style', {
22
+ context: [ 'some', 'A' ],
23
+ should: [ 'does', '', 'and', '' ],
24
+ unify: true
25
+ });
26
+
27
+ // using it
28
+ jShoulda
29
+ .useStyle('my_custom_style');
30
+
31
+
32
+ == 1.2 2008-11-20
33
+
34
+ * By default, each root context creates a new Test.Unit.Runner instance, so if tests are loaded from multiple files (or the same file includes multiple root contexts), and logged to the same table, header will show incorrect data. (And worst, only one of the results would get logged by the rake task.)
35
+
36
+ Now, you can use `jShoulda.unifyRunners()` to get all your tests pushed to the same runner. In addition, if you have already written tests through the "traditional" syntax, you can pass your test runner, which will be reused.
37
+
38
+
39
+
40
+ * The configuration object can contain properties (other than setup/teardown/before/after) which are copied to each Test.Unit in the context—that is, are accesible through `this` inside your _should_ callbacks. Best understood through example:
41
+
42
+ context("A 'should' execution", {
43
+ assertLocalYipiyay : function(input, msg) {
44
+ this.assertEqual('yipiyay', input, msg);
45
+ }
46
+ },
47
+ should("get access to extra properties defined on the configuration parameter", function() {
48
+ this.assertLocalYipiyay('yipiyay');
49
+ })
50
+ )();
51
+
52
+ * The context aliaser is now a real generator and accepts a prefix as a second argument. So, for this testing code
53
+
54
+ jShoulda
55
+ .setContextAlias('un', 'Un')
56
+ .setContextAlias('para', 'para')
57
+ .setShouldAlias('deberia', 'debería');
58
+
59
+ un("programador",
60
+ para("ser feliz",
61
+ deberia("poder comer melocotones de Calanda todo el año", function() {
62
+ })
63
+ )
64
+ )();
65
+
66
+ the outputted name for our test will be "Un programador para ser feliz debería poder comer melocotones de Calanda todo el año".
67
+
68
+ * Contexts are now allowed to be anonymous.
69
+
70
+ == 1.1 2008-11-09
71
+
72
+ * jShoulda is now a global symbol
73
+ * Refactored code to allow simple aliasing
74
+ * Aliasing methods jShoulda.setShouldAlias and jShoulda.setContextAlias
75
+ * Configurable connector deprecated (and removed) in favor of jShoulda.setShouldAlias method.
76
+ * global methods `should` and `context` are now created through aliasing
77
+ * Try this, babe
78
+
79
+ jShoulda.setContextAlias('describe').setShouldAlias('it', '');
80
+ describe("A context", {},
81
+ it("runs tests", function() {
82
+ this.assert(true);
83
+ })
84
+ )();
85
+
86
+ * The configuration object (setup/teardown) is now optional
87
+ * before/after are documented alias to setup/teardown since this very moment.
88
+
89
+ == 1.0.1 2008-10-31
90
+
91
+ * Configurable connector. Overwrite `should.connector` if you want to use a localized connector.
92
+
93
+ == 1.0 2008-10-18
94
+
95
+ * Version set to 1.0, no code changes
96
+
97
+ == 0.0.3 2008-10-11
98
+
99
+ * Proven to work with the original Prototype unittest.js
100
+
101
+ == 0.0.2 2008-10-07
102
+
103
+ * Now the root context invocation returns a Test.Runner instance
104
+
105
+ == 0.0.1 2008-10-05
106
+
107
+ * 1 major enhancement:
108
+ * Initial release
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Choan Galvez
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,34 @@
1
+ # jShoulda
2
+
3
+ jShoulda is a wrapper for [JsUnitTest](http://github.com/drnic/jsunittest/) which allows the developer to write Shoulda-like tests.
4
+
5
+ Please visit <http://jshoulda.scriptia.net> for more information.
6
+
7
+ ## Example
8
+
9
+ context('A context', {
10
+ setup: function() {
11
+ // do your setup
12
+ this.something = 1
13
+ },
14
+ teardown: function() {
15
+ // do your cleaning
16
+ }
17
+ },
18
+ should('run its setup function', function() {
19
+ this.assertEqual(1, this.something);
20
+ }),
21
+ context('which is an inner context', function() {
22
+ setup: function() {
23
+ this.something += 1;
24
+ }
25
+ },
26
+ should('run both setup functions', function() {
27
+ this.assertEqual(2, this.something);
28
+ })
29
+ )
30
+ )();
31
+
32
+ ## Author, license, source code
33
+
34
+ jShoulda has been created by <a href="http://choangalvez.nom.es/" hreflang="es">Choan Galvez</a> and is freely distributable under the terms of a MIT-style license. The source code resides in a <a href="http://github.com/choan/jshoulda/">Git repository at github</a>.