vraptor-scaffold 1.3.0.rc → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/.rvmrc.example +1 -0
  2. data/.travis.yml +2 -1
  3. data/CHANGELOG.rdoc +22 -3
  4. data/Rakefile +2 -2
  5. data/lib/vraptor-scaffold.rb +1 -1
  6. data/lib/vraptor-scaffold/generators/app/app_generator.rb +23 -56
  7. data/lib/vraptor-scaffold/generators/app/dependency/default_dependencies.rb +44 -0
  8. data/lib/vraptor-scaffold/generators/app/{dependency.rb → dependency/dependency.rb} +0 -0
  9. data/lib/vraptor-scaffold/generators/app/dependency/dependency_manager.rb +25 -0
  10. data/lib/vraptor-scaffold/generators/app/dependency/gae_dependencies.rb +49 -0
  11. data/lib/vraptor-scaffold/generators/app/dependency/heroku_dependencies.rb +48 -0
  12. data/lib/vraptor-scaffold/generators/app/freemarker_template_engine.rb +7 -5
  13. data/lib/vraptor-scaffold/generators/app/gae_app_generator.rb +145 -0
  14. data/lib/vraptor-scaffold/generators/app/jsp_template_engine.rb +6 -5
  15. data/lib/vraptor-scaffold/generators/app/templates/build-gae.xml +144 -0
  16. data/lib/vraptor-scaffold/generators/app/templates/build.gradle.erb +4 -4
  17. data/lib/vraptor-scaffold/generators/app/templates/eclipse/classpath-gae.erb +1 -3
  18. data/lib/vraptor-scaffold/generators/app/templates/eclipse/classpath.erb +1 -1
  19. data/lib/vraptor-scaffold/generators/app/templates/eclipse/project-gae.erb +2 -2
  20. data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings-gae/com.google.appengine.eclipse.core.prefs +4 -0
  21. data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings-gae/com.google.gdt.eclipse.core.prefs +1 -2
  22. data/lib/vraptor-scaffold/generators/app/templates/freemarker/macros/html.ftl +12 -0
  23. data/lib/vraptor-scaffold/generators/app/templates/freemarker/main.ftl.erb +18 -0
  24. data/lib/vraptor-scaffold/generators/app/templates/gae/appengine-web.xml.tt +1 -0
  25. data/lib/vraptor-scaffold/generators/app/templates/gae/ivysettings.xml +1 -1
  26. data/lib/vraptor-scaffold/generators/app/templates/gitignore-gae +4 -0
  27. data/lib/vraptor-scaffold/generators/app/templates/ivy.erb +3 -3
  28. data/lib/vraptor-scaffold/generators/app/templates/jsp/main.jsp.erb +20 -0
  29. data/lib/vraptor-scaffold/generators/app/templates/pom.erb +3 -3
  30. data/lib/vraptor-scaffold/generators/app/templates/vraptor-scaffold-gae.erb +7 -0
  31. data/lib/vraptor-scaffold/generators/base.rb +21 -0
  32. data/lib/vraptor-scaffold/generators/scaffold/attribute.rb +7 -1
  33. data/lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb +18 -0
  34. data/lib/vraptor-scaffold/generators/scaffold/controller_generator/templates/controller.erb +26 -1
  35. data/lib/vraptor-scaffold/generators/scaffold/controller_generator/templates/controller_test.erb +1 -1
  36. data/lib/vraptor-scaffold/generators/scaffold/import_manager.rb +20 -0
  37. data/lib/vraptor-scaffold/generators/scaffold/model_generator/templates/model.erb +7 -4
  38. data/lib/vraptor-scaffold/generators/scaffold/model_generator/templates/objectify_model.erb +3 -3
  39. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/templates/form.erb +8 -0
  40. data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/jsp_generator/templates/form.erb +13 -3
  41. data/lib/vraptor-scaffold/load_paths.rb +3 -3
  42. data/lib/vraptor-scaffold/runner/generator.rb +11 -1
  43. data/lib/vraptor-scaffold/runner/start.rb +1 -1
  44. data/lib/vraptor-scaffold/version.rb +1 -1
  45. data/maven/repo/br/com/caelum/vraptor3.4-compatible-gae/1.1/vraptor3.4-compatible-gae-1.1.jar +0 -0
  46. data/spec/spec_helper.rb +9 -1
  47. data/spec/vraptor-scaffold/generators/app/app_generator_spec.rb +47 -99
  48. data/spec/vraptor-scaffold/generators/app/dependency/dependency_manager_spec.rb +21 -0
  49. data/spec/vraptor-scaffold/generators/app/{dependency_spec.rb → dependency/dependency_spec.rb} +4 -4
  50. data/spec/vraptor-scaffold/generators/app/dependency/gae_dependencies_spec.rb +20 -0
  51. data/spec/vraptor-scaffold/generators/app/dependency/heroku_dependencies_spec.rb +20 -0
  52. data/spec/vraptor-scaffold/generators/app/freemarker_template_engine_spec.rb +49 -7
  53. data/spec/vraptor-scaffold/generators/app/gae_app_generator_spec.rb +286 -0
  54. data/spec/vraptor-scaffold/generators/app/jsp_template_engine_spec.rb +49 -7
  55. data/spec/vraptor-scaffold/generators/app/templates/build.gradle +6 -6
  56. data/spec/vraptor-scaffold/generators/app/templates/classpath-gae +1 -3
  57. data/spec/vraptor-scaffold/generators/app/templates/gae-jsp-web.xml +1 -1
  58. data/spec/vraptor-scaffold/generators/app/templates/ivy-gae.xml +8 -6
  59. data/spec/vraptor-scaffold/generators/app/templates/ivy.xml +5 -5
  60. data/{lib/vraptor-scaffold/generators/app/templates/freemarker/main.ftl → spec/vraptor-scaffold/generators/app/templates/main-with-jquery.ftl} +0 -0
  61. data/{lib/vraptor-scaffold/generators/app/templates/jsp/main.jsp → spec/vraptor-scaffold/generators/app/templates/main-with-jquery.jsp} +0 -0
  62. data/spec/vraptor-scaffold/generators/app/templates/main-without-jquery.ftl +14 -0
  63. data/spec/vraptor-scaffold/generators/app/templates/main-without-jquery.jsp +16 -0
  64. data/spec/vraptor-scaffold/generators/app/templates/pom-heroku.xml +5 -5
  65. data/spec/vraptor-scaffold/generators/app/templates/pom.xml +5 -5
  66. data/spec/vraptor-scaffold/generators/app/templates/project-gae +2 -2
  67. data/spec/vraptor-scaffold/generators/app/templates/vraptor-scaffold-gae.properties +7 -0
  68. data/spec/vraptor-scaffold/generators/plugin/expected_configs/build.gradle +7 -7
  69. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_build.gradle +6 -6
  70. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_ivy.xml +5 -5
  71. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_pom.xml +5 -5
  72. data/spec/vraptor-scaffold/generators/plugin/expected_configs/ivy.xml +6 -6
  73. data/spec/vraptor-scaffold/generators/plugin/expected_configs/pom.xml +6 -6
  74. data/spec/vraptor-scaffold/generators/plugin/plugin_generator_spec.rb +7 -7
  75. data/spec/vraptor-scaffold/generators/scaffold/attribute_spec.rb +198 -181
  76. data/spec/vraptor-scaffold/generators/scaffold/base_scaffold_spec.rb +7 -1
  77. data/spec/vraptor-scaffold/generators/scaffold/controller_generator/templates/ProductController.java +9 -1
  78. data/spec/vraptor-scaffold/generators/scaffold/freemarker_generator/templates/form.ftl +15 -0
  79. data/spec/vraptor-scaffold/generators/scaffold/import_manager_spec.rb +9 -0
  80. data/spec/vraptor-scaffold/generators/scaffold/jsp_generator/templates/form.jsp +23 -3
  81. data/spec/vraptor-scaffold/generators/scaffold/model_generator/model_generator_spec.rb +2 -2
  82. data/spec/vraptor-scaffold/generators/scaffold/model_generator/objectify_model_generator_spec.rb +6 -6
  83. data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/Objectify_Product.java +23 -5
  84. data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/Product.java +24 -6
  85. data/spec/vraptor-scaffold/http_request_spec.rb +10 -0
  86. data/spec/vraptor-scaffold/runner/generator_spec.rb +18 -2
  87. metadata +86 -30
  88. data/lib/vraptor-scaffold/generators/app/dependency_manager.rb +0 -83
  89. data/spec/vraptor-scaffold/generators/app/dependency_manager_spec.rb +0 -34
