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,13 @@
1
+ Feature: Development processes of newgem itself (rake tasks)
2
+
3
+ As a Newgem maintainer or contributor
4
+ I want rake tasks to maintain and release the gem
5
+ So that I can spend time on the tests and code, and not excessive time on maintenance processes
6
+
7
+ Scenario: Generate RubyGem
8
+ Given this project is active project folder
9
+ And 'pkg' folder is deleted
10
+ When task 'rake gem' is invoked
11
+ Then folder 'pkg' is created
12
+ And file with name matching 'pkg/*.gem' is created else you should run "rake manifest" to fix this
13
+ And gem spec key 'rdoc_options' contains /--mainREADME.rdoc/
@@ -0,0 +1,19 @@
1
+ Feature: Apply the latest distribution files from vendored projects into generators
2
+ In order to cheaply include latest JS libraries into the generators
3
+ As a newjs developer/deployer
4
+ I want to copy into newjs generators the JavaScript files from vendored projects
5
+
6
+ Scenario: Copy across jsunittest into generators
7
+ Given this project is active project folder
8
+ When task 'rake vendor:update:jsunittest' is invoked
9
+ Then file 'app_generators/newjs/templates/test/assets/jsunittest.js' is same as file 'vendor/jsunittest/dist/jsunittest.js'
10
+ Then file 'app_generators/newjs/templates/test/assets/unittest.css' is same as file 'vendor/jsunittest/dist/unittest.css'
11
+ Then file 'app_generators/newjs_iphone/templates/Html/test/assets/jsunittest.js' is same as file 'vendor/jsunittest/dist/jsunittest.js'
12
+ Then file 'app_generators/newjs_iphone/templates/Html/test/assets/unittest.css' is same as file 'vendor/jsunittest/dist/unittest.css'
13
+ Then file 'rails_generators/javascript_test/templates/assets/jsunittest.js' is same as file 'vendor/jsunittest/dist/jsunittest.js'
14
+ Then file 'rails_generators/javascript_test/templates/assets/unittest.css' is same as file 'vendor/jsunittest/dist/unittest.css'
15
+
16
+ Scenario: Copy across jshoulda into generators
17
+ Given this project is active project folder
18
+ When task 'rake vendor:update:jshoulda' is invoked
19
+ Then file 'rails_generators/javascript_test/templates/assets/jshoulda.js' is same as file 'vendor/jshoulda/dist/jshoulda.js'
@@ -0,0 +1,205 @@
1
+ def in_project_folder(&block)
2
+ project_folder = @active_project_folder || @tmp_root
3
+ FileUtils.chdir(project_folder, &block)
4
+ end
5
+
6
+ def in_home_folder(&block)
7
+ FileUtils.chdir(@home_path, &block)
8
+ end
9
+
10
+ Given %r{^a safe folder} do
11
+ FileUtils.rm_rf @tmp_root = File.dirname(__FILE__) + "/../../tmp"
12
+ FileUtils.mkdir_p @tmp_root
13
+ FileUtils.mkdir_p @home_path = File.expand_path(File.join(@tmp_root, "home"))
14
+ @lib_path = File.expand_path(File.dirname(__FILE__) + '/../../lib')
15
+ Given "env variable $HOME set to '#{@home_path}'"
16
+ end
17
+
18
+ Given %r{^this project is active project folder} do
19
+ Given "a safe folder"
20
+ @active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
21
+ end
22
+
23
+ Given %r{^env variable \$([\w_]+) set to '(.*)'} do |env_var, value|
24
+ ENV[env_var] = value
25
+ end
26
+
27
+ def force_local_lib_override(project_name = @project_name)
28
+ rakefile = File.read(File.join(project_name, 'Rakefile'))
29
+ File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
30
+ f << "$:.unshift('#{@lib_path}')\n"
31
+ f << rakefile
32
+ end
33
+ end
34
+
35
+ def setup_active_project_folder project_name
36
+ @active_project_folder = File.join(@tmp_root, project_name)
37
+ @project_name = project_name
38
+ end
39
+
40
+ Given %r{'(.*)' folder is deleted} do |folder|
41
+ in_project_folder do
42
+ FileUtils.rm_rf folder
43
+ end
44
+ end
45
+
46
+ When %r{^'(.*)' generator is invoked with arguments '(.*)'$} do |generator, arguments|
47
+ @stdout = StringIO.new
48
+ FileUtils.chdir(@active_project_folder) do
49
+ if Object.const_defined?("APP_ROOT")
50
+ APP_ROOT.replace(FileUtils.pwd)
51
+ else
52
+ APP_ROOT = FileUtils.pwd
53
+ end
54
+ run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout)
55
+ end
56
+ File.open(File.join(@tmp_root, "generator.out"), "w") do |f|
57
+ @stdout.rewind
58
+ f << @stdout.read
59
+ end
60
+ end
61
+
62
+ When %r{run executable '(.*)' with arguments '(.*)'} do |executable, arguments|
63
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
64
+ in_project_folder do
65
+ system "#{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
66
+ end
67
+ end
68
+
69
+ When %r{run project executable '(.*)' with arguments '(.*)'} do |executable, arguments|
70
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
71
+ in_project_folder do
72
+ system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
73
+ end
74
+ end
75
+
76
+ When %r{run local executable '(.*)' with arguments '(.*)'} do |executable, arguments|
77
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
78
+ executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
79
+ in_project_folder do
80
+ system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
81
+ end
82
+ end
83
+
84
+ When %r{^task 'rake (.*)' is invoked$} do |task|
85
+ @stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
86
+ FileUtils.chdir(@active_project_folder) do
87
+ system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
88
+ end
89
+ end
90
+
91
+ Then %r{^folder '(.*)' (is|is not) created} do |folder, is|
92
+ in_project_folder do
93
+ File.exists?(folder).should(is == 'is' ? be_true : be_false)
94
+ end
95
+ end
96
+
97
+ Then %r{^file '(.*)' (is|is not) created} do |file, is|
98
+ in_project_folder do
99
+ File.exists?(file).should(is == 'is' ? be_true : be_false)
100
+ end
101
+ end
102
+
103
+ Then %r{^file with name matching '(.*)' is created} do |pattern|
104
+ in_project_folder do
105
+ Dir[pattern].should_not be_empty
106
+ end
107
+ end
108
+
109
+ Then %r{^file '(.*)' is same as file '(.*)'} do |file1, file2|
110
+ in_project_folder do
111
+ File.exists?(file1)
112
+ File.exists?(file2)
113
+ file1_contents = File.read(file1)
114
+ file2_contents = File.read(file2)
115
+ file1_contents.should == file2_contents
116
+ end
117
+ end
118
+
119
+
120
+ Then %r{gem file '(.*)' and generated file '(.*)' should be the same} do |gem_file, project_file|
121
+ File.exists?(gem_file).should be_true
122
+ File.exists?(project_file).should be_true
123
+ gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
124
+ project_file_contents = File.read(File.join(@active_project_folder, project_file))
125
+ project_file_contents.should == gem_file_contents
126
+ end
127
+
128
+ Then %r{^output same as contents of '(.*)'$} do |file|
129
+ expected_output = File.read(File.join(File.dirname(__FILE__) + "/../expected_outputs", file))
130
+ actual_output = File.read(@stdout)
131
+ actual_output.should == expected_output
132
+ end
133
+
134
+ Then %r{^(does|does not) invoke generator '(.*)'$} do |does_invoke, generator|
135
+ actual_output = File.read(@stdout)
136
+ does_invoke == "does" ?
137
+ actual_output.should(match(/dependency\s+#{generator}/)) :
138
+ actual_output.should_not(match(/dependency\s+#{generator}/))
139
+ end
140
+
141
+ Then %r{help options '(.*)' and '(.*)' are displayed} do |opt1, opt2|
142
+ actual_output = File.read(@stdout)
143
+ actual_output.should match(/#{opt1}/)
144
+ actual_output.should match(/#{opt2}/)
145
+ end
146
+
147
+ Then %r{^output (does|does not) match \/(.*)\/} do |does, regex|
148
+ actual_output = File.read(@stdout)
149
+ (does == 'does') ?
150
+ actual_output.should(match(/#{regex}/)) :
151
+ actual_output.should_not(match(/#{regex}/))
152
+ end
153
+
154
+ Then %r{^contents of file '(.*)' (does|does not) match \/(.*)\/} do |file, does, regex|
155
+ in_project_folder do
156
+ actual_output = File.read(file)
157
+ (does == 'does') ?
158
+ actual_output.should(match(/#{regex}/)) :
159
+ actual_output.should_not(match(/#{regex}/))
160
+ end
161
+ end
162
+
163
+ Then %r{^all (\d+) tests pass} do |expected_test_count|
164
+ expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
165
+ actual_output = File.read(@stdout)
166
+ actual_output.should match(expected)
167
+ end
168
+
169
+ Then %r{^all (\d+) examples pass} do |expected_test_count|
170
+ expected = %r{^#{expected_test_count} examples?, 0 failures}
171
+ actual_output = File.read(@stdout)
172
+ actual_output.should match(expected)
173
+ end
174
+
175
+ Then %r{^yaml file '(.*)' contains (\{.*\})} do |file, yaml|
176
+ in_project_folder do
177
+ yaml = eval yaml
178
+ YAML.load(File.read(file)).should == yaml
179
+ end
180
+ end
181
+
182
+ Then %r{^Rakefile can display tasks successfully} do
183
+ @stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
184
+ FileUtils.chdir(@active_project_folder) do
185
+ system "rake -T > #{@stdout} 2> #{@stdout}"
186
+ end
187
+ actual_output = File.read(@stdout)
188
+ actual_output.should match(/^rake\s+\w+\s+#\s.*/)
189
+ end
190
+
191
+ Then %r{^task 'rake (.*)' is executed successfully} do |task|
192
+ @stdout.should_not be_nil
193
+ actual_output = File.read(@stdout)
194
+ actual_output.should_not match(/^Don't know how to build task '#{task}'/)
195
+ actual_output.should_not match(/Error/i)
196
+ end
197
+
198
+ Then %r{^gem spec key '(.*)' contains \/(.*)\/} do |key, regex|
199
+ in_project_folder do
200
+ gem_file = Dir["pkg/*.gem"].first
201
+ gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
202
+ spec_value = gem_spec.send(key.to_sym)
203
+ spec_value.to_s.should match(/#{regex}/)
204
+ end
205
+ end
@@ -0,0 +1,6 @@
1
+ require File.dirname(__FILE__) + "/../../lib/newjs"
2
+
3
+ gem 'cucumber'
4
+ require 'cucumber'
5
+ gem 'rspec'
6
+ require 'spec'
@@ -1,6 +1,6 @@
1
1
  class FunctionalTestGenerator < RubiGen::Base
2
2
 
3
- attr_reader :name, :dist_name
3
+ attr_reader :name, :dist_name, :testing_lib
4
4
 
5
5
  def initialize(runtime_args, runtime_options = {})
6
6
  super
@@ -15,6 +15,12 @@ class FunctionalTestGenerator < RubiGen::Base
15
15
  # Ensure appropriate folder(s) exists
16
16
  m.directory 'test/functional'
17
17
 
18
+ if testing_lib == 'jshoulda'
19
+ # Ensure jshoulda exists. TODO Should be moved to the newjs generator?
20
+ m.directory 'test/assets'
21
+ m.file 'test/assets/jshoulda.js', 'test/assets/jshoulda.js', :collision => :skip
22
+ end
23
+
18
24
  # Create stubs
19
25
  m.template "test/test.html.erb", "test/functional/#{name}_test.html"
20
26
  end
@@ -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("--jshoulda", "Use jShoulda to write the test") { |v| options[:testing_lib] = '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
+ @testing_lib = options[:testing_lib]
53
61
  end
54
62
  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');