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.
- data/.travis.yml +7 -0
- data/CHANGELOG.rdoc +164 -0
- data/Gemfile.lock +5 -8
- data/README.textile +20 -7
- data/bin/vraptor +1 -1
- data/index.sample.html +169 -0
- data/lib/vraptor-scaffold.rb +10 -29
- data/lib/vraptor-scaffold/configuration.rb +27 -4
- data/lib/vraptor-scaffold/execution.rb +24 -0
- data/lib/vraptor-scaffold/generators/app/app_generator.rb +196 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/dependency.rb +0 -0
- data/lib/vraptor-scaffold/generators/app/dependency_manager.rb +53 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/freemarker_template_engine.rb +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/jsp_template_engine.rb +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/build.gradle.erb +19 -1
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/build.properties.erb +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/build.xml +6 -2
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/decorators.erb +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/classpath.erb +0 -5
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/project.erb +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.jdt.core.prefs +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.common.component.tt +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.common.project.facet.core.xml +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.container +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.name +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/freemarker-web.xml +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/infrastructure/FreemarkerPathResolver.java.tt +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/macros/html.ftl +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker/main.ftl +0 -0
- data/lib/vraptor-scaffold/generators/app/templates/heroku/Main.java +21 -0
- data/lib/vraptor-scaffold/generators/app/templates/heroku/Procfile +1 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/ivy-2.2.0.jar +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/ivy.erb +1 -1
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/jsp/jsp-web.xml +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/jsp/main.jsp +2 -2
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/jsp/prelude.jspf +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator/templates/src/models/Entity.java.tt → app/templates/models/Entity.erb} +1 -1
- data/lib/vraptor-scaffold/generators/app/templates/orm/Repository-hibernate.java.tt +50 -0
- data/lib/vraptor-scaffold/generators/{app_generator/templates/src/repositories/Repository.java.tt → app/templates/orm/Repository-jpa.java.tt} +3 -3
- data/lib/vraptor-scaffold/generators/app/templates/orm/hibernate.cfg.xml +7 -0
- data/lib/vraptor-scaffold/generators/app/templates/orm/persistence.xml +10 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/pom.erb +29 -13
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/resources-test/.empty_directory +0 -0
- data/lib/vraptor-scaffold/generators/app/templates/resources/hibernate.properties +16 -0
- data/lib/vraptor-scaffold/generators/app/templates/resources/log4j.properties +4 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/resources/messages.properties +0 -0
- data/lib/vraptor-scaffold/generators/app/templates/vraptor-scaffold.erb +7 -0
- data/lib/vraptor-scaffold/generators/{app_generator/templates/webapp/WEB-INF/web.xml → app/templates/webapp/WEB-INF/web.xml.tt} +2 -2
- data/lib/vraptor-scaffold/generators/{app_generator/templates/src-test/controllers → app/templates/webapp/images}/.empty_directory +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/index.jsp +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/stylesheets/common.css +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/stylesheets/scaffold.css +0 -0
- data/lib/vraptor-scaffold/generators/{app_generator → app}/templates/webapp/stylesheets/stylesheets.css +0 -0
- data/lib/vraptor-scaffold/generators/plugin/plugin_generator.rb +42 -0
- data/lib/vraptor-scaffold/generators/plugin/vraptor_gem.rb +36 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/attribute.rb +1 -1
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/base_scaffold.rb +6 -2
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/controller_generator.rb +3 -3
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/templates/controller.erb +3 -3
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/templates/controller_test.erb +1 -1
- data/lib/vraptor-scaffold/generators/scaffold/model_generator/model_generator.rb +20 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/model_generator/templates/model.erb +3 -3
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/model_generator/templates/model_test.erb +1 -1
- data/lib/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator.rb +27 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/repository.erb +3 -3
- data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/repository_impl.erb +16 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/repository_test.erb +1 -1
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold}/scaffold_generator.rb +0 -0
- data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/freemarker_generator.rb +18 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/freemarker_generator/templates/edit.erb +0 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/freemarker_generator/templates/form.erb +4 -4
- data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/templates/index.erb +36 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/freemarker_generator/templates/new.erb +0 -0
- data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/freemarker_generator/templates/show.erb +14 -0
- data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/jsp_generator/jsp_generator.rb +18 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/edit.erb +0 -0
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/form.erb +4 -4
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/index.erb +6 -6
- data/lib/vraptor-scaffold/generators/{scaffold_generator → scaffold/template_engine_generator}/jsp_generator/templates/new.erb +0 -0
- data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/jsp_generator/templates/show.erb +14 -0
- data/lib/vraptor-scaffold/generators/scaffold/template_engine_generator/template_engine_generator.rb +21 -0
- data/lib/vraptor-scaffold/load_paths.rb +13 -21
- data/lib/vraptor-scaffold/runner.rb +11 -0
- data/lib/vraptor-scaffold/runner/commands_help.rb +13 -0
- data/lib/vraptor-scaffold/runner/configure.rb +21 -0
- data/lib/vraptor-scaffold/runner/generator.rb +15 -0
- data/lib/vraptor-scaffold/runner/help.rb +12 -0
- data/lib/vraptor-scaffold/runner/plugin.rb +19 -0
- data/lib/vraptor-scaffold/runner/scaffold.rb +16 -0
- data/lib/vraptor-scaffold/version.rb +1 -1
- data/spec/resources/vraptor-scaffold.properties +5 -0
- data/spec/simple_custom_plugin.rb +10 -0
- data/spec/spec_helper.rb +5 -6
- data/spec/vraptor-scaffold/configuration_spec.rb +88 -4
- data/spec/vraptor-scaffold/execution_spec.rb +47 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/app_generator_spec.rb +136 -54
- data/spec/vraptor-scaffold/generators/{app_generator → app}/dependency_manager_spec.rb +1 -1
- data/spec/vraptor-scaffold/generators/{app_generator → app}/dependency_spec.rb +0 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/freemarker_template_engine_spec.rb +1 -1
- data/spec/vraptor-scaffold/generators/{app_generator → app}/jsp_template_engine_spec.rb +0 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/Entity.java +1 -1
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/FreemarkerPathResolver.java +0 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/Repository.java +3 -3
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/build.gradle +24 -5
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/build.properties +0 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/decorators-jsp.xml +0 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/decorators.xml +0 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/freemarker-web.xml +2 -2
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/ivy.xml +6 -5
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/jsp-web.xml +1 -1
- data/spec/vraptor-scaffold/generators/app/templates/pom-heroku.xml +168 -0
- data/spec/vraptor-scaffold/generators/{app_generator → app}/templates/pom.xml +11 -14
- data/spec/vraptor-scaffold/generators/app/templates/vraptor-scaffold.properties +7 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/build.gradle +61 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_build.gradle +61 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_ivy.xml +40 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_pom.xml +147 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/ivy.xml +40 -0
- data/spec/vraptor-scaffold/generators/plugin/expected_configs/pom.xml +147 -0
- data/spec/vraptor-scaffold/generators/plugin/plugin_generator_spec.rb +130 -0
- data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/attribute_spec.rb +13 -9
- data/spec/vraptor-scaffold/generators/scaffold/base_scaffold_spec.rb +73 -0
- data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/controller_generator_spec.rb +18 -9
- data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/controller_generator/templates/ProductController.java +3 -3
- data/spec/vraptor-scaffold/generators/scaffold/freemarker_generator/freemarker_generator_spec.rb +74 -0
- data/spec/vraptor-scaffold/generators/scaffold/jsp_generator/jsp_generator_spec.rb +75 -0
- data/spec/vraptor-scaffold/generators/scaffold/model_generator/model_generator_spec.rb +50 -0
- data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/model_generator/templates/Product.java +6 -6
- data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/hibernate.cfg.xml +8 -0
- data/spec/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator_spec.rb +60 -0
- data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ClientRepository.java +22 -0
- data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ClientRepositoryImpl.java +16 -0
- data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/ProductRepository.java +3 -3
- data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/repository_generator/templates/ProductRepositoryImpl.java +3 -3
- data/spec/vraptor-scaffold/generators/{scaffold_generator → scaffold}/scaffold_generator_spec.rb +0 -0
- data/spec/vraptor-scaffold/runner/commands_help_spec.rb +12 -0
- data/spec/vraptor-scaffold/runner/configure_spec.rb +12 -0
- data/spec/vraptor-scaffold/runner/generator_spec.rb +31 -0
- data/spec/vraptor-scaffold/runner/help_spec.rb +29 -0
- data/spec/vraptor-scaffold/runner/plugin_spec.rb +45 -0
- data/spec/vraptor-scaffold/runner/scaffold_spec.rb +35 -0
- data/spec/vraptor-scaffold_spec.rb +1 -94
- data/vraptor-scaffold.gemspec +3 -3
- metadata +137 -140
- data/History.txt +0 -128
- data/lib/vraptor-scaffold/generators/app_generator/app_generator.rb +0 -102
- data/lib/vraptor-scaffold/generators/app_generator/dependency_manager.rb +0 -37
- data/lib/vraptor-scaffold/generators/app_generator/templates/ivysettings.xml +0 -9
- data/lib/vraptor-scaffold/generators/app_generator/templates/resources/META-INF/persistence.xml +0 -20
- data/lib/vraptor-scaffold/generators/app_generator/templates/resources/log4j.properties +0 -4
- data/lib/vraptor-scaffold/generators/app_generator/templates/src-test/models/.empty_directory +0 -0
- data/lib/vraptor-scaffold/generators/app_generator/templates/src-test/repositories/.empty_directory +0 -0
- data/lib/vraptor-scaffold/generators/app_generator/templates/src/controllers/.empty_directory +0 -0
- data/lib/vraptor-scaffold/generators/app_generator/templates/vraptor-scaffold.erb +0 -2
- data/lib/vraptor-scaffold/generators/app_generator/templates/webapp/images/.empty_directory +0 -0
- data/lib/vraptor-scaffold/generators/app_generator/templates/webapp/javascripts/application.js +0 -0
- data/lib/vraptor-scaffold/generators/app_generator/templates/webapp/javascripts/jquery.min.js +0 -16
- data/lib/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/freemarker_generator.rb +0 -22
- data/lib/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/templates/index.erb +0 -36
- data/lib/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/templates/show.erb +0 -14
- data/lib/vraptor-scaffold/generators/scaffold_generator/jsp_generator/jsp_generator.rb +0 -22
- data/lib/vraptor-scaffold/generators/scaffold_generator/jsp_generator/templates/show.erb +0 -14
- data/lib/vraptor-scaffold/generators/scaffold_generator/model_generator/model_generator.rb +0 -11
- data/lib/vraptor-scaffold/generators/scaffold_generator/repository_generator/repository_generator.rb +0 -12
- data/lib/vraptor-scaffold/generators/scaffold_generator/repository_generator/templates/repository_impl.erb +0 -16
- data/spec/vraptor-scaffold/generators/scaffold_generator/base_scaffold_spec.rb +0 -41
- data/spec/vraptor-scaffold/generators/scaffold_generator/freemarker_generator/freemarker_generator_spec.rb +0 -36
- data/spec/vraptor-scaffold/generators/scaffold_generator/jsp_generator/jsp_generator_spec.rb +0 -34
- data/spec/vraptor-scaffold/generators/scaffold_generator/model_generator/model_generator_spec.rb +0 -25
- data/spec/vraptor-scaffold/generators/scaffold_generator/repository_generator/repository_generator_spec.rb +0 -31
data/spec/spec_helper.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec/autorun'
|
|
3
3
|
require File.dirname(__FILE__) + '/../lib/vraptor-scaffold'
|
4
4
|
|
5
5
|
def build_attributes
|
6
|
-
[Attribute.new("name", "string"), Attribute.new("
|
6
|
+
[Attribute.new("name", "string"), Attribute.new("myFlag", "boolean")]
|
7
7
|
end
|
8
8
|
|
9
9
|
def mock_config_file
|
@@ -11,9 +11,8 @@ def mock_config_file
|
|
11
11
|
Configuration.stub!(:config).and_return(file)
|
12
12
|
end
|
13
13
|
|
14
|
-
def exists_and_identical?(source,
|
15
|
-
File.
|
16
|
-
|
14
|
+
def exists_and_identical?(source, created)
|
15
|
+
c = File.open(created).read.gsub( /\r/m, "" )
|
16
|
+
c2 = File.open(source).read.gsub( /\r/m, "" )
|
17
|
+
c.should be == c2
|
17
18
|
end
|
18
|
-
|
19
|
-
|
@@ -30,22 +30,47 @@ describe Configuration do
|
|
30
30
|
Configuration::META_INF.should == "#{Configuration::WEB_APP}/META-INF"
|
31
31
|
end
|
32
32
|
|
33
|
-
it "should configure properties
|
33
|
+
it "should configure scaffold properties" do
|
34
34
|
Configuration::FILENAME.should == "#{Configuration::META_INF}/vraptor-scaffold.properties"
|
35
35
|
end
|
36
36
|
|
37
37
|
context "load config file" do
|
38
38
|
before(:each) do
|
39
|
-
config = {"template_engine" => "jsp", "package" => "br.com.caelum"
|
39
|
+
config = {"template_engine" => "jsp", "package" => "br.com.caelum", "orm" => "jpa", "models_package" => "model",
|
40
|
+
"controllers_package" => "controller", "repositories_package" => "repository"}
|
40
41
|
YAML.stub!(:load_file).with(Configuration::FILENAME).and_return(config)
|
41
42
|
end
|
42
43
|
|
44
|
+
it "should know models package" do
|
45
|
+
Configuration.models_package.should == "model"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should know controllers package" do
|
49
|
+
Configuration.controllers_package.should == "controller"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should know repositories package" do
|
53
|
+
Configuration.repositories_package.should == "repository"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should know full models package" do
|
57
|
+
Configuration.full_models_package.should == "br.com.caelum.model"
|
58
|
+
end
|
59
|
+
|
43
60
|
it "should know template engine" do
|
44
|
-
Configuration.template_engine.should == "jsp"
|
61
|
+
Configuration.template_engine.should == "jsp"
|
45
62
|
end
|
46
63
|
|
47
64
|
it "should know base package" do
|
48
|
-
Configuration.package.should == "br.com.caelum"
|
65
|
+
Configuration.package.should == "br.com.caelum"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should know orm" do
|
69
|
+
Configuration.orm.should == "jpa"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "orm cannot be hibernate" do
|
73
|
+
Configuration.hibernate?.should be_false
|
49
74
|
end
|
50
75
|
|
51
76
|
it "should build main class path with base package" do
|
@@ -56,4 +81,63 @@ describe Configuration do
|
|
56
81
|
Configuration.test_class_path("models", "Product.java").should == "src/test/java/br/com/caelum/models/Product.java"
|
57
82
|
end
|
58
83
|
end
|
84
|
+
context "hibernate" do
|
85
|
+
before(:each) do
|
86
|
+
config = {"template_engine" => "jsp", "package" => "br.com.caelum", "orm" => "hibernate"}
|
87
|
+
YAML.stub!(:load_file).with(Configuration::FILENAME).and_return(config)
|
88
|
+
end
|
89
|
+
it "should know orm" do
|
90
|
+
Configuration.orm.should == "hibernate"
|
91
|
+
end
|
92
|
+
|
93
|
+
it "orm should be hibernate" do
|
94
|
+
Configuration.hibernate?.should be_true
|
95
|
+
end
|
96
|
+
end
|
97
|
+
context "properties without default configs" do
|
98
|
+
before(:each) do
|
99
|
+
config = {}
|
100
|
+
YAML.stub!(:load_file).with(Configuration::FILENAME).and_return(config)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should know models package" do
|
104
|
+
Configuration.models_package.should == "models"
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should know controllers package" do
|
108
|
+
Configuration.controllers_package.should == "controllers"
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should know repositories package" do
|
112
|
+
Configuration.repositories_package.should == "repositories"
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should know full models package" do
|
116
|
+
Configuration.full_models_package.should == "app.models"
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should know template engine" do
|
120
|
+
Configuration.template_engine.should == "jsp"
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should know base package" do
|
124
|
+
Configuration.package.should == "app"
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should know orm" do
|
128
|
+
Configuration.orm.should == "jpa"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "orm cannot be hibernate" do
|
132
|
+
Configuration.hibernate?.should be_false
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should build main class path with base package" do
|
136
|
+
Configuration.main_class_path("models", "Product.java").should == "src/main/java/app/models/Product.java"
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should build test class path with base package" do
|
140
|
+
Configuration.test_class_path("models", "Product.java").should == "src/test/java/app/models/Product.java"
|
141
|
+
end
|
142
|
+
end
|
59
143
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe VraptorScaffold::Execution do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@execution = VraptorScaffold::Execution.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context "discover runner for action" do
|
10
|
+
it "should be commands help when no action" do
|
11
|
+
@execution.runner_for(nil).should == VraptorScaffold::Runner::CommandsHelp
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be app generator when -h action" do
|
15
|
+
@execution.runner_for("-h").should == VraptorScaffold::Runner::Generator
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should be app generator when --help action" do
|
19
|
+
@execution.runner_for("--help").should == VraptorScaffold::Runner::Generator
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should be app generator when new action" do
|
23
|
+
@execution.runner_for("new").should == VraptorScaffold::Runner::Generator
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should be app generator when scaffold action" do
|
27
|
+
@execution.runner_for("scaffold").should == VraptorScaffold::Runner::Scaffold
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be plugin generator when plugin action" do
|
31
|
+
@execution.runner_for("plugin").should == VraptorScaffold::Runner::Plugin
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should be commands help when scaffold when unknown action" do
|
35
|
+
@execution.runner_for("xpto").should == VraptorScaffold::Runner::CommandsHelp
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should discover runner and run" do
|
40
|
+
runner = mock(VraptorScaffold::Runner::Generator)
|
41
|
+
runner.stub!(:new).and_return runner
|
42
|
+
runner.should_receive(:run).with(['app'])
|
43
|
+
@execution.stub!(:runner_for).with('new').and_return(runner)
|
44
|
+
@execution.run(['new', 'app'])
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -5,7 +5,7 @@ describe AppGenerator do
|
|
5
5
|
context "build new application" do
|
6
6
|
before(:all) do
|
7
7
|
@project_path = "src/vraptor-scaffold"
|
8
|
-
AppGenerator.new(@project_path, ["-b=mvn"]).invoke_all
|
8
|
+
AppGenerator.new(@project_path, ["-b=mvn", "-r=repository", "-m=domain", "-c=control"]).invoke_all
|
9
9
|
end
|
10
10
|
|
11
11
|
after(:all) do
|
@@ -13,7 +13,12 @@ describe AppGenerator do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should create directory with project name" do
|
16
|
-
File.exist?(@project_path).should be_true
|
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
|
+
AppGenerator.new(@project_path)
|
17
22
|
end
|
18
23
|
|
19
24
|
it "should create pom" do
|
@@ -23,7 +28,7 @@ describe AppGenerator do
|
|
23
28
|
end
|
24
29
|
|
25
30
|
it "cannot create ivy.xml" do
|
26
|
-
File.exist?("#{@project_path}/ivy.xml").should be_false
|
31
|
+
File.exist?("#{@project_path}/ivy.xml").should be_false
|
27
32
|
end
|
28
33
|
|
29
34
|
it "cannot create build.gradle" do
|
@@ -34,6 +39,12 @@ describe AppGenerator do
|
|
34
39
|
File.exist?("#{@project_path}/.classpath").should be_false
|
35
40
|
end
|
36
41
|
|
42
|
+
it "should configure vraptor-scaffold.properties" do
|
43
|
+
source = File.join File.dirname(__FILE__), "templates", "vraptor-scaffold.properties"
|
44
|
+
destination = "#{@project_path}/#{Configuration::FILENAME}"
|
45
|
+
exists_and_identical?(source, destination)
|
46
|
+
end
|
47
|
+
|
37
48
|
context "creating main java" do
|
38
49
|
before(:all) do
|
39
50
|
@main_java = "#{@project_path}/#{Configuration::MAIN_SRC}"
|
@@ -41,42 +52,69 @@ describe AppGenerator do
|
|
41
52
|
end
|
42
53
|
|
43
54
|
it "should create source folder" do
|
44
|
-
File.exist?(@main_java).should be_true
|
55
|
+
File.exist?(@main_java).should be_true
|
45
56
|
end
|
46
57
|
|
47
58
|
it "should create app folder" do
|
48
|
-
File.exist?(@app).should be_true
|
59
|
+
File.exist?(@app).should be_true
|
49
60
|
end
|
50
61
|
|
51
62
|
it "should create controllers folder" do
|
52
|
-
File.exist?("#{@app}/
|
63
|
+
File.exist?("#{@app}/control").should be_true
|
53
64
|
end
|
54
65
|
|
55
66
|
it "should create models folder" do
|
56
|
-
File.exist?("#{@app}/
|
67
|
+
File.exist?("#{@app}/domain").should be_true
|
57
68
|
end
|
58
69
|
|
59
70
|
it "should create generic entity" do
|
60
71
|
source = File.join File.dirname(__FILE__), "templates", "Entity.java"
|
61
|
-
destination = "#{@app}/
|
72
|
+
destination = "#{@app}/domain/Entity.java"
|
62
73
|
exists_and_identical?(source, destination)
|
63
74
|
end
|
64
75
|
|
65
76
|
it "should create generic repository" do
|
66
77
|
source = File.join File.dirname(__FILE__), "templates", "Repository.java"
|
67
|
-
destination = "#{@app}/
|
78
|
+
destination = "#{@app}/repository/Repository.java"
|
68
79
|
exists_and_identical?(source, destination)
|
69
80
|
end
|
70
81
|
end
|
71
82
|
|
72
83
|
context "creating main resources" do
|
73
|
-
before(:
|
84
|
+
before(:each) do
|
74
85
|
@main_resources = "#{@project_path}/#{Configuration::MAIN_RESOURCES}"
|
75
86
|
@meta_inf = "#{@main_resources}/META-INF"
|
76
|
-
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context "hibernate orm" do
|
90
|
+
before(:all) do
|
91
|
+
@project_path = "src/vraptor-scaffold-hibernate"
|
92
|
+
@main_resources = "#{@project_path}/#{Configuration::MAIN_RESOURCES}"
|
93
|
+
@meta_inf = "#{@main_resources}/META-INF"
|
94
|
+
AppGenerator.new(@project_path, ["--orm=hibernate"]).invoke_all
|
95
|
+
end
|
96
|
+
|
97
|
+
after(:all) do
|
98
|
+
FileUtils.remove_dir("src/vraptor-scaffold-hibernate")
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should create hibernate.cfg.xml" do
|
102
|
+
source = "#{AppGenerator.source_root}/orm/hibernate.cfg.xml"
|
103
|
+
destination = "#{@main_resources}/hibernate.cfg.xml"
|
104
|
+
exists_and_identical?(source, destination)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "cannot create META-INF" do
|
108
|
+
File.exist?(@meta_inf).should be_false
|
109
|
+
end
|
110
|
+
|
111
|
+
it "cannot create persistence.xml" do
|
112
|
+
File.exist?("#{@meta_inf}/persistence.xml").should be_false
|
113
|
+
end
|
114
|
+
end
|
77
115
|
|
78
116
|
it "should create resource folder" do
|
79
|
-
File.exist?(@main_resources).should be_true
|
117
|
+
File.exist?(@main_resources).should be_true
|
80
118
|
end
|
81
119
|
|
82
120
|
it "should create log4j" do
|
@@ -85,18 +123,28 @@ describe AppGenerator do
|
|
85
123
|
exists_and_identical?(source, destination)
|
86
124
|
end
|
87
125
|
|
88
|
-
it "should create messages
|
126
|
+
it "should create messages.properties" do
|
89
127
|
source = "#{AppGenerator.source_root}/resources/messages.properties"
|
90
128
|
destination = "#{@main_resources}/messages.properties"
|
91
129
|
exists_and_identical?(source, destination)
|
92
130
|
end
|
93
131
|
|
132
|
+
it "should create hibernate.properties" do
|
133
|
+
source = "#{AppGenerator.source_root}/resources/hibernate.properties"
|
134
|
+
destination = "#{@main_resources}/hibernate.properties"
|
135
|
+
exists_and_identical?(source, destination)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "cannot create hibernate.cfg.xml" do
|
139
|
+
File.exist?("#{@main_resources}/hibernate.cfg.xml").should be_false
|
140
|
+
end
|
141
|
+
|
94
142
|
it "should create META-INF" do
|
95
|
-
File.exist?(@meta_inf).should be_true
|
143
|
+
File.exist?(@meta_inf).should be_true
|
96
144
|
end
|
97
145
|
|
98
146
|
it "should create persistence.xml" do
|
99
|
-
source = "#{AppGenerator.source_root}/
|
147
|
+
source = "#{AppGenerator.source_root}/orm/persistence.xml"
|
100
148
|
destination = "#{@meta_inf}/persistence.xml"
|
101
149
|
exists_and_identical?(source, destination)
|
102
150
|
end
|
@@ -106,10 +154,10 @@ describe AppGenerator do
|
|
106
154
|
before(:all) do
|
107
155
|
@webapp = "#{@project_path}/#{Configuration::WEB_APP}"
|
108
156
|
@web_inf = "#{@project_path}/#{Configuration::WEB_INF}"
|
109
|
-
end
|
157
|
+
end
|
110
158
|
|
111
159
|
it "should create webapp folder" do
|
112
|
-
File.exist?(@webapp).should be_true
|
160
|
+
File.exist?(@webapp).should be_true
|
113
161
|
end
|
114
162
|
|
115
163
|
it "should create index" do
|
@@ -119,7 +167,7 @@ describe AppGenerator do
|
|
119
167
|
end
|
120
168
|
|
121
169
|
it "should create WEB-INF folder" do
|
122
|
-
File.exist?(@web_inf).should be_true
|
170
|
+
File.exist?(@web_inf).should be_true
|
123
171
|
end
|
124
172
|
|
125
173
|
it "should create scaffold css" do
|
@@ -141,19 +189,17 @@ describe AppGenerator do
|
|
141
189
|
end
|
142
190
|
|
143
191
|
it "should create jquery js" do
|
144
|
-
source = "#{AppGenerator.source_root}/webapp/javascripts/jquery.min.js"
|
145
192
|
destination = "#{@webapp}/javascripts/jquery.min.js"
|
146
|
-
|
193
|
+
File.exists?(destination).should be_true
|
147
194
|
end
|
148
195
|
|
149
196
|
it "should create application js" do
|
150
|
-
source = "#{AppGenerator.source_root}/webapp/javascripts/application.js"
|
151
197
|
destination = "#{@webapp}/javascripts/application.js"
|
152
|
-
|
198
|
+
File.exists?(destination).should be_true
|
153
199
|
end
|
154
200
|
|
155
201
|
it "should create images folder" do
|
156
|
-
File.exist?("#{@webapp}/images").should be_true
|
202
|
+
File.exist?("#{@webapp}/images").should be_true
|
157
203
|
end
|
158
204
|
end
|
159
205
|
|
@@ -165,29 +211,29 @@ describe AppGenerator do
|
|
165
211
|
end
|
166
212
|
|
167
213
|
it "should create test source folder" do
|
168
|
-
File.exist?(@test_java).should be_true
|
214
|
+
File.exist?(@test_java).should be_true
|
169
215
|
end
|
170
216
|
|
171
217
|
it "should create app folder" do
|
172
|
-
File.exist?(@app).should be_true
|
218
|
+
File.exist?(@app).should be_true
|
173
219
|
end
|
174
220
|
|
175
221
|
it "should create controllers folder" do
|
176
|
-
File.exist?("#{@app}/
|
222
|
+
File.exist?("#{@app}/control").should be_true
|
177
223
|
end
|
178
224
|
|
179
225
|
it "should create models folder" do
|
180
|
-
File.exist?("#{@app}/
|
226
|
+
File.exist?("#{@app}/domain").should be_true
|
181
227
|
end
|
182
228
|
|
183
229
|
it "should create respositories folder" do
|
184
|
-
File.exist?("#{@app}/
|
185
|
-
end
|
230
|
+
File.exist?("#{@app}/repository").should be_true
|
231
|
+
end
|
186
232
|
|
187
233
|
it "should create test resource folder" do
|
188
|
-
File.exist?(@test_resource).should be_true
|
234
|
+
File.exist?(@test_resource).should be_true
|
189
235
|
end
|
190
|
-
end
|
236
|
+
end
|
191
237
|
end
|
192
238
|
|
193
239
|
context "build app with complex package" do
|
@@ -204,11 +250,11 @@ describe AppGenerator do
|
|
204
250
|
end
|
205
251
|
|
206
252
|
it "should create main path" do
|
207
|
-
File.exist?(@main_java).should be_true
|
253
|
+
File.exist?(@main_java).should be_true
|
208
254
|
end
|
209
255
|
|
210
256
|
it "should create test path" do
|
211
|
-
File.exist?(@test_java).should be_true
|
257
|
+
File.exist?(@test_java).should be_true
|
212
258
|
end
|
213
259
|
|
214
260
|
end
|
@@ -237,7 +283,7 @@ describe AppGenerator do
|
|
237
283
|
AppGenerator.new(@project_path).invoke_all
|
238
284
|
end
|
239
285
|
end
|
240
|
-
|
286
|
+
|
241
287
|
context "configuring ant application" do
|
242
288
|
|
243
289
|
before(:all) do
|
@@ -266,20 +312,14 @@ describe AppGenerator do
|
|
266
312
|
destination = "#{@project_path}/ivy.xml"
|
267
313
|
exists_and_identical?(source, destination)
|
268
314
|
end
|
269
|
-
|
270
|
-
it "should create ivysettings.xml" do
|
271
|
-
source = File.join AppGenerator.source_root, "ivysettings.xml"
|
272
|
-
destination = "#{@project_path}/ivysettings.xml"
|
273
|
-
exists_and_identical?(source, destination)
|
274
|
-
end
|
275
315
|
|
276
316
|
it "should copy ivy.jar" do
|
277
317
|
ivy = File.join @project_path, AppGenerator::IVY_JAR
|
278
|
-
File.exist?(ivy).should be_true
|
318
|
+
File.exist?(ivy).should be_true
|
279
319
|
end
|
280
320
|
|
281
321
|
it "cannot create pom.xml" do
|
282
|
-
File.exist?("#{@project_path}/pom.xml").should be_false
|
322
|
+
File.exist?("#{@project_path}/pom.xml").should be_false
|
283
323
|
end
|
284
324
|
|
285
325
|
it "cannot create build.gradle" do
|
@@ -300,7 +340,7 @@ describe AppGenerator do
|
|
300
340
|
it "should create .settings" do
|
301
341
|
settings = File.join @project_path, ".settings"
|
302
342
|
File.exist?(settings).should be_true
|
303
|
-
end
|
343
|
+
end
|
304
344
|
end
|
305
345
|
end
|
306
346
|
|
@@ -318,7 +358,7 @@ describe AppGenerator do
|
|
318
358
|
File.exist?("#{@project_path}/.classpath").should be_false
|
319
359
|
end
|
320
360
|
end
|
321
|
-
|
361
|
+
|
322
362
|
context "configuring gradle application" do
|
323
363
|
|
324
364
|
before(:all) do
|
@@ -337,11 +377,11 @@ describe AppGenerator do
|
|
337
377
|
end
|
338
378
|
|
339
379
|
it "cannot create ivy.xml" do
|
340
|
-
File.exist?("#{@project_path}/ivy.xml").should be_false
|
380
|
+
File.exist?("#{@project_path}/ivy.xml").should be_false
|
341
381
|
end
|
342
382
|
|
343
383
|
it "cannot create pom.xml" do
|
344
|
-
File.exist?("#{@project_path}/pom.xml").should be_false
|
384
|
+
File.exist?("#{@project_path}/pom.xml").should be_false
|
345
385
|
end
|
346
386
|
end
|
347
387
|
|
@@ -369,27 +409,69 @@ describe AppGenerator do
|
|
369
409
|
end
|
370
410
|
end
|
371
411
|
|
412
|
+
context "valid orm" do
|
413
|
+
it "jpa should be valid" do
|
414
|
+
AppGenerator::ORMS.include?("jpa").should be_true
|
415
|
+
end
|
416
|
+
|
417
|
+
it "hibernate should be valid" do
|
418
|
+
AppGenerator::ORMS.include?("hibernate").should be_true
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
372
422
|
it "should configure banner" do
|
373
423
|
AppGenerator.banner.should == "vraptor new PROJECT_PATH [options]"
|
374
424
|
end
|
375
|
-
|
425
|
+
|
376
426
|
context "validate options" do
|
377
427
|
before(:each) do
|
378
428
|
@project_path = "vraptor-scaffold"
|
379
429
|
end
|
380
430
|
|
381
|
-
|
431
|
+
it "should be invalid when build tool is not supported" do
|
432
|
+
Kernel.should_receive(:exit)
|
433
|
+
AppGenerator.new(@project_path, ["-b=maven"])
|
434
|
+
end
|
435
|
+
|
436
|
+
it "should be invalid when template engine is not supported" do
|
437
|
+
Kernel.should_receive(:exit)
|
438
|
+
AppGenerator.new(@project_path, ["-e=velocity"])
|
439
|
+
end
|
440
|
+
|
441
|
+
it "should be invalid when orm mapping is not supported" do
|
442
|
+
Kernel.should_receive(:exit)
|
443
|
+
AppGenerator.new(@project_path, ["-o=toplink"])
|
444
|
+
end
|
445
|
+
|
446
|
+
it "should be invalid when jquery version does not exist" do
|
447
|
+
Kernel.should_receive(:exit)
|
448
|
+
AppGenerator.new(@project_path, ["-j=1.x"])
|
449
|
+
end
|
450
|
+
end
|
451
|
+
|
452
|
+
context "heroku app" do
|
453
|
+
before(:all) do
|
454
|
+
@project_path = "heroku"
|
455
|
+
AppGenerator.new(@project_path, ["--heroku"]).invoke_all
|
456
|
+
end
|
457
|
+
|
458
|
+
after(:all) do
|
382
459
|
FileUtils.remove_dir(@project_path)
|
383
460
|
end
|
384
461
|
|
385
|
-
it "should
|
386
|
-
|
387
|
-
|
462
|
+
it "should create pom" do
|
463
|
+
source = File.join File.dirname(__FILE__), "templates", "pom-heroku.xml"
|
464
|
+
destination = "#{@project_path}/pom.xml"
|
465
|
+
exists_and_identical?(source, destination)
|
388
466
|
end
|
389
467
|
|
390
|
-
it "should
|
391
|
-
|
392
|
-
|
468
|
+
it "should create Procfile" do
|
469
|
+
File.exist?("#{@project_path}/Procfile").should be_true
|
470
|
+
end
|
471
|
+
|
472
|
+
it "should create main class to run heroku apps" do
|
473
|
+
File.exist?("#{@project_path}/src/main/java/Main.java").should be_true
|
393
474
|
end
|
394
475
|
end
|
476
|
+
|
395
477
|
end
|