vraptor-scaffold 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. data/.travis.yml +7 -0
  2. data/CHANGELOG.rdoc +164 -0
  3. data/Gemfile.lock +5 -8
  4. data/README.textile +20 -7
  5. data/bin/vraptor +1 -1
  6. data/index.sample.html +169 -0
  7. data/lib/vraptor-scaffold.rb +10 -29
  8. data/lib/vraptor-scaffold/configuration.rb +27 -4
  9. data/lib/vraptor-scaffold/execution.rb +24 -0
  10. data/lib/vraptor-scaffold/generators/app/app_generator.rb +196 -0
  11. data/lib/vraptor-scaffold/generators/{app_generator → app}/dependency.rb +0 -0
  12. data/lib/vraptor-scaffold/generators/app/dependency_manager.rb +53 -0
  13. data/lib/vraptor-scaffold/generators/{app_generator → app}/freemarker_template_engine.rb +0 -0
  14. data/lib/vraptor-scaffold/generators/{app_generator → app}/jsp_template_engine.rb +0 -0
  15. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/build.gradle.erb +19 -1
  16. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/build.properties.erb +0 -0
  17. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/build.xml +6 -2
  18. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/decorators.erb +0 -0
  19. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/classpath.erb +0 -5
  20. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/project.erb +0 -0
  21. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.jdt.core.prefs +0 -0
  22. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.common.component.tt +0 -0
  23. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.common.project.facet.core.xml +0 -0
  24. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.container +0 -0
  25. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.name +0 -0
  26. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/freemarker-web.xml +0 -0
  27. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/infrastructure/FreemarkerPathResolver.java.tt +0 -0
  28. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/macros/html.ftl +0 -0
  29. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/main.ftl +0 -0
  30. data/lib/vraptor-scaffold/generators/app/templates/heroku/Main.java +21 -0
  31. data/lib/vraptor-scaffold/generators/app/templates/heroku/Procfile +1 -0
  32. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/ivy-2.2.0.jar +0 -0
  33. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/ivy.erb +1 -1
  34. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/jsp/jsp-web.xml +0 -0
  35. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/jsp/main.jsp +2 -2
  36. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/jsp/prelude.jspf +0 -0
  37. data/lib/vraptor-scaffold/generators/{app_generator/templates/src/models/Entity.java.tt → app/templates/models/Entity.erb} +1 -1
  38. data/lib/vraptor-scaffold/generators/app/templates/orm/Repository-hibernate.java.tt +50 -0
  39. data/lib/vraptor-scaffold/generators/{app_generator/templates/src/repositories/Repository.java.tt → app/templates/orm/Repository-jpa.java.tt} +3 -3
  40. data/lib/vraptor-scaffold/generators/app/templates/orm/hibernate.cfg.xml +7 -0
  41. data/lib/vraptor-scaffold/generators/app/templates/orm/persistence.xml +10 -0
  42. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/pom.erb +29 -13
  43. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/resources-test/.empty_directory +0 -0
  44. data/lib/vraptor-scaffold/generators/app/templates/resources/hibernate.properties +16 -0
  45. data/lib/vraptor-scaffold/generators/app/templates/resources/log4j.properties +4 -0
  46. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/resources/messages.properties +0 -0
  47. data/lib/vraptor-scaffold/generators/app/templates/vraptor-scaffold.erb +7 -0
  48. data/lib/vraptor-scaffold/generators/{app_generator/templates/webapp/WEB-INF/web.xml → app/templates/webapp/WEB-INF/web.xml.tt} +2 -2
  49. data/lib/vraptor-scaffold/generators/{app_generator/templates/src-test/controllers → app/templates/webapp/images}/.empty_directory +0 -0
  50. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/index.jsp +0 -0
  51. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/stylesheets/common.css +0 -0
  52. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/stylesheets/scaffold.css +0 -0
  53. data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/stylesheets/stylesheets.css +0 -0
  54. data/lib/vraptor-scaffold/generators/plugin/plugin_generator.rb +42 -0
  55. data/lib/vraptor-scaffold/generators/plugin/vraptor_gem.rb +36 -0
  56. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/attribute.rb +1 -1
  57. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/base_scaffold.rb +6 -2
  58. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/controller_generator.rb +3 -3
  59. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/templates/controller.erb +3 -3
  60. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/templates/controller_test.erb +1 -1
  61. data/lib/vraptor-scaffold/generators/scaffold/model_generator/model_generator.rb +20 -0
  62. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/model_generator/templates/model.erb +3 -3
  63. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/model_generator/templates/model_test.erb +1 -1
  64. data/lib/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator.rb +27 -0
  65. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/repository.erb +3 -3
  66. data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/repository_impl.erb +16 -0
  67. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/repository_test.erb +1 -1
  68. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/scaffold_generator.rb +0 -0
  69. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/freemarker_generator.rb +18 -0
  70. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/freemarker_generator/templates/edit.erb +0 -0
  71. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/freemarker_generator/templates/form.erb +4 -4
  72. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/templates/index.erb +36 -0
  73. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/freemarker_generator/templates/new.erb +0 -0
  74. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/templates/show.erb +14 -0
  75. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/jsp_generator/jsp_generator.rb +18 -0
  76. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/edit.erb +0 -0
  77. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/form.erb +4 -4
  78. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/index.erb +6 -6
  79. data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/new.erb +0 -0
  80. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/jsp_generator/templates/show.erb +14 -0
  81. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/template_engine_generator.rb +21 -0
  82. data/lib/vraptor-scaffold/load_paths.rb +13 -21
  83. data/lib/vraptor-scaffold/runner.rb +11 -0
  84. data/lib/vraptor-scaffold/runner/commands_help.rb +13 -0
  85. data/lib/vraptor-scaffold/runner/configure.rb +21 -0
  86. data/lib/vraptor-scaffold/runner/generator.rb +15 -0
  87. data/lib/vraptor-scaffold/runner/help.rb +12 -0
  88. data/lib/vraptor-scaffold/runner/plugin.rb +19 -0
  89. data/lib/vraptor-scaffold/runner/scaffold.rb +16 -0
  90. data/lib/vraptor-scaffold/version.rb +1 -1
  91. data/spec/resources/vraptor-scaffold.properties +5 -0
  92. data/spec/simple_custom_plugin.rb +10 -0
  93. data/spec/spec_helper.rb +5 -6
  94. data/spec/vraptor-scaffold/configuration_spec.rb +88 -4
  95. data/spec/vraptor-scaffold/execution_spec.rb +47 -0
  96. data/spec/vraptor-scaffold/generators/{app_generator → app}/app_generator_spec.rb +136 -54
  97. data/spec/vraptor-scaffold/generators/{app_generator → app}/dependency_manager_spec.rb +1 -1
  98. data/spec/vraptor-scaffold/generators/{app_generator → app}/dependency_spec.rb +0 -0
  99. data/spec/vraptor-scaffold/generators/{app_generator → app}/freemarker_template_engine_spec.rb +1 -1
  100. data/spec/vraptor-scaffold/generators/{app_generator → app}/jsp_template_engine_spec.rb +0 -0
  101. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/Entity.java +1 -1
  102. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/FreemarkerPathResolver.java +0 -0
  103. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/Repository.java +3 -3
  104. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/build.gradle +24 -5
  105. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/build.properties +0 -0
  106. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/decorators-jsp.xml +0 -0
  107. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/decorators.xml +0 -0
  108. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker-web.xml +2 -2
  109. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/ivy.xml +6 -5
  110. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/jsp-web.xml +1 -1
  111. data/spec/vraptor-scaffold/generators/app/templates/pom-heroku.xml +168 -0
  112. data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/pom.xml +11 -14
  113. data/spec/vraptor-scaffold/generators/app/templates/vraptor-scaffold.properties +7 -0
  114. data/spec/vraptor-scaffold/generators/plugin/expected_configs/build.gradle +61 -0
  115. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_build.gradle +61 -0
  116. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_ivy.xml +40 -0
  117. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_pom.xml +147 -0
  118. data/spec/vraptor-scaffold/generators/plugin/expected_configs/ivy.xml +40 -0
  119. data/spec/vraptor-scaffold/generators/plugin/expected_configs/pom.xml +147 -0
  120. data/spec/vraptor-scaffold/generators/plugin/plugin_generator_spec.rb +130 -0
  121. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/attribute_spec.rb +13 -9
  122. data/spec/vraptor-scaffold/generators/scaffold/base_scaffold_spec.rb +73 -0
  123. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/controller_generator_spec.rb +18 -9
  124. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/templates/ProductController.java +3 -3
  125. data/spec/vraptor-scaffold/generators/scaffold/freemarker_generator/freemarker_generator_spec.rb +74 -0
  126. data/spec/vraptor-scaffold/generators/scaffold/jsp_generator/jsp_generator_spec.rb +75 -0
  127. data/spec/vraptor-scaffold/generators/scaffold/model_generator/model_generator_spec.rb +50 -0
  128. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/model_generator/templates/Product.java +6 -6
  129. data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/hibernate.cfg.xml +8 -0
  130. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator_spec.rb +60 -0
  131. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ClientRepository.java +22 -0
  132. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ClientRepositoryImpl.java +16 -0
  133. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/ProductRepository.java +3 -3
  134. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/ProductRepositoryImpl.java +3 -3
  135. data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/scaffold_generator_spec.rb +0 -0
  136. data/spec/vraptor-scaffold/runner/commands_help_spec.rb +12 -0
  137. data/spec/vraptor-scaffold/runner/configure_spec.rb +12 -0
  138. data/spec/vraptor-scaffold/runner/generator_spec.rb +31 -0
  139. data/spec/vraptor-scaffold/runner/help_spec.rb +29 -0
  140. data/spec/vraptor-scaffold/runner/plugin_spec.rb +45 -0
  141. data/spec/vraptor-scaffold/runner/scaffold_spec.rb +35 -0
  142. data/spec/vraptor-scaffold_spec.rb +1 -94
  143. data/vraptor-scaffold.gemspec +3 -3
  144. metadata +137 -140
  145. data/History.txt +0 -128
  146. data/lib/vraptor-scaffold/generators/app_generator/app_generator.rb +0 -102
  147. data/lib/vraptor-scaffold/generators/app_generator/dependency_manager.rb +0 -37
  148. data/lib/vraptor-scaffold/generators/app_generator/templates/ivysettings.xml +0 -9
  149. data/lib/vraptor-scaffold/generators/app_generator/templates/resources/META-INF/persistence.xml +0 -20
  150. data/lib/vraptor-scaffold/generators/app_generator/templates/resources/log4j.properties +0 -4
  151. data/lib/vraptor-scaffold/generators/app_generator/templates/src-test/models/.empty_directory +0 -0
  152. data/lib/vraptor-scaffold/generators/app_generator/templates/src-test/repositories/.empty_directory +0 -0
  153. data/lib/vraptor-scaffold/generators/app_generator/templates/src/controllers/.empty_directory +0 -0
  154. data/lib/vraptor-scaffold/generators/app_generator/templates/vraptor-scaffold.erb +0 -2
  155. data/lib/vraptor-scaffold/generators/app_generator/templates/webapp/images/.empty_directory +0 -0
  156. data/lib/vraptor-scaffold/generators/app_generator/templates/webapp/javascripts/application.js +0 -0
  157. data/lib/vraptor-scaffold/generators/app_generator/templates/webapp/javascripts/jquery.min.js +0 -16
  158. data/lib/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/freemarker_generator.rb +0 -22
  159. data/lib/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/templates/index.erb +0 -36
  160. data/lib/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/templates/show.erb +0 -14
  161. data/lib/vraptor-scaffold/generators/scaffold_generator/jsp_generator/jsp_generator.rb +0 -22
  162. data/lib/vraptor-scaffold/generators/scaffold_generator/jsp_generator/templates/show.erb +0 -14
  163. data/lib/vraptor-scaffold/generators/scaffold_generator/model_generator/model_generator.rb +0 -11
  164. data/lib/vraptor-scaffold/generators/scaffold_generator/repository_generator/repository_generator.rb +0 -12
  165. data/lib/vraptor-scaffold/generators/scaffold_generator/repository_generator/templates/repository_impl.erb +0 -16
  166. data/spec/vraptor-scaffold/generators/scaffold_generator/base_scaffold_spec.rb +0 -41
  167. data/spec/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/freemarker_generator_spec.rb +0 -36
  168. data/spec/vraptor-scaffold/generators/scaffold_generator/jsp_generator/jsp_generator_spec.rb +0 -34
  169. data/spec/vraptor-scaffold/generators/scaffold_generator/model_generator/model_generator_spec.rb +0 -25
  170. data/spec/vraptor-scaffold/generators/scaffold_generator/repository_generator/repository_generator_spec.rb +0 -31