@@ -10,13 +10,13 @@
10
10
  </configurations>
11
11
 
12
12
  <dependencies>
13
- <dependency org="br.com.caelum.vraptor.plugin" name="vraptor-environment" rev="0.0.8" conf="default" />
14
- <dependency org="br.com.caelum" name="vraptor" rev="3.4.0" conf="default" />
13
+ <dependency org="br.com.caelum.vraptor" name="vraptor-environment" rev="0.0.8" conf="default" />
14
+ <dependency org="br.com.caelum" name="vraptor" rev="3.4.1" conf="default" />
15
15
  <dependency org="opensymphony" name="sitemesh" rev="2.4.2" conf="default" />
16
16
  <dependency org="javax.servlet" name="jstl" rev="1.2" conf="default" />
17
- <dependency org="org.hsqldb" name="hsqldb" rev="2.2.4" conf="default" />
18
- <dependency org="org.hibernate" name="hibernate-entitymanager" rev="3.6.7.Final" conf="default" />
19
- <dependency org="org.hibernate" name="hibernate-c3p0" rev="3.6.7.Final" conf="default" />
17
+ <dependency org="org.hsqldb" name="hsqldb" rev="2.2.8" conf="default" />
18
+ <dependency org="org.hibernate" name="hibernate-entitymanager" rev="4.0.1.Final" conf="default" />
19
+ <dependency org="org.hibernate" name="hibernate-c3p0" rev="4.0.1.Final" conf="default" />
20
20
  <dependency org="org.hibernate" name="hibernate-validator" rev="4.2.0.Final" conf="default" />
