padrino-gen 0.9.14 → 0.9.15
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.rdoc +17 -2
- data/Rakefile +1 -2
- data/bin/padrino-gen +2 -3
- data/lib/padrino-gen.rb +2 -2
- data/lib/padrino-gen/generators/actions.rb +62 -8
- data/lib/padrino-gen/generators/app.rb +2 -1
- data/lib/padrino-gen/generators/cli.rb +3 -3
- data/lib/padrino-gen/generators/components/orms/activerecord.rb +10 -9
- data/lib/padrino-gen/generators/components/orms/couchrest.rb +1 -1
- data/lib/padrino-gen/generators/components/orms/datamapper.rb +11 -9
- data/lib/padrino-gen/generators/components/orms/mongoid.rb +1 -1
- data/lib/padrino-gen/generators/components/orms/mongomapper.rb +1 -1
- data/lib/padrino-gen/generators/components/orms/mongomatic.rb +85 -0
- data/lib/padrino-gen/generators/components/orms/ohm.rb +72 -0
- data/lib/padrino-gen/generators/components/orms/sequel.rb +12 -11
- data/lib/padrino-gen/generators/components/renderers/erubis.rb +3 -0
- data/lib/padrino-gen/generators/components/renderers/liquid.rb +4 -0
- data/lib/padrino-gen/generators/components/stylesheets/compass.rb +3 -3
- data/lib/padrino-gen/generators/components/stylesheets/compass/application.scss +1 -1
- data/lib/padrino-gen/generators/components/stylesheets/less.rb +12 -23
- data/lib/padrino-gen/generators/components/stylesheets/sass.rb +6 -16
- data/lib/padrino-gen/generators/components/stylesheets/scss.rb +16 -0
- data/lib/padrino-gen/generators/components/tests/riot.rb +5 -23
- data/lib/padrino-gen/generators/controller.rb +1 -1
- data/lib/padrino-gen/generators/mailer.rb +3 -1
- data/lib/padrino-gen/generators/migration.rb +1 -1
- data/lib/padrino-gen/generators/model.rb +1 -1
- data/lib/padrino-gen/generators/plugin.rb +47 -0
- data/lib/padrino-gen/generators/project.rb +39 -22
- data/lib/padrino-gen/generators/project/config/boot.rb +12 -0
- data/lib/padrino-gen/generators/runner.rb +90 -0
- data/lib/padrino-gen/generators/templates/initializer.rb.tt +5 -0
- data/lib/padrino-gen/generators/templates/mailer.rb.tt +10 -0
- data/lib/padrino-gen/padrino-tasks/datamapper.rb +8 -7
- data/padrino-gen.gemspec +11 -12
- data/test/fixtures/admin_template.rb +7 -0
- data/test/fixtures/example_template.rb +14 -0
- data/test/fixtures/git_template.rb +4 -0
- data/test/fixtures/plugin_template.rb +13 -0
- data/test/fixtures/rake_template.rb +9 -0
- data/test/helper.rb +64 -2
- data/test/test_app_generator.rb +16 -1
- data/test/test_controller_generator.rb +1 -1
- data/test/test_generator.rb +1 -1
- data/test/test_mailer_generator.rb +11 -1
- data/test/test_model_generator.rb +64 -20
- data/test/test_plugin_generator.rb +123 -0
- data/test/test_project_generator.rb +134 -77
- metadata +37 -103
@@ -0,0 +1,123 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
|
+
|
3
|
+
class TestPluginGenerator < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
%w(sample_project sample_git sample_rake sample_admin).each { |proj| system("rm -rf /tmp/#{proj}") }
|
6
|
+
end
|
7
|
+
|
8
|
+
context "the plugin destroy option" do
|
9
|
+
should "remove the plugin instance" do
|
10
|
+
path = File.expand_path('../fixtures/plugin_template.rb', __FILE__)
|
11
|
+
silence_logger { generate(:project, 'sample_project', '--root=/tmp') }
|
12
|
+
silence_logger { generate(:plugin, path, '--root=/tmp/sample_project') }
|
13
|
+
silence_logger { generate(:plugin, path, '--root=/tmp/sample_project', '-d') }
|
14
|
+
assert_no_file_exists('/tmp/sample_project/lib/hoptoad_init.rb')
|
15
|
+
assert_no_match_in_file(/enable \:raise_errors/,'/tmp/sample_project/app/app.rb')
|
16
|
+
assert_no_match_in_file(/rack\_hoptoad/, '/tmp/sample_project/Gemfile')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'the project generator with template' do
|
21
|
+
setup do
|
22
|
+
example_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'example_template.rb')
|
23
|
+
silence_logger { generate(:project, 'sample_project', "-p=#{example_template_path}", '-r=/tmp', '> /dev/null') }
|
24
|
+
end
|
25
|
+
|
26
|
+
before_should "invoke Padrino.bin_gen" do
|
27
|
+
expects_generated_project :test => :shoulda, :orm => :activerecord, :dev => true
|
28
|
+
expects_generated :model, "post title:string body:text -r=/tmp/sample_project"
|
29
|
+
expects_generated :controller, "posts get:index get:new post:new -r=/tmp/sample_project"
|
30
|
+
expects_generated :migration, "AddEmailToUser email:string -r=/tmp/sample_project"
|
31
|
+
expects_generated :fake, "foo bar -r=/tmp/sample_project"
|
32
|
+
expects_dependencies 'nokogiri'
|
33
|
+
expects_initializer :test, "# Example"
|
34
|
+
expects_generated :app, "testapp -r=/tmp/sample_project"
|
35
|
+
expects_generated :controller, "users get:index -r=/tmp/sample_project --app=testapp"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "with resolving urls" do
|
40
|
+
|
41
|
+
should "resolve generic url properly" do
|
42
|
+
template_file = 'http://www.example.com/test.rb'
|
43
|
+
project_gen = Padrino::Generators::Project.new(['sample_project'], ["-p=#{template_file}", '-r=/tmp'], {})
|
44
|
+
project_gen.expects(:apply).with(template_file).returns(true).once
|
45
|
+
silence_logger { project_gen.invoke_all }
|
46
|
+
end
|
47
|
+
|
48
|
+
should "resolve gist url properly" do
|
49
|
+
FakeWeb.register_uri(:get, "http://gist.github.com/357045", :body => '<a href="/raw/357045/4356/blog_template.rb">raw</a>')
|
50
|
+
template_file = 'http://gist.github.com/357045'
|
51
|
+
resolved_path = 'http://gist.github.com/raw/357045/4356/blog_template.rb'
|
52
|
+
project_gen = Padrino::Generators::Project.new(['sample_project'], ["-p=#{template_file}", '-r=/tmp'], {})
|
53
|
+
project_gen.expects(:apply).with(resolved_path).returns(true).once
|
54
|
+
silence_logger { project_gen.invoke_all }
|
55
|
+
end
|
56
|
+
|
57
|
+
should "resolve official template" do
|
58
|
+
template_file = 'sampleblog'
|
59
|
+
resolved_path = "http://github.com/padrino/padrino-recipes/raw/master/templates/sampleblog_template.rb"
|
60
|
+
project_gen = Padrino::Generators::Project.new(['sample_project'], ["-p=#{template_file}", '-r=/tmp'], {})
|
61
|
+
project_gen.expects(:apply).with(resolved_path).returns(true).once
|
62
|
+
silence_logger { project_gen.invoke_all }
|
63
|
+
end
|
64
|
+
|
65
|
+
should "resolve local file" do
|
66
|
+
template_file = 'path/to/local/file.rb'
|
67
|
+
project_gen = Padrino::Generators::Project.new(['sample_project'], ["-p=#{template_file}", '-r=/tmp'], {})
|
68
|
+
project_gen.expects(:apply).with(File.expand_path(template_file)).returns(true).once
|
69
|
+
silence_logger { project_gen.invoke_all }
|
70
|
+
end
|
71
|
+
|
72
|
+
should "resolve official plugin" do
|
73
|
+
template_file = 'hoptoad'
|
74
|
+
resolved_path = "http://github.com/padrino/padrino-recipes/raw/master/plugins/hoptoad_plugin.rb"
|
75
|
+
plugin_gen = Padrino::Generators::Plugin.new([ template_file], ['-r=/tmp/sample_project'],{})
|
76
|
+
plugin_gen.expects(:in_app_root?).returns(true).once
|
77
|
+
plugin_gen.expects(:apply).with(resolved_path).returns(true).once
|
78
|
+
silence_logger { plugin_gen.invoke_all }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "with git commands" do
|
83
|
+
setup do
|
84
|
+
git_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'git_template.rb')
|
85
|
+
silence_logger { generate(:project, 'sample_git', "-p=#{git_template_path}", '-r=/tmp', '> /dev/null') }
|
86
|
+
end
|
87
|
+
|
88
|
+
before_should "generate a repository correctly" do
|
89
|
+
expects_generated_project :test => :rspec, :orm => :activerecord, :name => 'sample_git'
|
90
|
+
expects_git :init, :root => '/tmp/sample_git'
|
91
|
+
expects_git :add, :arguments => '.', :root => '/tmp/sample_git'
|
92
|
+
expects_git :commit, :arguments => 'hello', :root => '/tmp/sample_git'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context "with rake invocations" do
|
97
|
+
setup do
|
98
|
+
rake_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'rake_template.rb')
|
99
|
+
silence_logger { generate(:project, 'sample_rake', "-p=#{rake_template_path}", '-r=/tmp', '> /dev/null') }
|
100
|
+
end
|
101
|
+
|
102
|
+
before_should "Run rake task and list tasks" do
|
103
|
+
expects_generated_project :test => :shoulda, :orm => :activerecord, :name => 'sample_rake'
|
104
|
+
expects_rake "custom", :root => '/tmp/sample_rake'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context "with admin commands" do
|
109
|
+
setup do
|
110
|
+
admin_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'admin_template.rb')
|
111
|
+
silence_logger { generate(:project, 'sample_admin', "-p=#{admin_template_path}", '-r=/tmp', '> /dev/null') }
|
112
|
+
end
|
113
|
+
|
114
|
+
before_should "generate correctly an admin" do
|
115
|
+
expects_generated_project :test => :shoulda, :orm => :activerecord, :name => 'sample_admin'
|
116
|
+
expects_generated :model, "post title:string body:text -r=/tmp/sample_admin"
|
117
|
+
expects_rake "ar:create", :root => '/tmp/sample_admin'
|
118
|
+
expects_generated :admin, "-r=/tmp/sample_admin"
|
119
|
+
expects_rake "ar:migrate", :root => '/tmp/sample_admin'
|
120
|
+
expects_generated :admin_page, "post -r=/tmp/sample_admin"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -3,6 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/helper')
|
|
3
3
|
class TestProjectGenerator < Test::Unit::TestCase
|
4
4
|
def setup
|
5
5
|
`rm -rf /tmp/sample_project`
|
6
|
+
`rm -rf /tmp/project.com`
|
6
7
|
`rm -rf /tmp/warepedia`
|
7
8
|
end
|
8
9
|
|
@@ -15,7 +16,14 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
15
16
|
assert_file_exists('/tmp/sample_project/config/boot.rb')
|
16
17
|
assert_file_exists('/tmp/sample_project/public/favicon.ico')
|
17
18
|
end
|
18
|
-
|
19
|
+
|
20
|
+
should "generate a valid name" do
|
21
|
+
silence_logger { generate(:project, 'project.com', '--root=/tmp') }
|
22
|
+
assert_file_exists('/tmp/project.com')
|
23
|
+
assert_match_in_file(/class ProjectCom < Padrino::Application/,'/tmp/project.com/app/app.rb')
|
24
|
+
assert_match_in_file(/Padrino.mount\("ProjectCom"\).to\('\/'\)/,'/tmp/project.com/config/apps.rb')
|
25
|
+
end
|
26
|
+
|
19
27
|
should "allow specifying alternate application name" do
|
20
28
|
assert_nothing_raised { silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--app=base_app') } }
|
21
29
|
assert_file_exists('/tmp/sample_project')
|
@@ -79,12 +87,12 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
79
87
|
should "output to log components being applied" do
|
80
88
|
component_options = ['--orm=datamapper', '--test=riot', '--mock=mocha', '--script=prototype', '--renderer=erb','--stylesheet=less']
|
81
89
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', *component_options) }
|
82
|
-
assert_match
|
83
|
-
assert_match
|
84
|
-
assert_match
|
85
|
-
assert_match
|
86
|
-
assert_match
|
87
|
-
assert_match
|
90
|
+
assert_match(/Applying.*?datamapper.*?orm/, buffer)
|
91
|
+
assert_match(/Applying.*?riot.*?test/, buffer)
|
92
|
+
assert_match(/Applying.*?mocha.*?mock/, buffer)
|
93
|
+
assert_match(/Applying.*?prototype.*?script/, buffer)
|
94
|
+
assert_match(/Applying.*?erb.*?renderer/, buffer)
|
95
|
+
assert_match(/Applying.*?less.*?stylesheet/, buffer)
|
88
96
|
end
|
89
97
|
|
90
98
|
should "output gem files for base app" do
|
@@ -98,28 +106,28 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
98
106
|
context "a generator for mock component" do
|
99
107
|
should "properly generate for rr and riot" do
|
100
108
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--mock=rr', '--test=riot', '--script=none') }
|
101
|
-
assert_match
|
109
|
+
assert_match(/Applying.*?rr.*?mock/, buffer)
|
102
110
|
assert_match_in_file(/gem 'rr'/, '/tmp/sample_project/Gemfile')
|
103
111
|
assert_match_in_file(/require 'riot\/rr'/, '/tmp/sample_project/test/test_config.rb')
|
104
112
|
end
|
105
113
|
|
106
114
|
should "properly generater for rr and bacon" do
|
107
115
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--mock=rr', '--test=bacon', '--script=none') }
|
108
|
-
assert_match
|
116
|
+
assert_match(/Applying.*?rr.*?mock/, buffer)
|
109
117
|
assert_match_in_file(/gem 'rr'/, '/tmp/sample_project/Gemfile')
|
110
118
|
assert_match_in_file(/RR::Adapters::RRMethods/m, '/tmp/sample_project/test/test_config.rb')
|
111
119
|
end
|
112
120
|
|
113
121
|
should "properly generate for mocha and rspec" do
|
114
122
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp','--test=rspec', '--mock=mocha', '--script=none') }
|
115
|
-
assert_match
|
123
|
+
assert_match(/Applying.*?mocha.*?mock/, buffer)
|
116
124
|
assert_match_in_file(/gem 'mocha'/, '/tmp/sample_project/Gemfile')
|
117
125
|
assert_match_in_file(/conf.mock_with :mocha/m, '/tmp/sample_project/spec/spec_helper.rb')
|
118
126
|
end
|
119
127
|
|
120
128
|
should "properly generate for rr and rspec" do
|
121
129
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=rspec', '--mock=rr', '--script=none') }
|
122
|
-
assert_match
|
130
|
+
assert_match(/Applying.*?rr.*?mock/, buffer)
|
123
131
|
assert_match_in_file(/gem 'rr'/, '/tmp/sample_project/Gemfile')
|
124
132
|
assert_match_in_file(/conf.mock_with :rr/m, '/tmp/sample_project/spec/spec_helper.rb')
|
125
133
|
end
|
@@ -127,33 +135,34 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
127
135
|
end
|
128
136
|
|
129
137
|
context "the generator for orm components" do
|
130
|
-
|
138
|
+
|
131
139
|
context "for sequel" do
|
132
140
|
should "properly generate default" do
|
133
141
|
@app.instance_eval("undef setup_orm if respond_to?('setup_orm')")
|
134
|
-
buffer = silence_logger { generate(:project, '
|
135
|
-
assert_match
|
136
|
-
assert_match_in_file(/gem 'sequel'/, '/tmp/
|
137
|
-
assert_match_in_file(/gem 'sqlite3-ruby'/, '/tmp/
|
138
|
-
assert_match_in_file(/Sequel.connect/, '/tmp/
|
139
|
-
assert_match_in_file(%r{sqlite://}, '/tmp/
|
140
|
-
|
142
|
+
buffer = silence_logger { generate(:project, 'project.com', '--root=/tmp', '--orm=sequel', '--script=none') }
|
143
|
+
assert_match(/Applying.*?sequel.*?orm/, buffer)
|
144
|
+
assert_match_in_file(/gem 'sequel'/, '/tmp/project.com/Gemfile')
|
145
|
+
assert_match_in_file(/gem 'sqlite3-ruby'/, '/tmp/project.com/Gemfile')
|
146
|
+
assert_match_in_file(/Sequel.connect/, '/tmp/project.com/config/database.rb')
|
147
|
+
assert_match_in_file(%r{sqlite://}, '/tmp/project.com/config/database.rb')
|
148
|
+
assert_match_in_file(%r{project_com}, '/tmp/project.com/config/database.rb')
|
149
|
+
assert_dir_exists('/tmp/project.com/app/models')
|
141
150
|
end
|
142
|
-
|
151
|
+
|
143
152
|
should "properly generate mysql" do
|
144
153
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=sequel', '--adapter=mysql') }
|
145
154
|
assert_match_in_file(/gem 'mysql'/, '/tmp/sample_project/Gemfile')
|
146
155
|
assert_match_in_file(%r{"mysql://}, '/tmp/sample_project/config/database.rb')
|
147
156
|
assert_match_in_file(/sample_project_development/, '/tmp/sample_project/config/database.rb')
|
148
157
|
end
|
149
|
-
|
158
|
+
|
150
159
|
should "properly generate sqlite3" do
|
151
160
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=sequel', '--adapter=sqlite') }
|
152
161
|
assert_match_in_file(/gem 'sqlite3-ruby'/, '/tmp/sample_project/Gemfile')
|
153
162
|
assert_match_in_file(%r{sqlite://}, '/tmp/sample_project/config/database.rb')
|
154
163
|
assert_match_in_file(/sample_project_development/, '/tmp/sample_project/config/database.rb')
|
155
164
|
end
|
156
|
-
|
165
|
+
|
157
166
|
should "properly generate postgres" do
|
158
167
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=sequel', '--adapter=postgres') }
|
159
168
|
assert_match_in_file(/gem 'pg'/, '/tmp/sample_project/Gemfile')
|
@@ -164,28 +173,29 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
164
173
|
|
165
174
|
context "for activerecord" do
|
166
175
|
should "properly generate default" do
|
167
|
-
buffer = silence_logger { generate(:project, '
|
168
|
-
assert_match
|
169
|
-
assert_match_in_file(/gem 'activerecord', :require => "active_record"/, '/tmp/
|
170
|
-
assert_match_in_file(/gem 'sqlite3-ruby', :require => "sqlite3"/, '/tmp/
|
171
|
-
assert_match_in_file(/ActiveRecord::Base.establish_connection/, '/tmp/
|
172
|
-
|
176
|
+
buffer = silence_logger { generate(:project, 'project.com', '--root=/tmp', '--orm=activerecord', '--script=none') }
|
177
|
+
assert_match(/Applying.*?activerecord.*?orm/, buffer)
|
178
|
+
assert_match_in_file(/gem 'activerecord', :require => "active_record"/, '/tmp/project.com/Gemfile')
|
179
|
+
assert_match_in_file(/gem 'sqlite3-ruby', :require => "sqlite3"/, '/tmp/project.com/Gemfile')
|
180
|
+
assert_match_in_file(/ActiveRecord::Base.establish_connection/, '/tmp/project.com/config/database.rb')
|
181
|
+
assert_match_in_file(/project_com/, '/tmp/project.com/config/database.rb')
|
182
|
+
assert_dir_exists('/tmp/project.com/app/models')
|
173
183
|
end
|
174
|
-
|
184
|
+
|
175
185
|
should "properly generate mysql" do
|
176
186
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=activerecord','--adapter=mysql') }
|
177
187
|
assert_match_in_file(/gem 'mysql'/, '/tmp/sample_project/Gemfile')
|
178
188
|
assert_match_in_file(/sample_project_development/, '/tmp/sample_project/config/database.rb')
|
179
189
|
assert_match_in_file(%r{:adapter => 'mysql'}, '/tmp/sample_project/config/database.rb')
|
180
190
|
end
|
181
|
-
|
191
|
+
|
182
192
|
should "properly generate sqlite3" do
|
183
193
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=activerecord', '--adapter=sqlite3') }
|
184
194
|
assert_match_in_file(/gem 'sqlite3-ruby', :require => "sqlite3"/, '/tmp/sample_project/Gemfile')
|
185
195
|
assert_match_in_file(/sample_project_development.db/, '/tmp/sample_project/config/database.rb')
|
186
196
|
assert_match_in_file(%r{:adapter => 'sqlite3'}, '/tmp/sample_project/config/database.rb')
|
187
197
|
end
|
188
|
-
|
198
|
+
|
189
199
|
should "properly generate postgres" do
|
190
200
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=activerecord', '--adapter=postgres') }
|
191
201
|
assert_match_in_file(/gem 'pg', :require => "postgres"/, '/tmp/sample_project/Gemfile')
|
@@ -196,27 +206,28 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
196
206
|
|
197
207
|
context "for datamapper" do
|
198
208
|
should "properly generate default" do
|
199
|
-
buffer = silence_logger { generate(:project, '
|
200
|
-
assert_match
|
201
|
-
assert_match_in_file(/gem 'data_mapper'/, '/tmp/
|
202
|
-
assert_match_in_file(/gem 'dm-sqlite-adapter'/, '/tmp/
|
203
|
-
assert_match_in_file(/DataMapper.setup/, '/tmp/
|
204
|
-
|
209
|
+
buffer = silence_logger { generate(:project, 'project.com', '--root=/tmp', '--orm=datamapper', '--script=none') }
|
210
|
+
assert_match(/Applying.*?datamapper.*?orm/, buffer)
|
211
|
+
assert_match_in_file(/gem 'data_mapper'/, '/tmp/project.com/Gemfile')
|
212
|
+
assert_match_in_file(/gem 'dm-sqlite-adapter'/, '/tmp/project.com/Gemfile')
|
213
|
+
assert_match_in_file(/DataMapper.setup/, '/tmp/project.com/config/database.rb')
|
214
|
+
assert_match_in_file(/project_com/, '/tmp/project.com/config/database.rb')
|
215
|
+
assert_dir_exists('/tmp/project.com/app/models')
|
205
216
|
end
|
206
|
-
|
217
|
+
|
207
218
|
should "properly generate for mysql" do
|
208
219
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=datamapper', '--adapter=mysql') }
|
209
220
|
assert_match_in_file(/gem 'dm-mysql-adapter'/, '/tmp/sample_project/Gemfile')
|
210
221
|
assert_match_in_file(%r{"mysql://}, '/tmp/sample_project/config/database.rb')
|
211
222
|
assert_match_in_file(/sample_project_development/, '/tmp/sample_project/config/database.rb')
|
212
223
|
end
|
213
|
-
|
224
|
+
|
214
225
|
should "properly generate for sqlite" do
|
215
226
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=datamapper', '--adapter=sqlite') }
|
216
227
|
assert_match_in_file(/gem 'dm-sqlite-adapter'/, '/tmp/sample_project/Gemfile')
|
217
228
|
assert_match_in_file(/sample_project_development/, '/tmp/sample_project/config/database.rb')
|
218
229
|
end
|
219
|
-
|
230
|
+
|
220
231
|
should "properly generate for postgres" do
|
221
232
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=datamapper', '--adapter=postgres') }
|
222
233
|
assert_match_in_file(/gem 'dm-postgres-adapter'/, '/tmp/sample_project/Gemfile')
|
@@ -225,66 +236,101 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
225
236
|
end
|
226
237
|
end
|
227
238
|
|
228
|
-
|
229
239
|
should "properly generate for mongomapper" do
|
230
|
-
buffer = silence_logger { generate(:project, '
|
231
|
-
assert_match
|
232
|
-
assert_match_in_file(/gem 'mongo_mapper'/, '/tmp/
|
233
|
-
assert_match_in_file(/gem 'bson_ext'/, '/tmp/
|
234
|
-
assert_match_in_file(/MongoMapper.database/, '/tmp/
|
235
|
-
|
240
|
+
buffer = silence_logger { generate(:project, 'project.com', '--root=/tmp', '--orm=mongomapper', '--script=none') }
|
241
|
+
assert_match(/Applying.*?mongomapper.*?orm/, buffer)
|
242
|
+
assert_match_in_file(/gem 'mongo_mapper'/, '/tmp/project.com/Gemfile')
|
243
|
+
assert_match_in_file(/gem 'bson_ext'/, '/tmp/project.com/Gemfile')
|
244
|
+
assert_match_in_file(/MongoMapper.database/, '/tmp/project.com/config/database.rb')
|
245
|
+
assert_match_in_file(/project_com/, '/tmp/project.com/config/database.rb')
|
246
|
+
assert_dir_exists('/tmp/project.com/app/models')
|
236
247
|
end
|
237
248
|
|
238
249
|
should "properly generate for mongoid" do
|
239
|
-
buffer = silence_logger { generate(:project, '
|
240
|
-
assert_match
|
241
|
-
assert_match_in_file(/gem 'mongoid'/, '/tmp/
|
242
|
-
assert_match_in_file(/gem 'bson_ext'/, '/tmp/
|
243
|
-
assert_match_in_file(/Mongoid.database/, '/tmp/
|
244
|
-
|
250
|
+
buffer = silence_logger { generate(:project, 'project.com', '--root=/tmp', '--orm=mongoid', '--script=none') }
|
251
|
+
assert_match(/Applying.*?mongoid.*?orm/, buffer)
|
252
|
+
assert_match_in_file(/gem 'mongoid'/, '/tmp/project.com/Gemfile')
|
253
|
+
assert_match_in_file(/gem 'bson_ext'/, '/tmp/project.com/Gemfile')
|
254
|
+
assert_match_in_file(/Mongoid.database/, '/tmp/project.com/config/database.rb')
|
255
|
+
assert_match_in_file(/project_com/, '/tmp/project.com/config/database.rb')
|
256
|
+
assert_dir_exists('/tmp/project.com/app/models')
|
245
257
|
end
|
246
258
|
|
247
259
|
|
248
260
|
should "properly generate for couchrest" do
|
249
|
-
buffer = silence_logger { generate(:project, '
|
250
|
-
assert_match
|
251
|
-
assert_match_in_file(/gem 'couchrest'/, '/tmp/
|
252
|
-
assert_match_in_file(/CouchRest.database!/, '/tmp/
|
261
|
+
buffer = silence_logger { generate(:project, 'project.com', '--root=/tmp', '--orm=couchrest', '--script=none') }
|
262
|
+
assert_match(/Applying.*?couchrest.*?orm/, buffer)
|
263
|
+
assert_match_in_file(/gem 'couchrest'/, '/tmp/project.com/Gemfile')
|
264
|
+
assert_match_in_file(/CouchRest.database!/, '/tmp/project.com/config/database.rb')
|
265
|
+
assert_match_in_file(/project_com/, '/tmp/project.com/config/database.rb')
|
266
|
+
assert_dir_exists('/tmp/project.com/app/models')
|
267
|
+
end
|
268
|
+
|
269
|
+
should "properly generate for ohm" do
|
270
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=ohm', '--script=none') }
|
271
|
+
assert_match /Applying.*?ohm.*?orm/, buffer
|
272
|
+
assert_match_in_file(/gem 'json'/, '/tmp/sample_project/Gemfile')
|
273
|
+
assert_match_in_file(/gem 'ohm'/, '/tmp/sample_project/Gemfile')
|
274
|
+
assert_match_in_file(/gem 'ohm-contrib', :require => "ohm\/contrib"/, '/tmp/sample_project/Gemfile')
|
275
|
+
assert_match_in_file(/Ohm.connect/, '/tmp/sample_project/config/database.rb')
|
276
|
+
assert_dir_exists('/tmp/sample_project/app/models')
|
277
|
+
end
|
278
|
+
|
279
|
+
should "properly generate for mongomatic" do
|
280
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--orm=mongomatic', '--script=none') }
|
281
|
+
assert_match /Applying.*?mongomatic.*?orm/, buffer
|
282
|
+
assert_match_in_file(/gem 'bson_ext'/, '/tmp/sample_project/Gemfile')
|
283
|
+
assert_match_in_file(/gem 'mongomatic'/, '/tmp/sample_project/Gemfile')
|
284
|
+
assert_match_in_file(/Mongomatic.db = Mongo::Connection.new.db/, '/tmp/sample_project/config/database.rb')
|
253
285
|
assert_dir_exists('/tmp/sample_project/app/models')
|
254
286
|
end
|
255
287
|
end
|
256
288
|
|
289
|
+
|
257
290
|
context "the generator for renderer component" do
|
258
|
-
should "properly generate
|
291
|
+
should "properly generate for erb" do
|
259
292
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--renderer=erb', '--script=none') }
|
260
|
-
assert_match
|
293
|
+
assert_match(/Applying.*?erb.*?renderer/, buffer)
|
261
294
|
end
|
262
295
|
|
263
296
|
should "properly generate for haml" do
|
264
297
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--renderer=haml','--script=none') }
|
265
|
-
assert_match
|
298
|
+
assert_match(/Applying.*?haml.*?renderer/, buffer)
|
266
299
|
assert_match_in_file(/gem 'haml'/, '/tmp/sample_project/Gemfile')
|
267
300
|
end
|
301
|
+
|
302
|
+
should "properly generate for erubis" do
|
303
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--renderer=erubis','--script=none') }
|
304
|
+
assert_match(/Applying.*?erubis.*?renderer/,buffer)
|
305
|
+
assert_match_in_file(/gem 'erubis'/, '/tmp/sample_project/Gemfile')
|
306
|
+
end
|
307
|
+
|
308
|
+
should "properly generate for liquid" do
|
309
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--renderer=liquid','--script=none') }
|
310
|
+
assert_match(/Applying.*?liquid.*?renderer/,buffer)
|
311
|
+
assert_match_in_file(/gem 'liquid'/, '/tmp/sample_project/Gemfile')
|
312
|
+
end
|
313
|
+
|
268
314
|
end
|
269
315
|
|
270
316
|
context "the generator for script component" do
|
271
317
|
should "properly generate for jquery" do
|
272
318
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=jquery') }
|
273
|
-
assert_match
|
319
|
+
assert_match(/Applying.*?jquery.*?script/, buffer)
|
274
320
|
assert_file_exists('/tmp/sample_project/public/javascripts/jquery.js')
|
275
321
|
assert_file_exists('/tmp/sample_project/public/javascripts/application.js')
|
276
322
|
end
|
277
323
|
|
278
324
|
should "properly generate for mootools" do
|
279
325
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=mootools') }
|
280
|
-
assert_match
|
326
|
+
assert_match(/Applying.*?mootools.*?script/, buffer)
|
281
327
|
assert_file_exists('/tmp/sample_project/public/javascripts/mootools-core.js')
|
282
328
|
assert_file_exists('/tmp/sample_project/public/javascripts/application.js')
|
283
329
|
end
|
284
330
|
|
285
331
|
should "properly generate for prototype" do
|
286
332
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=prototype') }
|
287
|
-
assert_match
|
333
|
+
assert_match(/Applying.*?prototype.*?script/, buffer)
|
288
334
|
assert_file_exists('/tmp/sample_project/public/javascripts/protopak.js')
|
289
335
|
assert_file_exists('/tmp/sample_project/public/javascripts/lowpro.js')
|
290
336
|
assert_file_exists('/tmp/sample_project/public/javascripts/application.js')
|
@@ -292,30 +338,30 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
292
338
|
|
293
339
|
should "properly generate for rightjs" do
|
294
340
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=rightjs') }
|
295
|
-
assert_match
|
341
|
+
assert_match(/Applying.*?rightjs.*?script/, buffer)
|
296
342
|
assert_file_exists('/tmp/sample_project/public/javascripts/right.js')
|
297
343
|
assert_file_exists('/tmp/sample_project/public/javascripts/application.js')
|
298
344
|
end
|
299
345
|
|
300
346
|
should "properly generate for ext-core" do
|
301
347
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=extcore') }
|
302
|
-
assert_match
|
348
|
+
assert_match(/Applying.*?extcore.*?script/, buffer)
|
303
349
|
assert_file_exists('/tmp/sample_project/public/javascripts/ext-core.js')
|
304
350
|
assert_file_exists('/tmp/sample_project/public/javascripts/application.js')
|
305
351
|
end
|
306
|
-
|
352
|
+
|
307
353
|
should "properly generate for dojo" do
|
308
354
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--script=dojo') }
|
309
|
-
assert_match
|
355
|
+
assert_match(/Applying.*?dojo.*?script/, buffer)
|
310
356
|
assert_file_exists('/tmp/sample_project/public/javascripts/dojo.js')
|
311
357
|
assert_file_exists('/tmp/sample_project/public/javascripts/application.js')
|
312
358
|
end
|
313
359
|
end
|
314
360
|
|
315
361
|
context "the generator for test component" do
|
316
|
-
should "properly
|
362
|
+
should "properly generate for bacon" do
|
317
363
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=bacon', '--script=none') }
|
318
|
-
assert_match
|
364
|
+
assert_match(/Applying.*?bacon.*?test/, buffer)
|
319
365
|
assert_match_in_file(/gem 'rack-test'/, '/tmp/sample_project/Gemfile')
|
320
366
|
assert_match_in_file(/:require => "rack\/test"/, '/tmp/sample_project/Gemfile')
|
321
367
|
assert_match_in_file(/:group => "test"/, '/tmp/sample_project/Gemfile')
|
@@ -327,7 +373,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
327
373
|
|
328
374
|
should "properly generate for riot" do
|
329
375
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=riot', '--script=none') }
|
330
|
-
assert_match
|
376
|
+
assert_match(/Applying.*?riot.*?test/, buffer)
|
331
377
|
assert_match_in_file(/gem 'rack-test'/, '/tmp/sample_project/Gemfile')
|
332
378
|
assert_match_in_file(/:require => "rack\/test"/, '/tmp/sample_project/Gemfile')
|
333
379
|
assert_match_in_file(/:group => "test"/, '/tmp/sample_project/Gemfile')
|
@@ -336,12 +382,13 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
336
382
|
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_project/test/test_config.rb')
|
337
383
|
assert_match_in_file(/Riot::Situation/, '/tmp/sample_project/test/test_config.rb')
|
338
384
|
assert_match_in_file(/Riot::Context/, '/tmp/sample_project/test/test_config.rb')
|
385
|
+
assert_match_in_file(/SampleProject\.tap/, '/tmp/sample_project/test/test_config.rb')
|
339
386
|
assert_file_exists('/tmp/sample_project/test/test.rake')
|
340
387
|
end
|
341
388
|
|
342
389
|
should "properly generate for rspec" do
|
343
390
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=rspec', '--script=none') }
|
344
|
-
assert_match
|
391
|
+
assert_match(/Applying.*?rspec.*?test/, buffer)
|
345
392
|
assert_match_in_file(/gem 'rack-test'/, '/tmp/sample_project/Gemfile')
|
346
393
|
assert_match_in_file(/:require => "rack\/test"/, '/tmp/sample_project/Gemfile')
|
347
394
|
assert_match_in_file(/:group => "test"/, '/tmp/sample_project/Gemfile')
|
@@ -353,7 +400,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
353
400
|
|
354
401
|
should "properly generate for shoulda" do
|
355
402
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=shoulda', '--script=none') }
|
356
|
-
assert_match
|
403
|
+
assert_match(/Applying.*?shoulda.*?test/, buffer)
|
357
404
|
assert_match_in_file(/gem 'rack-test'/, '/tmp/sample_project/Gemfile')
|
358
405
|
assert_match_in_file(/:require => "rack\/test"/, '/tmp/sample_project/Gemfile')
|
359
406
|
assert_match_in_file(/:group => "test"/, '/tmp/sample_project/Gemfile')
|
@@ -365,7 +412,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
365
412
|
|
366
413
|
should "properly generate for testspec" do
|
367
414
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=testspec', '--script=none') }
|
368
|
-
assert_match
|
415
|
+
assert_match(/Applying.*?testspec.*?test/, buffer)
|
369
416
|
assert_match_in_file(/gem 'rack-test'/, '/tmp/sample_project/Gemfile')
|
370
417
|
assert_match_in_file(/:require => "rack\/test"/, '/tmp/sample_project/Gemfile')
|
371
418
|
assert_match_in_file(/:group => "test"/, '/tmp/sample_project/Gemfile')
|
@@ -377,7 +424,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
377
424
|
|
378
425
|
should "properly generate for cucumber" do
|
379
426
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--test=cucumber', '--script=none') }
|
380
|
-
assert_match
|
427
|
+
assert_match(/Applying.*?cucumber.*?test/, buffer)
|
381
428
|
assert_match_in_file(/gem 'rack-test'/, '/tmp/sample_project/Gemfile')
|
382
429
|
assert_match_in_file(/:require => "rack\/test"/, '/tmp/sample_project/Gemfile')
|
383
430
|
assert_match_in_file(/:group => "test"/, '/tmp/sample_project/Gemfile')
|
@@ -400,7 +447,7 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
400
447
|
should "properly generate for sass" do
|
401
448
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--renderer=haml','--script=none','--stylesheet=sass') }
|
402
449
|
assert_match_in_file(/gem 'haml'/, '/tmp/sample_project/Gemfile')
|
403
|
-
assert_match_in_file(/module SassInitializer.*Sass::Plugin::Rack/m, '/tmp/sample_project/lib/
|
450
|
+
assert_match_in_file(/module SassInitializer.*Sass::Plugin::Rack/m, '/tmp/sample_project/lib/sass_init.rb')
|
404
451
|
assert_match_in_file(/register SassInitializer/m, '/tmp/sample_project/app/app.rb')
|
405
452
|
assert_dir_exists('/tmp/sample_project/app/stylesheets')
|
406
453
|
end
|
@@ -409,11 +456,11 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
409
456
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--renderer=haml','--script=none','--stylesheet=less') }
|
410
457
|
assert_match_in_file(/gem 'less'/, '/tmp/sample_project/Gemfile')
|
411
458
|
assert_match_in_file(/gem 'rack-less'/, '/tmp/sample_project/Gemfile')
|
412
|
-
assert_match_in_file(/module LessInitializer.*Rack::Less/m, '/tmp/sample_project/lib/
|
459
|
+
assert_match_in_file(/module LessInitializer.*Rack::Less/m, '/tmp/sample_project/lib/less_init.rb')
|
413
460
|
assert_match_in_file(/register LessInitializer/m, '/tmp/sample_project/app/app.rb')
|
414
461
|
assert_dir_exists('/tmp/sample_project/app/stylesheets')
|
415
462
|
end
|
416
|
-
|
463
|
+
|
417
464
|
should "properly generate for compass" do
|
418
465
|
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--renderer=haml','--script=none','--stylesheet=compass') }
|
419
466
|
assert_match_in_file(/gem 'compass'/, '/tmp/sample_project/Gemfile')
|
@@ -424,5 +471,15 @@ class TestProjectGenerator < Test::Unit::TestCase
|
|
424
471
|
assert_file_exists('/tmp/sample_project/app/stylesheets/application.scss')
|
425
472
|
assert_file_exists('/tmp/sample_project/app/stylesheets/partials/_base.scss')
|
426
473
|
end
|
474
|
+
|
475
|
+
should "properly generate for scss" do
|
476
|
+
buffer = silence_logger { generate(:project, 'sample_project', '--root=/tmp', '--renderer=haml','--script=none','--stylesheet=scss') }
|
477
|
+
assert_match_in_file(/gem 'haml'/, '/tmp/sample_project/Gemfile')
|
478
|
+
assert_match_in_file(/module ScssInitializer.*Sass::Plugin::Rack/m, '/tmp/sample_project/lib/scss_init.rb')
|
479
|
+
assert_match_in_file(/Sass::Plugin.options\[:syntax\] = :scss/m, '/tmp/sample_project/lib/scss_init.rb')
|
480
|
+
assert_match_in_file(/register ScssInitializer/m, '/tmp/sample_project/app/app.rb')
|
481
|
+
assert_dir_exists('/tmp/sample_project/app/stylesheets')
|
482
|
+
end
|
483
|
+
|
427
484
|
end
|
428
485
|
end
|