@@ -19,7 +19,11 @@ describe Attribute do
19
19
  end
20
20
 
21
21
  it "should camelize composed name" do
22
- Attribute.new("NomeComposto", "double").name.should == "nomeComposto"
22
+ Attribute.new("MyItem", "double").name.should == "myItem"
23
+ end
24
+
25
+ it "should camelize composed name" do
26
+ Attribute.new("myItem", "double").name.should == "myItem"
23
27
  end
24
28
 
25
29
  it "should keep name in downcase" do
@@ -101,35 +105,35 @@ describe Attribute do
101
105
  end
102
106
 
103
107
  context "java type" do
104
- it "should know corret java type to boolean" do
108
+ it "should know correct java type to boolean" do
105
109
  Attribute.new("flag", "boolean").java_type.should eql("boolean")
106
110
  end
107
111
 
108
- it "should know corret java type to text" do
112
+ it "should know correct java type to text" do
109
113
  Attribute.new("description", "text").java_type.should eql("String")
110
114
  end
111
115
 
112
- it "should know corret java type to string" do
116
+ it "should know correct java type to string" do
113
117
  Attribute.new("name", "string").java_type.should eql("String")
114
118
  end
115
119
 
116
- it "should know corret java type to double" do
120
+ it "should know correct java type to double" do
117
121
  Attribute.new("name", "double").java_type.should eql("Double")