21
21
  <dependency org="joda-time" name="joda-time" rev="2.0" conf="default" />
22
22
  <dependency org="com.thoughtworks.xstream" name="xstream" rev="1.4.1" conf="default" />
@@ -28,7 +28,7 @@
28
28
  <!-- Test dependencies -->
29
29
  <dependency org="junit" name="junit" rev="4.10" conf="test->default" />
30
30
  <dependency org="org.hamcrest" name="hamcrest-all" rev="1.1" conf="test->default" />
31
- <dependency org="org.mockito" name="mockito-all" rev="1.8.5" conf="test->default" />
31
+ <dependency org="org.mockito" name="mockito-all" rev="1.9.0" conf="test->default" />
32
32
 
33
33
  <!-- Jetty dependencies -->
34
34
  <dependency org="org.mortbay.jetty" name="jsp-api-2.1" rev="6.1.14" conf="jetty->default" />
@@ -55,14 +55,14 @@
55
55
 
56
56
  <dependencies>
57
57
  <dependency>
58
- <groupId>br.com.caelum.vraptor.plugin</groupId>
58
+ <groupId>br.com.caelum.vraptor</groupId>
59
59
  <artifactId>vraptor-environment</artifactId>
60
60
  <version>0.0.8</version>
61
61
  </dependency>
62
62
  <dependency>
63
63
  <groupId>br.com.caelum</groupId>
64
64
  <artifactId>vraptor</artifactId>
65
- <version>3.4.0</version>
65
+ <version>3.4.1</version>
66
66
  </dependency>
67
67
  <dependency>
68
68
  <groupId>opensymphony</groupId>
