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
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../../spec_helper")
|
2
|
+
|
3
|
+
describe DependencyManager do
|
4
|
+
|
5
|
+
context "dependencies by project type" do
|
6
|
+
it "should be default" do
|
7
|
+
options = {}
|
8
|
+
DependencyManager.new(options).dependencies.class.should == DefaultDependencies
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be heroku" do
|
12
|
+
options = {:heroku => true}
|
13
|
+
DependencyManager.new(options).dependencies.class.should == HerokuDependencies
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should be gae" do
|
17
|
+
options = {:gae => true}
|
18
|
+
DependencyManager.new(options).dependencies.class.should == GaeDependencies
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/vraptor-scaffold/generators/app/{dependency_spec.rb → dependency/dependency_spec.rb}
RENAMED
@@ -1,14 +1,14 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + "
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../../spec_helper")
|
2
2
|
|
3
3
|
describe Dependency do
|
4
|
-
|
4
|
+
|
5
5
|
it "should has exclusions" do
|
6
6
|
dependency = Dependency.new("org.vraptor", "vraptor3", "3.0.0", [Dependency.new("org.vraptor2", "2.0.0")])
|
7
7
|
dependency.has_exclusions?.should be_true
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
it "cannot has exclusions" do
|
11
11
|
dependency = Dependency.new("org.vraptor", "vraptor3", "3.0.0")
|
12
12
|
dependency.has_exclusions?.should be_false
|
13
13
|
end
|
14
|
-
end
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../../spec_helper")
|
2
|
+
|
3
|
+
describe GaeDependencies do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
others_dependency = mock(Dependency)
|
7
|
+
others_dependency.stub!(:exclusions).and_return([])
|
8
|
+
Dependency.stub!(:new).and_return(others_dependency)
|
9
|
+
@dependency = mock(Dependency)
|
10
|
+
end
|
11
|
+
|
12
|
+
context "compile scope" do
|
13
|
+
it "should include freemarker dependency when template is freemarker" do
|
14
|
+
options = {:template_engine => "ftl"}
|
15
|
+
Dependency.stub!(:new).with("org.freemarker", "freemarker", "2.3.18").and_return(@dependency)
|
16
|
+
GaeDependencies.new(options).compile_scope.include?(@dependency).should be_true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../../spec_helper")
|
2
|
+
|
3
|
+
describe HerokuDependencies do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
others_dependency = mock(Dependency)
|
7
|
+
others_dependency.stub!(:exclusions).and_return([])
|
8
|
+
Dependency.stub!(:new).and_return(others_dependency)
|
9
|
+
@dependency = mock(Dependency)
|
10
|
+
end
|
11
|
+
|
12
|
+
context "compile scope" do
|
13
|
+
it "should include freemarker dependency when template is freemarker" do
|
14
|
+
options = {:template_engine => "ftl"}
|
15
|
+
Dependency.stub!(:new).with("org.freemarker", "freemarker", "2.3.18").and_return(@dependency)
|
16
|
+
HerokuDependencies.new(options).compile_scope.include?(@dependency).should be_true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -12,11 +12,11 @@ describe FreemarkerTemplateEngine do
|
|
12
12
|
|
13
13
|
context "configuring" do
|
14
14
|
before(:all) do
|
15
|
-
AppGenerator.new(@project_path, ["--template-engine=ftl", "-p=br.com.caelum", "--orm=hibernate"]).invoke_all
|
15
|
+
AppGenerator.new(@project_path, ["--template-engine=ftl", "-p=br.com.caelum", "--orm=hibernate", "--skip-jquery"]).invoke_all
|
16
16
|
end
|
17
17
|
|
18
18
|
after(:all) do
|
19
|
-
FileUtils.remove_dir(
|
19
|
+
FileUtils.remove_dir("src")
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should create decorators.xml" do
|
@@ -32,11 +32,11 @@ describe FreemarkerTemplateEngine do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should create views folder" do
|
35
|
-
File.exist?("#{@web_inf}/views").should be_true
|
35
|
+
File.exist?("#{@web_inf}/views").should be_true
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should create infrastructure folder" do
|
39
|
-
File.exist?("#{@app}/infrastructure").should be_true
|
39
|
+
File.exist?("#{@app}/infrastructure").should be_true
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should create path resolver" do
|
@@ -46,9 +46,8 @@ describe FreemarkerTemplateEngine do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should create decorator file" do
|
49
|
-
source = "#{FreemarkerTemplateEngine.source_root}/main.ftl"
|
50
49
|
destination = "#{@decorators}/main.ftl"
|
51
|
-
|
50
|
+
File.exist?(destination)
|
52
51
|
end
|
53
52
|
|
54
53
|
it "should create html macro file" do
|
@@ -57,4 +56,47 @@ describe FreemarkerTemplateEngine do
|
|
57
56
|
exists_and_identical?(source, destination)
|
58
57
|
end
|
59
58
|
end
|
60
|
-
|
59
|
+
|
60
|
+
context "building a freemarker application" do
|
61
|
+
context "with jquery" do
|
62
|
+
before(:all) do
|
63
|
+
@project_path = "src/vraptor-scaffold-with-jquery"
|
64
|
+
@web_inf = "#{@project_path}/#{Configuration::WEB_INF}"
|
65
|
+
@decorators = "#{@web_inf}/views/decorators"
|
66
|
+
|
67
|
+
mock_http_request()
|
68
|
+
|
69
|
+
AppGenerator.new(@project_path, ["--template-engine=ftl"]).invoke_all
|
70
|
+
end
|
71
|
+
|
72
|
+
after(:all) do
|
73
|
+
FileUtils.remove_dir("src/vraptor-scaffold-with-jquery")
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should create a main file with jquery js import" do
|
77
|
+
source = File.join File.dirname(__FILE__), "templates", "main-with-jquery.ftl"
|
78
|
+
destination = "#{@decorators}/main.ftl"
|
79
|
+
exists_and_identical?(source, destination)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "building a freemarker application without jquery" do
|
84
|
+
before(:all) do
|
85
|
+
@project_path = "src/vraptor-scaffold-without-jquery"
|
86
|
+
@web_inf = "#{@project_path}/#{Configuration::WEB_INF}"
|
87
|
+
@decorators = "#{@web_inf}/views/decorators"
|
88
|
+
AppGenerator.new(@project_path, ["--template-engine=ftl", "--skip-jquery"]).invoke_all
|
89
|
+
end
|
90
|
+
|
91
|
+
after(:all) do
|
92
|
+
FileUtils.remove_dir("src/vraptor-scaffold-without-jquery")
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should create a main file with jquery js import" do
|
96
|
+
source = File.join File.dirname(__FILE__), "templates", "main-without-jquery.ftl"
|
97
|
+
destination = "#{@decorators}/main.ftl"
|
98
|
+
exists_and_identical?(source, destination)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,286 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
|
2
|
+
|
3
|
+
describe GaeAppGenerator do
|
4
|
+
|
5
|
+
context "build new application" do
|
6
|
+
before(:all) do
|
7
|
+
@project_path = "src/vraptor-scaffold"
|
8
|
+
GaeAppGenerator.new(@project_path, ["-r=repository", "-m=domain", "-c=control", "--skip-jquery"]).invoke_all
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:all) do
|
12
|
+
FileUtils.remove_dir("src")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should create directory with project name" do
|
16
|
+
File.exist?(@project_path).should be_true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should be invalid when project name already exist" do
|
20
|
+
Kernel.should_receive(:exit)
|
21
|
+
GaeAppGenerator.new(@project_path, ["--skip-jquery"])
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should configure vraptor-scaffold.properties" do
|
25
|
+
source = File.join File.dirname(__FILE__), "templates", "vraptor-scaffold-gae.properties"
|
26
|
+
destination = "#{@project_path}/#{Configuration::FILENAME}"
|
27
|
+
exists_and_identical?(source, destination)
|
28
|
+
end
|
29
|
+
|
30
|
+
context "creating main java" do
|
31
|
+
before(:all) do
|
32
|
+
@main_java = "#{@project_path}/#{Configuration::MAIN_SRC}"
|
33
|
+
@app = "#{@main_java}/app"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should create source folder" do
|
37
|
+
File.exist?(@main_java).should be_true
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should create app folder" do
|
41
|
+
File.exist?(@app).should be_true
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should create controllers folder" do
|
45
|
+
File.exist?("#{@app}/control").should be_true
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should create models folder" do
|
49
|
+
File.exist?("#{@app}/domain").should be_true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "creating webapp" do
|
54
|
+
before(:all) do
|
55
|
+
@webapp = "#{@project_path}/#{Configuration::WEB_APP}"
|
56
|
+
@web_inf = "#{@project_path}/#{Configuration::WEB_INF}"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should create webapp folder" do
|
60
|
+
File.exist?(@webapp).should be_true
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should create index" do
|
64
|
+
source = "#{GaeAppGenerator.source_root}/webapp/index.jsp"
|
65
|
+
destination = "#{@webapp}/index.jsp"
|
66
|
+
exists_and_identical?(source, destination)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should create WEB-INF folder" do
|
70
|
+
File.exist?(@web_inf).should be_true
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should create scaffold css" do
|
74
|
+
source = "#{GaeAppGenerator.source_root}/webapp/stylesheets/scaffold.css"
|
75
|
+
destination = "#{@webapp}/stylesheets/scaffold.css"
|
76
|
+
exists_and_identical?(source, destination)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should create stylesheets css" do
|
80
|
+
source = "#{GaeAppGenerator.source_root}/webapp/stylesheets/application.css"
|
81
|
+
destination = "#{@webapp}/stylesheets/application.css"
|
82
|
+
exists_and_identical?(source, destination)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should create application js" do
|
86
|
+
destination = "#{@webapp}/javascripts/application.js"
|
87
|
+
File.exists?(destination).should be_true
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should create images folder" do
|
91
|
+
File.exist?("#{@webapp}/images").should be_true
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "creating test" do
|
96
|
+
before(:all) do
|
97
|
+
@test_java = "#{@project_path}/#{Configuration::TEST_SRC}"
|
98
|
+
@test_resource = "#{@project_path}/#{Configuration::TEST_RESOURCES}"
|
99
|
+
@app = "#{@test_java}/app"
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should create test source folder" do
|
103
|
+
File.exist?(@test_java).should be_true
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should create app folder" do
|
107
|
+
File.exist?(@app).should be_true
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should create controllers folder" do
|
111
|
+
File.exist?("#{@app}/control").should be_true
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should create models folder" do
|
115
|
+
File.exist?("#{@app}/domain").should be_true
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should create respositories folder" do
|
119
|
+
File.exist?("#{@app}/repository").should be_true
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should create test resource folder" do
|
123
|
+
File.exist?(@test_resource).should be_true
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context "build app with complex package" do
|
129
|
+
|
130
|
+
before(:all) do
|
131
|
+
@project_path = "src/vraptor-scaffold"
|
132
|
+
GaeAppGenerator.new(@project_path, ["-p=br.com.caelum", "--skip-jquery"]).invoke_all
|
133
|
+
@main_java = "#{@project_path}/#{Configuration::MAIN_SRC}/br/com/caelum"
|
134
|
+
@test_java = "#{@project_path}/#{Configuration::TEST_SRC}/br/com/caelum"
|
135
|
+
end
|
136
|
+
|
137
|
+
after(:all) do
|
138
|
+
FileUtils.remove_dir("src")
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should create main path" do
|
142
|
+
File.exist?(@main_java).should be_true
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should create test path" do
|
146
|
+
File.exist?(@test_java).should be_true
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
context "configuring template engine" do
|
152
|
+
|
153
|
+
before(:each) do
|
154
|
+
@project_path = "src/vraptor-scaffold"
|
155
|
+
end
|
156
|
+
|
157
|
+
after(:each) do
|
158
|
+
FileUtils.remove_dir("src")
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should configure jsp template engine" do
|
162
|
+
template = mock(JspTemplateEngine)
|
163
|
+
JspTemplateEngine.stub!(:new).with(@project_path, anything()).and_return(template)
|
164
|
+
template.should_receive(:configure)
|
165
|
+
GaeAppGenerator.new(@project_path, ["--skip-jquery"]).invoke_all
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
context "skip eclipse configuration files" do
|
170
|
+
before(:all) do
|
171
|
+
@project_path = "vraptor-scaffold"
|
172
|
+
GaeAppGenerator.new(@project_path, ["--skip-eclipse", "--skip-jquery"]).invoke_all
|
173
|
+
end
|
174
|
+
|
175
|
+
after(:all) do
|
176
|
+
FileUtils.remove_dir(@project_path)
|
177
|
+
end
|
178
|
+
|
179
|
+
it "cannot create .classpath file" do
|
180
|
+
File.exist?("#{@project_path}/.classpath").should be_false
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
context "gae app" do
|
185
|
+
before(:all) do
|
186
|
+
@project_path = "gae"
|
187
|
+
GaeAppGenerator.new(@project_path, ["--skip-jquery"]).invoke_all
|
188
|
+
@main_java = "#{@project_path}/#{Configuration::MAIN_SRC}"
|
189
|
+
@app = "#{@main_java}/app"
|
190
|
+
end
|
191
|
+
|
192
|
+
after(:all) do
|
193
|
+
FileUtils.remove_dir(@project_path)
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should create ivy.xml" do
|
197
|
+
source = File.join File.dirname(__FILE__), "templates", "ivy-gae.xml"
|
198
|
+
destination = "#{@project_path}/ivy.xml"
|
199
|
+
exists_and_identical?(source, destination)
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should create ivysettings.xml" do
|
203
|
+
File.exist?("#{@project_path}/ivysettings.xml").should be_true
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should not create generic entity" do
|
207
|
+
File.exist?("#{@app}/model/Entity.java").should be_false
|
208
|
+
end
|
209
|
+
|
210
|
+
it "should create appengine-web xml to run gae apps" do
|
211
|
+
File.exist?("#{@project_path}/#{Configuration::WEB_INF}/appengine-web.xml").should be_true
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should create logging properties for gae apps" do
|
215
|
+
File.exist?("#{@project_path}/#{Configuration::WEB_INF}/logging.properties").should be_true
|
216
|
+
end
|
217
|
+
|
218
|
+
it "should create web.xml" do
|
219
|
+
source = File.join File.dirname(__FILE__), "templates", "gae-jsp-web.xml"
|
220
|
+
destination = "#{@project_path}/#{Configuration::WEB_INF}/web.xml"
|
221
|
+
exists_and_identical?(source, destination)
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should generate a objectify repository" do
|
225
|
+
source = File.join File.dirname(__FILE__), "templates", "RepositoryObjectify.java"
|
226
|
+
destination = "#{@project_path}/#{Configuration::MAIN_SRC}/app/repositories/Repository.java"
|
227
|
+
exists_and_identical?(source, destination)
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should generate a objectify resource factory" do
|
231
|
+
source = File.join File.dirname(__FILE__), "templates", "ObjectifyFactory.java"
|
232
|
+
destination = "#{@project_path}/#{Configuration::MAIN_SRC}/app/infra/ObjectifyFactory.java"
|
233
|
+
exists_and_identical?(source, destination)
|
234
|
+
end
|
235
|
+
|
236
|
+
it "should create a specific .classpath for gae" do
|
237
|
+
source = File.join File.dirname(__FILE__), "templates", "classpath-gae"
|
238
|
+
destination = "#{@project_path}/.classpath"
|
239
|
+
exists_and_identical?(source, destination)
|
240
|
+
end
|
241
|
+
|
242
|
+
it "should create a specific .project for gae" do
|
243
|
+
source = File.join File.dirname(__FILE__), "templates", "project-gae"
|
244
|
+
destination = "#{@project_path}/.project"
|
245
|
+
exists_and_identical?(source, destination)
|
246
|
+
end
|
247
|
+
|
248
|
+
it "should create .settings" do
|
249
|
+
settings = File.join @project_path, ".settings"
|
250
|
+
File.exist?(settings).should be_true
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
context "no skip jquery download file" do
|
255
|
+
before(:all) do
|
256
|
+
@project_path = "vraptor-scaffold"
|
257
|
+
|
258
|
+
mock_http_request()
|
259
|
+
|
260
|
+
GaeAppGenerator.new(@project_path).invoke_all
|
261
|
+
end
|
262
|
+
|
263
|
+
after(:all) do
|
264
|
+
FileUtils.remove_dir(@project_path)
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should exist jquery.min.js file" do
|
268
|
+
javascripts = File.join @project_path, Configuration::WEB_APP, "javascripts", "jquery.min.js"
|
269
|
+
File.exist?(javascripts).should be_true
|
270
|
+
end
|
271
|
+
|
272
|
+
it "should show a message for http problems" do
|
273
|
+
http_request = mock(Net::HTTP)
|
274
|
+
http_request.stub!(:get).with(kind_of(String)).and_throw(Net::HTTPError)
|
275
|
+
VraptorScaffold::HttpRequest.stub!(:open_session).with(kind_of(String)).and_return(http_request)
|
276
|
+
|
277
|
+
Kernel.should_receive(:puts).with("Was not possible to download jQuery.")
|
278
|
+
|
279
|
+
local_project_path = "project_without_jquery_by_http_error"
|
280
|
+
GaeAppGenerator.new(local_project_path).invoke_all
|
281
|
+
|
282
|
+
FileUtils.remove_dir(local_project_path)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
end
|