118
122
  end
119
123
 
120
- it "should know corret java type to float" do
124
+ it "should know correct java type to float" do
121
125
  Attribute.new("name", "float").java_type.should eql("Float")
122
126
  end
123
127
 
124
- it "should know corret java type to short" do
128
+ it "should know correct java type to short" do
125
129
  Attribute.new("name", "short").java_type.should eql("Short")
126
130
  end
127
131
 
128
- it "should know corret java type to integer" do
132
+ it "should know correct java type to integer" do
129
133
  Attribute.new("name", "integer").java_type.should eql("Integer")
130
134
  end
131
135
 
132
- it "should know corret java type to long" do
136
+ it "should know correct java type to long" do
133
137
  Attribute.new("name", "long").java_type.should eql("Long")
134
138
  end
135
139
  end
@@ -0,0 +1,73 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
2
+
3
+ describe BaseScaffold do
4
+
5
+ context "simple model name" do
6
+ before(:each) do
7
+ @base = BaseScaffold.new("client")
8
+ end
9
+
10
+ it "should know model class name" do
11
+ @base.class_name.should eql("Client")
12
+ end
13
+
14
+ it "should know model test class name" do
15
+ @base.test_class_name.should eql("ClientTest")
16
+ end
17
+
18
+ it "should know repository class name impl" do
19
+ @base.repository_impl_name.should eql("ClientRepositoryImpl")
20
+ end
21
+
22
+ it "should know repository interface name" do
23
+ @base.repository_interface_name.should eql("ClientRepository")
24
+ end
25
+
26
+ it "should know repository test class name" do
27
+ @base.repository_test_class_name.should eql("ClientRepositoryImplTest")
28
+ end
29
+
30
+ it "should know controller class name" do
31
+ @base.controller_class_name.should eql("ClientController")
32
+ end
33
+
34
+ it "should know controller test class name" do
35
+ @base.controller_test_class_name.should eql("ClientControllerTest")
36
+ end
37
+
38
+ it "should know path" do
39
+ @base.base_path.should eql("clients")
40
+ end
41
+
42
+ it "should know model parameter name with scaffold given with first letter uppercased" do
43
+ base = BaseScaffold.new("Client")
44
+ base.model_parameter_name.should eql("client")
45
+ end
46
+ end
47
+
48
+ context "compound model name" do
49
+ it "should know class name to 'orderItem'" do
50
+ BaseScaffold.new("orderItem").class_name.should eql("OrderItem")
51
+ end
52
+
53
+ it "should know class name to 'OrderItem'" do
54
+ BaseScaffold.new("OrderItem").class_name.should eql("OrderItem")
55
+ end
56
+
57
+ it "should know parameter name to 'OrderItem'" do
58
+ BaseScaffold.new("OrderItem").model_parameter_name.should eql("orderItem")
59
+ end
60
+
61
+ it "should know parameter name to 'OrderItem'" do
62
+ BaseScaffold.new("orderItem").model_parameter_name.should eql("orderItem")
63
+ end
64
+
65
+ it "should know path to 'orderItem'" do
66
+ BaseScaffold.new("orderItem").base_path.should eql("orderItems")
67
+ end
68
+
69
+ it "should know path to 'OrderItem'" do
70
+ BaseScaffold.new("OrderItem").base_path.should eql("orderItems")
71
+ end
72
+ end
73
+ end
@@ -1,6 +1,15 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../../../../spec_helper")
2
2
 