@@ -77,17 +77,17 @@
77
77
  <dependency>
78
78
  <groupId>org.hsqldb</groupId>
79
79
  <artifactId>hsqldb</artifactId>
80
- <version>2.2.4</version>
80
+ <version>2.2.8</version>
81
81
  </dependency>
82
82
  <dependency>
83
83
  <groupId>org.hibernate</groupId>
84
84
  <artifactId>hibernate-entitymanager</artifactId>
85
- <version>3.6.7.Final</version>
85
+ <version>4.0.1.Final</version>
86
86
  </dependency>
87
87
  <dependency>
88
88
  <groupId>org.hibernate</groupId>
89
89
  <artifactId>hibernate-c3p0</artifactId>
90
- <version>3.6.7.Final</version>
90
+ <version>4.0.1.Final</version>
91
91
  </dependency>
92
92
  <dependency>
93
93
  <groupId>org.hibernate</groupId>
@@ -121,7 +121,7 @@
121
121
  <dependency>
122
122
  <groupId>org.mockito</groupId>
123
123
  <artifactId>mockito-all</artifactId>
124
- <version>1.8.5</version>
124
+ <version>1.9.0</version>
125
125
  <scope>test</scope>
126
126
  </dependency>
127
127
 
@@ -9,9 +9,9 @@ describe PluginGenerator do
9
9
  @gradle_projet = "#{@project_path}/gradle"
10
10
  @ant_projet = "#{@project_path}/ant"
11
11
 
12
- AppGenerator.new(@maven_projet, ["-b=mvn"]).invoke_all
13
- AppGenerator.new(@gradle_projet, ["-b=gradle"]).invoke_all
14
- AppGenerator.new(@ant_projet, ["-b=ant"]).invoke_all
12
+ AppGenerator.new(@maven_projet, ["-b=mvn", "--skip-jquery"]).invoke_all
13
+ AppGenerator.new(@gradle_projet, ["-b=gradle", "--skip-jquery"]).invoke_all
14
+ AppGenerator.new(@ant_projet, ["-b=ant", "--skip-jquery"]).invoke_all
15
15
  end
16
16
 
17
17
  after :all do
@@ -46,7 +46,7 @@ describe PluginGenerator do
46
46
 
47
47
  before :each do
48
48
  FileUtils.chdir(@maven_projet)
49
- @generator = PluginGenerator.new("vraptor-environment", ["-v=0.0.8", "-g=br.com.caelum.vraptor.plugin"])
49
+ @generator = PluginGenerator.new("vraptor-environment", ["-v=0.0.8", "-g=br.com.caelum.vraptor"])
50
50
  @generator.build
51
51
  back
52
52
  end
@@ -78,7 +78,7 @@ describe PluginGenerator do
78
78
 
79
79
  before :each do
80
80
  FileUtils.chdir(@ant_projet)
81
- @generator = PluginGenerator.new("vraptor-environment", ["-v=0.0.8", "-g=br.com.caelum.vraptor.plugin"])
81
+ @generator = PluginGenerator.new("vraptor-environment", ["-v=0.0.8", "-g=br.com.caelum.vraptor"])
82
82
  @generator.build
83
83
  back
84
84
  end
@@ -94,7 +94,7 @@ describe PluginGenerator do
94
94
 
95
95
  before :each do
96
96
  FileUtils.chdir(@gradle_projet)
97
- @generator = PluginGenerator.new("vraptor-environment", ["-v=0.0.8"])
97
+ @generator = PluginGenerator.new("vraptor-environment", ["-v=0.0.8", "-g=br.com.caelum.vraptor"])
98
98
  @generator.build
99
99
  back
100
100
  end
@@ -110,7 +110,7 @@ describe PluginGenerator do
110
110
 
111
111
  before :each do
112
112
  FileUtils.chdir(@gradle_projet)
