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.
- data/.rvmrc.example +1 -0
- data/.travis.yml +2 -1
- data/CHANGELOG.rdoc +22 -3
- data/Rakefile +2 -2
- data/lib/vraptor-scaffold.rb +1 -1
- data/lib/vraptor-scaffold/generators/app/app_generator.rb +23 -56
- data/lib/vraptor-scaffold/generators/app/dependency/default_dependencies.rb +44 -0
- data/lib/vraptor-scaffold/generators/app/{dependency.rb → dependency/dependency.rb} +0 -0
- data/lib/vraptor-scaffold/generators/app/dependency/dependency_manager.rb +25 -0
- data/lib/vraptor-scaffold/generators/app/dependency/gae_dependencies.rb +49 -0
- data/lib/vraptor-scaffold/generators/app/dependency/heroku_dependencies.rb +48 -0
- data/lib/vraptor-scaffold/generators/app/freemarker_template_engine.rb +7 -5
- data/lib/vraptor-scaffold/generators/app/gae_app_generator.rb +145 -0
- data/lib/vraptor-scaffold/generators/app/jsp_template_engine.rb +6 -5
- data/lib/vraptor-scaffold/generators/app/templates/build-gae.xml +144 -0
- data/lib/vraptor-scaffold/generators/app/templates/build.gradle.erb +4 -4
- data/lib/vraptor-scaffold/generators/app/templates/eclipse/classpath-gae.erb +1 -3
- data/lib/vraptor-scaffold/generators/app/templates/eclipse/classpath.erb +1 -1
- data/lib/vraptor-scaffold/generators/app/templates/eclipse/project-gae.erb +2 -2
- data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings-gae/com.google.appengine.eclipse.core.prefs +4 -0
- data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings-gae/com.google.gdt.eclipse.core.prefs +1 -2
- data/lib/vraptor-scaffold/generators/app/templates/freemarker/macros/html.ftl +12 -0
- data/lib/vraptor-scaffold/generators/app/templates/freemarker/main.ftl.erb +18 -0
- data/lib/vraptor-scaffold/generators/app/templates/gae/appengine-web.xml.tt +1 -0
- data/lib/vraptor-scaffold/generators/app/templates/gae/ivysettings.xml +1 -1
- data/lib/vraptor-scaffold/generators/app/templates/gitignore-gae +4 -0
- data/lib/vraptor-scaffold/generators/app/templates/ivy.erb +3 -3
- data/lib/vraptor-scaffold/generators/app/templates/jsp/main.jsp.erb +20 -0
- data/lib/vraptor-scaffold/generators/app/templates/pom.erb +3 -3
- data/lib/vraptor-scaffold/generators/app/templates/vraptor-scaffold-gae.erb +7 -0
- data/lib/vraptor-scaffold/generators/base.rb +21 -0
- data/lib/vraptor-scaffold/generators/scaffold/attribute.rb +7 -1
- data/lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb +18 -0
- data/lib/vraptor-scaffold/generators/scaffold/controller_generator/templates/controller.erb +26 -1
- data/lib/vraptor-scaffold/generators/scaffold/controller_generator/templates/controller_test.erb +1 -1
- data/lib/vraptor-scaffold/generators/scaffold/import_manager.rb +20 -0
- data/lib/vraptor-scaffold/generators/scaffold/model_generator/templates/model.erb +7 -4
- data/lib/vraptor-scaffold/generators/scaffold/model_generator/templates/objectify_model.erb +3 -3
- data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/templates/form.erb +8 -0
- data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/jsp_generator/templates/form.erb +13 -3
- data/lib/vraptor-scaffold/load_paths.rb +3 -3
- data/lib/vraptor-scaffold/runner/generator.rb +11 -1
- data/lib/vraptor-scaffold/runner/start.rb +1 -1
- data/lib/vraptor-scaffold/version.rb +1 -1
- data/maven/repo/br/com/caelum/vraptor3.4-compatible-gae/1.1/vraptor3.4-compatible-gae-1.1.jar +0 -0
- data/spec/spec_helper.rb +9 -1
- data/spec/vraptor-scaffold/generators/app/app_generator_spec.rb +47 -99
- data/spec/vraptor-scaffold/generators/app/dependency/dependency_manager_spec.rb +21 -0
- data/spec/vraptor-scaffold/generators/app/{dependency_spec.rb → dependency/dependency_spec.rb} +4 -4
- data/spec/vraptor-scaffold/generators/app/dependency/gae_dependencies_spec.rb +20 -0
- data/spec/vraptor-scaffold/generators/app/dependency/heroku_dependencies_spec.rb +20 -0
- data/spec/vraptor-scaffold/generators/app/freemarker_template_engine_spec.rb +49 -7
- data/spec/vraptor-scaffold/generators/app/gae_app_generator_spec.rb +286 -0
- data/spec/vraptor-scaffold/generators/app/jsp_template_engine_spec.rb +49 -7
- data/spec/vraptor-scaffold/generators/app/templates/build.gradle +6 -6
- data/spec/vraptor-scaffold/generators/app/templates/classpath-gae +1 -3
- data/spec/vraptor-scaffold/generators/app/templates/gae-jsp-web.xml +1 -1
- data/spec/vraptor-scaffold/generators/app/templates/ivy-gae.xml +8 -6
- data/spec/vraptor-scaffold/generators/app/templates/ivy.xml +5 -5
- data/{lib/vraptor-scaffold/generators/app/templates/freemarker/main.ftl → spec/vraptor-scaffold/generators/app/templates/main-with-jquery.ftl} +0 -0
- data/{lib/vraptor-scaffold/generators/app/templates/jsp/main.jsp → spec/vraptor-scaffold/generators/app/templates/main-with-jquery.jsp} +0 -0
- data/spec/vraptor-scaffold/generators/app/templates/main-without-jquery.ftl +14 -0
- data/spec/vraptor-scaffold/generators/app/templates/main-without-jquery.jsp +16 -0
- data/spec/vraptor-scaffold/generators/app/templates/pom-heroku.xml +5 -5
- data/spec/vraptor-scaffold/generators/app/templates/pom.xml +5 -5
- data/spec/vraptor-scaffold/generators/app/templates/project-gae +2 -2
- data/spec/vraptor-scaffold/generators/app/templates/vraptor-scaffold-gae.properties +7 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/build.gradle +7 -7
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_build.gradle +6 -6
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_ivy.xml +5 -5
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_pom.xml +5 -5
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/ivy.xml +6 -6
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/pom.xml +6 -6
- data/spec/vraptor-scaffold/generators/plugin/plugin_generator_spec.rb +7 -7
- data/spec/vraptor-scaffold/generators/scaffold/attribute_spec.rb +198 -181
- data/spec/vraptor-scaffold/generators/scaffold/base_scaffold_spec.rb +7 -1
- data/spec/vraptor-scaffold/generators/scaffold/controller_generator/templates/ProductController.java +9 -1
- data/spec/vraptor-scaffold/generators/scaffold/freemarker_generator/templates/form.ftl +15 -0
- data/spec/vraptor-scaffold/generators/scaffold/import_manager_spec.rb +9 -0
- data/spec/vraptor-scaffold/generators/scaffold/jsp_generator/templates/form.jsp +23 -3
- data/spec/vraptor-scaffold/generators/scaffold/model_generator/model_generator_spec.rb +2 -2
- data/spec/vraptor-scaffold/generators/scaffold/model_generator/objectify_model_generator_spec.rb +6 -6
- data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/Objectify_Product.java +23 -5
- data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/Product.java +24 -6
- data/spec/vraptor-scaffold/http_request_spec.rb +10 -0
- data/spec/vraptor-scaffold/runner/generator_spec.rb +18 -2
- metadata +86 -30
- data/lib/vraptor-scaffold/generators/app/dependency_manager.rb +0 -83
- 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
|
14
|
-
<dependency org="br.com.caelum" name="vraptor" rev="3.4.
|
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.
|
18
|
-
<dependency org="org.hibernate" name="hibernate-entitymanager" rev="
|
19
|
-
<dependency org="org.hibernate" name="hibernate-c3p0" rev="
|
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.
|
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
|
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.
|
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.
|
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>
|
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>
|
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.
|
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
|
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
|
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"
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
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
|