3
3
  describe ControllerGenerator do
4
+
5
+ it "paths to simple model name" do
6
+ ControllerGenerator.new("product", build_attributes).path.should == "/products"
7
+ end
8
+
9
+ it "paths to compound model name" do
10
+ ControllerGenerator.new("orderItem", build_attributes).path.should == "/orderItems"
11
+ end
12
+
4
13
  describe "generating from a lowercased name" do
5
14
  before(:each) do
6
15
  mock_config_file
@@ -9,21 +18,21 @@ describe ControllerGenerator do
9
18
  end
10
19
 
11
20
  after(:each) do
12
- FileUtils.remove_dir("src")
21
+ FileUtils.remove_dir("src")
13
22
  end
14
23
 
15
24
  it "should create controller" do
16
25
  source = File.join File.dirname(__FILE__), "templates", "ProductController.java"
17
- destination = Configuration.main_class_path "controllers", "ProductController.java"
26
+ destination = Configuration.main_class_path "controller", "ProductController.java"
18
27
  exists_and_identical?(source, destination)
19
28
  end
20
29
 
21
30
  it "should create controller test" do
22
- test_class = Configuration.test_class_path "controllers", "ProductControllerTest.java"
23
- File.exist?(test_class).should be_true
31
+ test_class = Configuration.test_class_path "controller", "ProductControllerTest.java"
32
+ File.exist?(test_class).should be_true
24
33
  end