113
- @generator = PluginGenerator.new("vraptor-environment", ["-v=0.0.8", "-g=br.com.caelum.vraptor.plugin"])
113
+ @generator = PluginGenerator.new("vraptor-environment", ["-v=0.0.8"])
114
114
  @generator.build
115
115
  back
116
116
  end
@@ -2,185 +2,202 @@ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
2
2
 
3
3
  describe Attribute do
4
4
 
5
- context "getter method prefix" do
6
- it "should be 'is' to boolean attributes" do
7
- Attribute.new("active", "boolean").getter_prefix.should == "is"
8
- end
9
-
10
- it "should be 'get' otherwise" do
11
- Attribute.new("description", "string").getter_prefix.should == "get"
12
- end
13
- end
14
-
15
- context "initialize attribute" do
16
- context "downcase name" do
17
- it "should downcase all words" do
18
- Attribute.new("VALUE", "double").name.should == "value"
19
- end
20
-
21
- it "should camelize composed name" do
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"
27
- end
28
-
29
- it "should keep name in downcase" do
30
- Attribute.new("value", "double").name.should == "value"
31
- end
32
- end
33
-
34
- it "should downcase type" do
35
- Attribute.new("value", "DoublE").type.should == "double"
36
- end
37
- end
38
-
39
- context "supported types" do
40
- it "should support boolean" do
41
- Attribute.valid_types.include?("boolean").should be_true
42
- end
43
-
44
- it "should support double" do
45
- Attribute.valid_types.include?("double").should be_true
46
- end
47
-
48
- it "should support string" do
49
- Attribute.valid_types.include?("string").should be_true
50
- end
51
-
52
- it "should support float" do
53
- Attribute.valid_types.include?("float").should be_true
54
- end
55
-
56
- it "should support short" do
57
- Attribute.valid_types.include?("short").should be_true
58
- end
59
-
60
- it "should support integer" do
61
- Attribute.valid_types.include?("integer").should be_true
62
- end
63
-
64
- it "should support long" do
65
- Attribute.valid_types.include?("long").should be_true
66
- end
67
-
68
- it "should support text" do
69
- Attribute.valid_types.include?("text").should be_true
70
- end
71
-
72
- it "should not support other" do
73
- Attribute.valid_types.include?("other").should be_false
74
- end
75
- end
76
-
77
- context "html_input" do
78
- it "should know html input to boolean" do
79
- Attribute.new("flag", "boolean").html_input.should eql("checkbox")
80
- end
81
-
82
- it "should know html input to string" do
83
- Attribute.new("name", "string").html_input.should eql("text")
84
- end
85
-
86
- it "should know html input to double" do
87
- Attribute.new("name", "double").html_input.should eql("text")
88
- end
89
-
90
- it "should know html input to float" do
91
- Attribute.new("name", "float").html_input.should eql("text")
92
- end
93
-
94
- it "should know html input to short" do
95
- Attribute.new("name", "short").html_input.should eql("text")
96
- end
97
-
98
- it "should know html input to integer" do
99
- Attribute.new("name", "integer").html_input.should eql("text")
100
- end
101
-
102
- it "should know html input to long" do
103
- Attribute.new("name", "long").html_input.should eql("text")
104
- end
105
-
106
- it "should know html input to text" do
107
- Attribute.new("name", "text").html_input.should eql("textarea")
108
- end
109
- end
110
-
111
- context "java type" do
112
- it "should know correct java type to boolean" do
113
- Attribute.new("flag", "boolean").java_type.should eql("boolean")
114
- end
115
-
116
- it "should know correct java type to text" do
117
- Attribute.new("description", "text").java_type.should eql("String")
118
- end
119
-
120
- it "should know correct java type to string" do
121
- Attribute.new("name", "string").java_type.should eql("String")
122
- end
123
-
124
- it "should know correct java type to double" do
125
- Attribute.new("name", "double").java_type.should eql("Double")
126
- end
127
-
128
- it "should know correct java type to float" do
129
- Attribute.new("name", "float").java_type.should eql("Float")
130
- end
131
-
132
- it "should know correct java type to short" do
133
- Attribute.new("name", "short").java_type.should eql("Short")
134
- end
135
-
136
- it "should know correct java type to integer" do
137
- Attribute.new("name", "integer").java_type.should eql("Integer")
138
- end
139
-
140
- it "should know correct java type to long" do
141
- Attribute.new("name", "long").java_type.should eql("Long")
142
- end
143
- end
144
-
145
- context "validate" do
146
-
147
- it "should be valid when attribute is supported" do
148
- Kernel.should_not_receive(:exit)
149
- Attribute.valid_types.each do |type|
150
- Attribute.new("name", type)
151
- end
152
- end
153
-
154
- it "cannot be valid when attribute is not supported" do
155
- Kernel.should_receive(:exit)
156
- Attribute.new("name", "char")
157
- end
158
-
159
- it "should be valid when attribute is upper case" do
160
- Kernel.should_not_receive(:exit)
161
- Attribute.new("name", "String")
162
- end
163
- end
164
-
165
- it "should be boolean when type is boolean" do
166
- Attribute.new("flag", "boolean").boolean?.should be_true
167
- end
168
-
169
- it "cannot be boolean otherwise" do
170
- Attribute.new("flag", "short").boolean?.should be_false
171
- end
172
-
173
- context "html label" do
174
- it "should humanize composed name" do
175
- Attribute.new("MyItem", "double").html_label.should == "My item"
176
- end
177
-
178
- it "should humanize composed name" do
179
- Attribute.new("myItem", "double").html_label.should == "My item"
180
- end
181
-
182
- it "should humanize single name" do
183
- Attribute.new("item", "double").html_label.should == "Item"
184
- end
185
- end
5
+ context "getter method prefix" do
6
+ it "should be 'is' to boolean attributes" do
7
+ Attribute.new("active", "boolean").getter_prefix.should == "is"
8
+ end
9
+
10
+ it "should be 'get' otherwise" do
11
+ Attribute.new("description", "string").getter_prefix.should == "get"
12
+ end
13
+ end
14
+
15
+ context "initialize attribute" do
16
+ context "downcase name" do
17
+ it "should downcase all words" do
18
+ Attribute.new("VALUE", "double").name.should == "value"
19
+ end
20
+
21
+ it "should camelize composed name" do
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"
27
+ end
28
+
29
+ it "should keep name in downcase" do
30
+ Attribute.new("value", "double").name.should == "value"
31
+ end
32
+ end
33
+
34
+ it "should downcase type" do
35
+ Attribute.new("value", "DoublE").type.should == "double"
36
+ end
37
+ end
38
+
39
+ context "supported types" do
40
+ it "should support boolean" do
41
+ Attribute.valid_types.include?("boolean").should be_true
42
+ end
43
+
44
+ it "should support double" do
45
+ Attribute.valid_types.include?("double").should be_true
46
+ end
47
+
48
+ it "should support string" do
49
+ Attribute.valid_types.include?("string").should be_true
50
+ end
51
+
52
+ it "should support float" do
53
+ Attribute.valid_types.include?("float").should be_true
54
+ end
55
+
56
+ it "should support short" do
57
+ Attribute.valid_types.include?("short").should be_true
58
+ end
59
+
60
+ it "should support integer" do
61
+ Attribute.valid_types.include?("integer").should be_true
62
+ end
63
+
64
+ it "should support long" do
65
+ Attribute.valid_types.include?("long").should be_true
66
+ end
67
+
68
+ it "should support text" do
69
+ Attribute.valid_types.include?("text").should be_true
70
+ end
71
+
72
+ it "should not support other" do
73
+ Attribute.valid_types.include?("other").should be_false
74
+ end
75
+
76
+ it "should suport date" do
77
+ Attribute.valid_types.include?("date").should be_true
78
+ end
79
+
80
+ context "html_input" do
81
+ it "should know html input to boolean" do
82
+ Attribute.new("flag", "boolean").html_input.should eql("checkbox")
83
+ end
84
+
85
+ it "should know html input to string" do
86
+ Attribute.new("name", "string").html_input.should eql("text")
87
+ end
88
+
89
+ it "should know html input to double" do
90
+ Attribute.new("name", "double").html_input.should eql("text")
91
+ end
92
+
93
+ it "should know html input to float" do
94
+ Attribute.new("name", "float").html_input.should eql("text")
95
+ end
96
+
97
+ it "should know html input to short" do
98
+ Attribute.new("name", "short").html_input.should eql("text")
99
+ end
100
+
101
+ it "should know html input to integer" do
102
+ Attribute.new("name", "integer").html_input.should eql("text")
103
+ end
104
+
105
+ it "should know html input to long" do
106
+ Attribute.new("name", "long").html_input.should eql("text")
107
+ end
108
+
109
+ it "should know html input to text" do
110
+ Attribute.new("name", "text").html_input.should eql("textarea")
111
+ end
112
+
113
+ it "should know html input to date" do
114
+ Attribute.new("price", "date").html_input.should eql("text")
115
+ end
116
+ end
117
+
118
+ context "java type" do
119
+ it "should know correct java type to boolean" do
120
+ Attribute.new("flag", "boolean").java_type.should eql("boolean")
121
+ end
122
+
123
+ it "should know correct java type to text" do
124
+ Attribute.new("description", "text").java_type.should eql("String")
125
+ end
126
+
127
+ it "should know correct java type to string" do
128
+ Attribute.new("name", "string").java_type.should eql("String")
129
+ end
130
+
131
+ it "should know correct java type to double" do
132
+ Attribute.new("name", "double").java_type.should eql("Double")
133
+ end
134
+
135
+ it "should know correct java type to float" do
136
+ Attribute.new("name", "float").java_type.should eql("Float")
137
+ end
138
+
139
+ it "should know correct java type to short" do
140
+ Attribute.new("name", "short").java_type.should eql("Short")
141
+ end
142
+
143
+ it "should know correct java type to integer" do
144
+ Attribute.new("name", "integer").java_type.should eql("Integer")
145
+ end
146
+
147
+ it "should know correct java type to long" do
148
+ Attribute.new("name", "long").java_type.should eql("Long")
149
+ end
150
+
151
+ it "should know correct java type to Date" do
152
+ Attribute.new("price", "date").java_type.should eql("Date")
153
+ end
154
+
155
+ it "should know correct type to relationship many to one" do
156
+ Attribute.new("product", "references").java_type.should eql("Product")
157
+ end
158
+
159
+ end
160
+
161
+ context "validate" do
162
+
163
+ it "should be valid when attribute is supported" do
164
+ Kernel.should_not_receive(:exit)
165
+ Attribute.valid_types.each do |type|
166
+ Attribute.new("name", type)
167
+ end
168
+ end
169
+
170
+ it "cannot be valid when attribute is not supported" do
171
+ Kernel.should_receive(:exit)
172
+ Attribute.new("name", "char")
173
+ end
174
+
175
+ it "should be valid when attribute is upper case" do
176
+ Kernel.should_not_receive(:exit)
177
+ Attribute.new("name", "String")
178
+ end
179
+ end
180
+
181
+ it "should be boolean when type is boolean" do
182
+ Attribute.new("flag", "boolean").boolean?.should be_true
183
+ end
184
+
185
+ it "cannot be boolean otherwise" do
186
+ Attribute.new("flag", "short").boolean?.should be_false
187
+ end
188
+
189
+ context "html label" do
190
+ it "should humanize composed name" do
191
+ Attribute.new("MyItem", "double").html_label.should == "My item"
192
+ end
193
+
194
+ it "should humanize composed name" do
195
+ Attribute.new("myItem", "double").html_label.should == "My item"
196
+ end
197
+
198
+ it "should humanize single name" do
199
+ Attribute.new("item", "double").html_label.should == "Item"
200
+ end
201
+ end
202
+ end
186
203
  end