25
34
  end
26
-
35
+
27
36
  describe "generating from an uppercased name" do
28
37
  before(:each) do
29
38
  mock_config_file
@@ -32,18 +41,18 @@ describe ControllerGenerator do
32
41
  end
33
42
 
34
43
  after(:each) do
35
- FileUtils.remove_dir("src")
44
+ FileUtils.remove_dir("src")
36
45
  end
37
46
 
38
47
  it "should create controller" do
39
48
  source = File.join File.dirname(__FILE__), "templates", "ProductController.java"
40
- destination = Configuration.main_class_path "controllers", "ProductController.java"
49
+ destination = Configuration.main_class_path "controller", "ProductController.java"
41
50
  exists_and_identical?(source, destination)
42
51
  end
43
52
 
44
53
  it "should create controller test" do
45
- test_class = Configuration.test_class_path "controllers", "ProductControllerTest.java"
46
- File.exist?(test_class).should be_true
54
+ test_class = Configuration.test_class_path "controller", "ProductControllerTest.java"
55
+ File.exist?(test_class).should be_true
47
56
  end
48
57
  end
49
58
  end
@@ -1,9 +1,9 @@
1
- package app.controllers;
1
+ package app.controller;
2
2
 
3
3
  import java.util.List;
4
4
 
5
- import app.models.Product;
6
- import app.repositories.ProductRepository;
5
+ import app.model.Product;
6
+ import app.repository.ProductRepository;
7
7
  import br.com.caelum.vraptor.Delete;
8
8
  import br.com.caelum.vraptor.Get;
9
9
  import br.com.caelum.vraptor.Post;
@@ -0,0 +1,74 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../../../spec_helper")
2
+
3
+ describe FreemarkerGenerator do
4
+
5
+ it "should append context to path" do
6
+ FreemarkerGenerator.new("myModel", build_attributes).path.should == "${base}/myModels"
7
+ end
8
+
9
+ context "simple model name" do
10
+ before(:all) do
11
+ model = "product"
12
+ @views_path = File.join Configuration::WEB_INF, "views", model
13
+ @generator = FreemarkerGenerator.new(model, build_attributes)
14
+ @generator.build
15
+ end
16
+
17
+ after(:all) do
18
+ FileUtils.remove_dir("src")
19
+ end
20
+
21
+ it "should create index view" do
22
+ File.exist?("#{@views_path}/index.ftl").should be_true
23
+ end
24
+
25
+ it "should create show view" do
26
+ File.exist?("#{@views_path}/show.ftl").should be_true
27
+ end
28
+
29
+ it "should create form view" do
30
+ File.exist?("#{@views_path}/form.ftl").should be_true
31
+ end
32
+
33
+ it "should create new view" do
34
+ File.exist?("#{@views_path}/newProduct.ftl").should be_true
35
+ end
36
+
37
+ it "should create edit view" do
38
+ File.exist?("#{@views_path}/edit.ftl").should be_true
39
+ end
40
+ end
41
+
42
+ context "compound model name" do
43
+ before(:all) do
44
+ model = "OrderItem"
45
+ @views_path = File.join Configuration::WEB_INF, "views", "orderItem"
46
+ @generator = FreemarkerGenerator.new(model, build_attributes)
47
+ @generator.build
48
+ end
49
+
50
+ after(:all) do
51
+ FileUtils.remove_dir("src")
52
+ end
53
+
54
+ it "should create index view" do
55
+ File.exist?("#{@views_path}/index.ftl").should be_true
56
+ end
57
+
58
+ it "should create show view" do
59
+ File.exist?("#{@views_path}/show.ftl").should be_true
60
+ end
61
+
62
+ it "should create form view" do
63
+ File.exist?("#{@views_path}/form.ftl").should be_true
64
+ end
65
+
66
+ it "should create new view" do
67
+ File.exist?("#{@views_path}/newOrderItem.ftl").should be_true
68
+ end
69
+
70
+ it "should create edit view" do
71
+ File.exist?("#{@views_path}/edit.ftl").should be_true
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,75 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../../../spec_helper")
2
+
3
+ describe JspGenerator do
4
+
5
+ it "should append context to path" do
6
+ JspGenerator.new("myModel", build_attributes).path("/edit").should == "${pageContext.request.contextPath}/myModels/edit"
7
+ end
8
+
9
+ context "simple model name" do
10
+ before(:all) do
11
+ model = "product"
12
+ @views_path = File.join Configuration::WEB_INF, "jsp", model
13
+ @generator = JspGenerator.new(model, build_attributes)
14
+ @generator.build
15
+ end
16
+
17
+ after(:all) do
18
+ FileUtils.remove_dir("src")
19
+ end
20
+
21
+ it "should create index view" do
22
+ File.exist?("#{@views_path}/index.jsp").should be_true
23
+ end
24
+
25
+ it "should create show view" do
26
+ File.exist?("#{@views_path}/show.jsp").should be_true
27
+ end
28
+
29
+ it "should create form view" do
30
+ File.exist?("#{@views_path}/form.jsp").should be_true
31
+ end
32
+
33
+ it "should create new view" do
34
+ File.exist?("#{@views_path}/newProduct.jsp").should be_true
35
+ end
36
+
37
+ it "should create edit view" do
38
+ File.exist?("#{@views_path}/edit.jsp").should be_true
39
+ end
40
+ end
41
+
42
+ context "compound model name" do
43
+ before(:all) do
44
+ model = "OrderItem"
45
+ @views_path = File.join Configuration::WEB_INF, "jsp", "orderItem"
46
+ @generator = JspGenerator.new(model, build_attributes)
47
+ @generator.build
48
+ end
49
+
50
+ after(:all) do
51
+ FileUtils.remove_dir("src")
52
+ end
53
+
54
+ it "should create index view" do
55
+ File.exist?("#{@views_path}/index.jsp").should be_true
56
+ end
57
+
58
+ it "should create show view" do
59
+ File.exist?("#{@views_path}/show.jsp").should be_true
60
+ end
61
+
62
+ it "should create form view" do
63
+ File.exist?("#{@views_path}/form.jsp").should be_true
64
+ end
65
+
66
+ it "should create new view" do
67
+ File.exist?("#{@views_path}/newOrderItem.jsp").should be_true
68
+ end
69
+
70
+ it "should create edit view" do
71
+ File.exist?("#{@views_path}/edit.jsp").should be_true
72
+ end
73
+ end
74
+
75
+ end
@@ -0,0 +1,50 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../../../spec_helper")
2
+
3
+ describe ModelGenerator do
4
+
5
+ context "jpa" do
6
+ before(:each) do
7
+ mock_config_file
8
+ @generator = ModelGenerator.new("product", build_attributes)
9
+ @generator.build
10
+ end
11
+
12
+ after(:each) do
13
+ FileUtils.remove_dir("src")
14
+ end
15
+
16
+ it "should create model" do
17
+ source = File.join File.dirname(__FILE__), "templates", "Product.java"
18
+ destination = Configuration.main_class_path "model", "Product.java"
19
+ exists_and_identical?(source, destination)
20
+ end
21
+
22
+ it "should create model test" do
23
+ test_class = Configuration.test_class_path "model", "ProductTest.java"
24
+ File.exist?(test_class).should be_true
25
+ end
26
+ end
27
+
28
+ context "hibernate" do
29
+ before(:each) do
30
+ config = {"package" => "app", "orm" => "hibernate", "models_package" => "model"}
31
+ YAML.stub!(:load_file).with(Configuration::FILENAME).and_return(config)
32
+ AppGenerator.new("src", ["-o=hibernate"]).configure_orm
33
+ FileUtils.chdir("src")
34
+ @generator = ModelGenerator.new("product", build_attributes)
35
+ @generator.build
36
+ FileUtils.chdir("..")
37
+ end
38
+
39
+ after(:each) do
40
+ FileUtils.remove_dir("src")
41
+ end
42
+
43
+ it "should map entity in hibernate.cfg.xml when orm is hibernate" do
44
+ source = File.join File.dirname(__FILE__), "templates", "hibernate.cfg.xml"
45
+ destination = File.join "src", Configuration::MAIN_RESOURCES, "hibernate.cfg.xml"
46
+ exists_and_identical?(source, destination)
47
+ end
48
+ end
49
+
50
+ end
@@ -1,10 +1,10 @@
1
- package app.models;
1
+ package app.model;
2
2
 
3
3
  @javax.persistence.Entity
4
4
  public class Product extends Entity {
5
5
 
6
6
  private String name;
7
- private boolean flag;
7
+ private boolean myFlag;
8
8
 
9
9
  public void setName(String name) {
10
10
  this.name = name;
@@ -14,12 +14,12 @@ public class Product extends Entity {
14
14
  return name;
15
15
  }
16
16
 
17
- public void setFlag(boolean flag) {
18
- this.flag = flag;
17
+ public void setMyFlag(boolean myFlag) {
18
+ this.myFlag = myFlag;
19
19
  }
20
20
 
21
- public boolean isFlag() {
22
- return flag;
21
+ public boolean isMyFlag() {
22
+ return myFlag;
23
23
  }
24
24
 
25
25
  }
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
3
+
4
+ <hibernate-configuration>
5
+ <session-factory>
6
+ <mapping class='app.model.Product'/>
7
+ </session-factory>
8
+ </hibernate-configuration>