padrino-gen 0.6.3 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/padrino-gen +2 -2
- data/lib/padrino-gen/generators/actions.rb +50 -30
- data/lib/padrino-gen/generators/app/Gemfile +1 -0
- data/lib/padrino-gen/generators/app/config/boot.rb +1 -1
- data/lib/padrino-gen/generators/app.rb +7 -6
- data/lib/padrino-gen/generators/components/actions.rb +55 -56
- data/lib/padrino-gen/generators/components/orms/activerecord_gen.rb +48 -31
- data/lib/padrino-gen/generators/components/orms/couchrest_gen.rb +7 -9
- data/lib/padrino-gen/generators/components/orms/datamapper_gen.rb +16 -12
- data/lib/padrino-gen/generators/components/orms/mongomapper_gen.rb +6 -20
- data/lib/padrino-gen/generators/components/orms/sequel_gen.rb +6 -9
- data/lib/padrino-gen/generators/components/renderers/haml_gen.rb +1 -2
- data/lib/padrino-gen/generators/components/scripts/jquery_gen.rb +2 -2
- data/lib/padrino-gen/generators/components/scripts/prototype_gen.rb +3 -3
- data/lib/padrino-gen/generators/components/scripts/rightjs_gen.rb +2 -4
- data/lib/padrino-gen/generators/components/tests/bacon_test_gen.rb +3 -3
- data/lib/padrino-gen/generators/components/tests/riot_test_gen.rb +3 -3
- data/lib/padrino-gen/generators/components/tests/rspec_test_gen.rb +3 -3
- data/lib/padrino-gen/generators/components/tests/shoulda_test_gen.rb +3 -3
- data/lib/padrino-gen/generators/components/tests/testspec_test_gen.rb +3 -3
- data/lib/padrino-gen/generators/controller.rb +9 -8
- data/lib/padrino-gen/generators/mailer.rb +6 -5
- data/lib/padrino-gen/generators/migration.rb +5 -5
- data/lib/padrino-gen/generators/model.rb +5 -5
- data/lib/padrino-gen/generators.rb +12 -8
- data/lib/padrino-gen/padrino-tasks/activerecord.rb +33 -32
- data/lib/padrino-gen.rb +3 -0
- data/padrino-gen.gemspec +5 -5
- data/test/helper.rb +1 -1
- data/test/test_app_generator.rb +38 -39
- data/test/test_controller_generator.rb +11 -11
- data/test/test_mailer_generator.rb +4 -4
- data/test/test_migration_generator.rb +21 -21
- data/test/test_model_generator.rb +29 -31
- metadata +3 -3
data/test/test_app_generator.rb
CHANGED
@@ -12,7 +12,7 @@ class TestAppGenerator < Test::Unit::TestCase
|
|
12
12
|
|
13
13
|
context 'the App generator' do
|
14
14
|
should "allow simple generator to run and create base_app with no options" do
|
15
|
-
assert_nothing_raised { silence_logger { @app.start(['sample_app', '
|
15
|
+
assert_nothing_raised { silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none']) } }
|
16
16
|
assert_file_exists('/tmp/sample_app')
|
17
17
|
assert_file_exists('/tmp/sample_app/app')
|
18
18
|
assert_file_exists('/tmp/sample_app/config/boot.rb')
|
@@ -21,23 +21,23 @@ class TestAppGenerator < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
should "not create models folder if no orm is chosen" do
|
24
|
-
silence_logger { @app.start(['sample_app', '
|
24
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '--orm=none']) }
|
25
25
|
assert_no_dir_exists('/tmp/sample_app/app/models')
|
26
26
|
end
|
27
27
|
|
28
28
|
should "not create tests folder if no test framework is chosen" do
|
29
|
-
silence_logger { @app.start(['sample_app', '
|
29
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '--test=none']) }
|
30
30
|
assert_no_dir_exists('/tmp/sample_app/test')
|
31
31
|
end
|
32
32
|
|
33
33
|
should "place app specific names into correct files" do
|
34
|
-
silence_logger { @app.start(['sample_app', '
|
34
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none']) }
|
35
35
|
assert_match_in_file(/class SampleApp < Padrino::Application/m, '/tmp/sample_app/app/app.rb')
|
36
36
|
assert_match_in_file(/Padrino.mount_core\("SampleApp"\)/m, '/tmp/sample_app/config/apps.rb')
|
37
37
|
end
|
38
38
|
|
39
39
|
should "create components file containing options chosen with defaults" do
|
40
|
-
silence_logger { @app.start(['sample_app', '
|
40
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp']) }
|
41
41
|
components_chosen = YAML.load_file('/tmp/sample_app/.components')
|
42
42
|
assert_equal 'datamapper', components_chosen[:orm]
|
43
43
|
assert_equal 'bacon', components_chosen[:test]
|
@@ -48,7 +48,7 @@ class TestAppGenerator < Test::Unit::TestCase
|
|
48
48
|
|
49
49
|
should "create components file containing options chosen" do
|
50
50
|
component_options = ['--orm=datamapper', '--test=riot', '--mock=mocha', '--script=prototype', '--renderer=erb']
|
51
|
-
silence_logger { @app.start(['sample_app', '
|
51
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', *component_options]) }
|
52
52
|
components_chosen = YAML.load_file('/tmp/sample_app/.components')
|
53
53
|
assert_equal 'datamapper', components_chosen[:orm]
|
54
54
|
assert_equal 'riot', components_chosen[:test]
|
@@ -59,7 +59,7 @@ class TestAppGenerator < Test::Unit::TestCase
|
|
59
59
|
|
60
60
|
should "output to log components being applied" do
|
61
61
|
component_options = ['--orm=datamapper', '--test=riot', '--mock=mocha', '--script=prototype', '--renderer=erb']
|
62
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
62
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', *component_options]) }
|
63
63
|
assert_match /Applying.*?datamapper.*?orm/, buffer
|
64
64
|
assert_match /Applying.*?riot.*?test/, buffer
|
65
65
|
assert_match /Applying.*?mocha.*?mock/, buffer
|
@@ -68,7 +68,7 @@ class TestAppGenerator < Test::Unit::TestCase
|
|
68
68
|
end
|
69
69
|
|
70
70
|
should "output gem files for base app" do
|
71
|
-
silence_logger { @app.start(['sample_app', '
|
71
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none']) }
|
72
72
|
assert_match_in_file(/gem 'sinatra'/, '/tmp/sample_app/Gemfile')
|
73
73
|
assert_match_in_file(/gem 'padrino'/, '/tmp/sample_app/Gemfile')
|
74
74
|
assert_match_in_file(/gem 'rack-flash'/, '/tmp/sample_app/Gemfile')
|
@@ -78,14 +78,14 @@ class TestAppGenerator < Test::Unit::TestCase
|
|
78
78
|
|
79
79
|
context "a generator for mock component" do
|
80
80
|
should "properly generate for rr" do
|
81
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
81
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--mock=rr', '--script=none']) }
|
82
82
|
assert_match /Applying.*?rr.*?mock/, buffer
|
83
83
|
assert_match_in_file(/gem 'rr'/, '/tmp/sample_app/Gemfile')
|
84
84
|
assert_match_in_file(/include RR::Adapters::RRMethods/m, '/tmp/sample_app/test/test_config.rb')
|
85
85
|
end
|
86
86
|
|
87
87
|
should "properly generate default for mocha" do
|
88
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
88
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--mock=mocha', '--script=none']) }
|
89
89
|
assert_match /Applying.*?mocha.*?mock/, buffer
|
90
90
|
assert_match_in_file(/gem 'mocha'/, '/tmp/sample_app/Gemfile')
|
91
91
|
assert_match_in_file(/include Mocha::API/m, '/tmp/sample_app/test/test_config.rb')
|
@@ -95,7 +95,7 @@ class TestAppGenerator < Test::Unit::TestCase
|
|
95
95
|
context "the generator for orm components" do
|
96
96
|
should "properly generate for sequel" do
|
97
97
|
@app.instance_eval("undef setup_orm if respond_to?('setup_orm')")
|
98
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
98
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--orm=sequel', '--script=none']) }
|
99
99
|
assert_match /Applying.*?sequel.*?orm/, buffer
|
100
100
|
assert_match_in_file(/gem 'sequel'/, '/tmp/sample_app/Gemfile')
|
101
101
|
assert_match_in_file(/Sequel.connect/, '/tmp/sample_app/config/database.rb')
|
@@ -103,16 +103,16 @@ class TestAppGenerator < Test::Unit::TestCase
|
|
103
103
|
end
|
104
104
|
|
105
105
|
should "properly generate for activerecord" do
|
106
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
106
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--orm=activerecord', '--script=none']) }
|
107
107
|
assert_match /Applying.*?activerecord.*?orm/, buffer
|
108
|
-
assert_match_in_file(/gem '
|
108
|
+
assert_match_in_file(/gem 'active_record'/, '/tmp/sample_app/Gemfile')
|
109
109
|
assert_match_in_file(/Migrate the database/, '/tmp/sample_app/Rakefile')
|
110
110
|
assert_match_in_file(/ActiveRecord::Base.establish_connection/, '/tmp/sample_app/config/database.rb')
|
111
111
|
assert_dir_exists('/tmp/sample_app/app/models')
|
112
112
|
end
|
113
113
|
|
114
114
|
should "properly generate default for datamapper" do
|
115
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
115
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--orm=datamapper', '--script=none']) }
|
116
116
|
assert_match /Applying.*?datamapper.*?orm/, buffer
|
117
117
|
assert_match_in_file(/gem 'dm-core'/, '/tmp/sample_app/Gemfile')
|
118
118
|
assert_match_in_file(/DataMapper.setup/, '/tmp/sample_app/config/database.rb')
|
@@ -120,7 +120,7 @@ class TestAppGenerator < Test::Unit::TestCase
|
|
120
120
|
end
|
121
121
|
|
122
122
|
should "properly generate for mongomapper" do
|
123
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
123
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--orm=mongomapper', '--script=none']) }
|
124
124
|
assert_match /Applying.*?mongomapper.*?orm/, buffer
|
125
125
|
assert_match_in_file(/gem 'mongo_mapper'/, '/tmp/sample_app/Gemfile')
|
126
126
|
assert_match_in_file(/MongoMapper.database/, '/tmp/sample_app/config/database.rb')
|
@@ -128,7 +128,7 @@ class TestAppGenerator < Test::Unit::TestCase
|
|
128
128
|
end
|
129
129
|
|
130
130
|
should "properly generate for couchrest" do
|
131
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
131
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--orm=couchrest', '--script=none']) }
|
132
132
|
assert_match /Applying.*?couchrest.*?orm/, buffer
|
133
133
|
assert_match_in_file(/gem 'couchrest'/, '/tmp/sample_app/Gemfile')
|
134
134
|
assert_match_in_file(/CouchRest.database!/, '/tmp/sample_app/config/database.rb')
|
@@ -138,82 +138,81 @@ class TestAppGenerator < Test::Unit::TestCase
|
|
138
138
|
|
139
139
|
context "the generator for renderer component" do
|
140
140
|
should "properly generate default for erb" do
|
141
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
141
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--renderer=erb', '--script=none']) }
|
142
142
|
assert_match /Applying.*?erb.*?renderer/, buffer
|
143
143
|
assert_match_in_file(/gem 'erubis'/, '/tmp/sample_app/Gemfile')
|
144
144
|
end
|
145
145
|
|
146
146
|
should "properly generate for haml" do
|
147
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
147
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--renderer=haml','--script=none']) }
|
148
148
|
assert_match /Applying.*?haml.*?renderer/, buffer
|
149
149
|
assert_match_in_file(/gem 'haml'/, '/tmp/sample_app/Gemfile')
|
150
150
|
assert_match_in_file(/module SassInitializer.*Sass::Plugin::Rack/m, '/tmp/sample_app/config/initializers/sass.rb')
|
151
|
-
assert_file_exists('/tmp/sample_app/public/stylesheets/sass')
|
152
151
|
end
|
153
152
|
end
|
154
153
|
|
155
154
|
context "the generator for script component" do
|
156
155
|
should "properly generate for jquery" do
|
157
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
156
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=jquery']) }
|
158
157
|
assert_match /Applying.*?jquery.*?script/, buffer
|
159
|
-
assert_file_exists('/tmp/sample_app/public/javascripts/jquery.js')
|
160
|
-
assert_file_exists('/tmp/sample_app/public/javascripts/application.js')
|
158
|
+
assert_file_exists('/tmp/sample_app/app/public/javascripts/jquery.js')
|
159
|
+
assert_file_exists('/tmp/sample_app/app/public/javascripts/application.js')
|
161
160
|
end
|
162
161
|
|
163
162
|
should "properly generate for prototype" do
|
164
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
163
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=prototype']) }
|
165
164
|
assert_match /Applying.*?prototype.*?script/, buffer
|
166
|
-
assert_file_exists('/tmp/sample_app/public/javascripts/protopak.js')
|
167
|
-
assert_file_exists('/tmp/sample_app/public/javascripts/lowpro.js')
|
168
|
-
assert_file_exists('/tmp/sample_app/public/javascripts/application.js')
|
165
|
+
assert_file_exists('/tmp/sample_app/app/public/javascripts/protopak.js')
|
166
|
+
assert_file_exists('/tmp/sample_app/app/public/javascripts/lowpro.js')
|
167
|
+
assert_file_exists('/tmp/sample_app/app/public/javascripts/application.js')
|
169
168
|
end
|
170
169
|
|
171
170
|
should "properly generate for rightjs" do
|
172
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
171
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=rightjs']) }
|
173
172
|
assert_match /Applying.*?rightjs.*?script/, buffer
|
174
|
-
assert_file_exists('/tmp/sample_app/public/javascripts/right.js')
|
175
|
-
assert_file_exists('/tmp/sample_app/public/javascripts/application.js')
|
173
|
+
assert_file_exists('/tmp/sample_app/app/public/javascripts/right.js')
|
174
|
+
assert_file_exists('/tmp/sample_app/app/public/javascripts/application.js')
|
176
175
|
end
|
177
176
|
end
|
178
177
|
|
179
178
|
context "the generator for test component" do
|
180
179
|
should "properly default generate for bacon" do
|
181
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
180
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--test=bacon', '--script=none']) }
|
182
181
|
assert_match /Applying.*?bacon.*?test/, buffer
|
183
182
|
assert_match_in_file(/gem 'bacon'/, '/tmp/sample_app/Gemfile')
|
184
|
-
assert_match_in_file(/
|
183
|
+
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_app/test/test_config.rb')
|
185
184
|
assert_match_in_file(/Bacon::Context/, '/tmp/sample_app/test/test_config.rb')
|
186
185
|
end
|
187
186
|
|
188
187
|
should "properly generate for riot" do
|
189
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
188
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--test=riot', '--script=none']) }
|
190
189
|
assert_match /Applying.*?riot.*?test/, buffer
|
191
190
|
assert_match_in_file(/gem 'riot'/, '/tmp/sample_app/Gemfile')
|
192
|
-
assert_match_in_file(/
|
191
|
+
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_app/test/test_config.rb')
|
193
192
|
assert_match_in_file(/Riot::Situation/, '/tmp/sample_app/test/test_config.rb')
|
194
193
|
end
|
195
194
|
|
196
195
|
should "properly generate for rspec" do
|
197
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
196
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--test=rspec', '--script=none']) }
|
198
197
|
assert_match /Applying.*?rspec.*?test/, buffer
|
199
198
|
assert_match_in_file(/gem 'rspec'.*?:require_as => "spec"/, '/tmp/sample_app/Gemfile')
|
200
|
-
assert_match_in_file(/
|
199
|
+
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_app/test/test_config.rb')
|
201
200
|
assert_match_in_file(/Spec::Runner/, '/tmp/sample_app/test/test_config.rb')
|
202
201
|
end
|
203
202
|
|
204
203
|
should "properly generate for shoulda" do
|
205
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
204
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--test=shoulda', '--script=none']) }
|
206
205
|
assert_match /Applying.*?shoulda.*?test/, buffer
|
207
206
|
assert_match_in_file(/gem 'shoulda'/, '/tmp/sample_app/Gemfile')
|
208
|
-
assert_match_in_file(/
|
207
|
+
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_app/test/test_config.rb')
|
209
208
|
assert_match_in_file(/Test::Unit::TestCase/, '/tmp/sample_app/test/test_config.rb')
|
210
209
|
end
|
211
210
|
|
212
211
|
should "properly generate for testspec" do
|
213
|
-
buffer = silence_logger { @app.start(['sample_app', '
|
212
|
+
buffer = silence_logger { @app.start(['sample_app', '--root=/tmp', '--test=testspec', '--script=none']) }
|
214
213
|
assert_match /Applying.*?testspec.*?test/, buffer
|
215
214
|
assert_match_in_file(/gem 'test\/spec'/, '/tmp/sample_app/Gemfile')
|
216
|
-
assert_match_in_file(/
|
215
|
+
assert_match_in_file(/PADRINO_ENV = 'test' unless defined\?\(PADRINO_ENV\)/, '/tmp/sample_app/test/test_config.rb')
|
217
216
|
assert_match_in_file(/Test::Unit::TestCase/, '/tmp/sample_app/test/test_config.rb')
|
218
217
|
end
|
219
218
|
end
|
@@ -20,7 +20,7 @@ class TestControllerGenerator < Test::Unit::TestCase
|
|
20
20
|
end
|
21
21
|
|
22
22
|
should "generate controller within existing application" do
|
23
|
-
silence_logger { @app.start(['sample_app', '
|
23
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon']) }
|
24
24
|
silence_logger { @contgen.start(['demo_items', '-r=/tmp/sample_app']) }
|
25
25
|
assert_match_in_file(/SampleApp.controllers do/m, @controller_path)
|
26
26
|
assert_match_in_file(/SampleApp.helpers do/m, '/tmp/sample_app/app/helpers/demo_items_helper.rb')
|
@@ -28,31 +28,31 @@ class TestControllerGenerator < Test::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
should "generate controller test for bacon" do
|
31
|
-
silence_logger { @app.start(['sample_app', '
|
31
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon']) }
|
32
32
|
silence_logger { @contgen.start(['demo_items', '-r=/tmp/sample_app']) }
|
33
33
|
assert_match_in_file(/describe "DemoItemsController" do/m, @controller_test_path)
|
34
34
|
end
|
35
35
|
|
36
36
|
should "generate controller test for riot" do
|
37
|
-
silence_logger { @app.start(['sample_app', '
|
37
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=riot']) }
|
38
38
|
silence_logger { @contgen.start(['demo_items', '-r=/tmp/sample_app']) }
|
39
39
|
assert_match_in_file(/context "DemoItemsController" do/m, @controller_test_path)
|
40
40
|
end
|
41
41
|
|
42
42
|
should "generate controller test for testspec" do
|
43
|
-
silence_logger { @app.start(['sample_app', '
|
43
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=testspec']) }
|
44
44
|
silence_logger { @contgen.start(['demo_items', '-r=/tmp/sample_app']) }
|
45
45
|
assert_match_in_file(/context "DemoItemsController" do/m, @controller_test_path)
|
46
46
|
end
|
47
47
|
|
48
48
|
should "generate controller test for rspec" do
|
49
|
-
silence_logger { @app.start(['sample_app', '
|
49
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=rspec']) }
|
50
50
|
silence_logger { @contgen.start(['demo_items', '-r=/tmp/sample_app']) }
|
51
51
|
assert_match_in_file(/describe "DemoItemsController" do/m, '/tmp/sample_app/test/controllers/demo_items_controller_spec.rb')
|
52
52
|
end
|
53
53
|
|
54
54
|
should "generate controller test for shoulda" do
|
55
|
-
silence_logger { @app.start(['sample_app', '
|
55
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=shoulda']) }
|
56
56
|
silence_logger { @contgen.start(['demo_items', '-r=/tmp/sample_app']) }
|
57
57
|
expected_pattern = /class DemoItemsControllerTest < Test::Unit::TestCase/m
|
58
58
|
assert_match_in_file(expected_pattern, @controller_test_path)
|
@@ -61,14 +61,14 @@ class TestControllerGenerator < Test::Unit::TestCase
|
|
61
61
|
# Controller action generation
|
62
62
|
|
63
63
|
should "generate actions for get:test post:yada" do
|
64
|
-
silence_logger { @app.start(['sample_app', '
|
64
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=shoulda'])}
|
65
65
|
silence_logger { @contgen.start(['demo_items', "get:test","post:yada",'-r=/tmp/sample_app']) }
|
66
66
|
assert_match_in_file(/get :test do\n end\n/m,@controller_path)
|
67
67
|
assert_match_in_file(/post :yada do\n end\n/m,@controller_path)
|
68
68
|
end
|
69
69
|
|
70
70
|
should "generate url routes for get:yoda post:yada" do
|
71
|
-
silence_logger { @app.start(['sample_app', '
|
71
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=shoulda'])}
|
72
72
|
silence_logger { @contgen.start(['demo_items', "get:yoda","post:yada",'-r=/tmp/sample_app']) }
|
73
73
|
# assert_match_in_file(/map\(\:yoda\).to\(\"\/demo_items\/yoda\"\)/m,@route_path)
|
74
74
|
# assert_match_in_file(/map\(\:yada\).to\(\"\/demo_items\/yada\"\)/m,@route_path)
|
@@ -79,7 +79,7 @@ class TestControllerGenerator < Test::Unit::TestCase
|
|
79
79
|
context "the controller destroy option" do
|
80
80
|
|
81
81
|
should "destroy controller files" do
|
82
|
-
silence_logger { @app.start(['sample_app', '
|
82
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon'])}
|
83
83
|
silence_logger { @contgen.start(['demo_items','-r=/tmp/sample_app']) }
|
84
84
|
silence_logger { @contgen.start(['demo_items','-r=/tmp/sample_app','-d'])}
|
85
85
|
assert_no_file_exists(@controller_path)
|
@@ -88,7 +88,7 @@ class TestControllerGenerator < Test::Unit::TestCase
|
|
88
88
|
end
|
89
89
|
|
90
90
|
should "destroy controller files with rspec" do
|
91
|
-
silence_logger { @app.start(['sample_app', '
|
91
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=rspec'])}
|
92
92
|
silence_logger { @contgen.start(['demo_items','-r=/tmp/sample_app']) }
|
93
93
|
silence_logger { @contgen.start(['demo_items','-r=/tmp/sample_app','-d'])}
|
94
94
|
assert_no_file_exists(@controller_path)
|
@@ -97,7 +97,7 @@ class TestControllerGenerator < Test::Unit::TestCase
|
|
97
97
|
end
|
98
98
|
|
99
99
|
should "remove url routes" do
|
100
|
-
silence_logger { @app.start(['sample_app', '
|
100
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon'])}
|
101
101
|
silence_logger { @contgen.start(['demo_items', "get:yoda","post:yada",'-r=/tmp/sample_app']) }
|
102
102
|
silence_logger { @contgen.start(['demo_items','-r=/tmp/sample_app','-d'])}
|
103
103
|
# assert_no_match_in_file(/map\(\:yoda\).to\(\"\/demo_items\/yoda\"\)/m,@route_path)
|
@@ -17,7 +17,7 @@ class TestMailerGenerator < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
should "support generating a new mailer extended from base" do
|
20
|
-
silence_logger { @app.start(['sample_app', '
|
20
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon']) }
|
21
21
|
silence_logger { @mailgen.start(['demo', '-r=/tmp/sample_app']) }
|
22
22
|
assert_match_in_file(/class DemoMailer < Padrino::Mailer::Base/m, '/tmp/sample_app/app/mailers/demo_mailer.rb')
|
23
23
|
assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_app/config/initializers/mailer.rb')
|
@@ -25,7 +25,7 @@ class TestMailerGenerator < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
should "support generating a new mailer extended from base with long name" do
|
28
|
-
silence_logger { @app.start(['sample_app', '
|
28
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon']) }
|
29
29
|
silence_logger { @mailgen.start(['user_notice', '-r=/tmp/sample_app']) }
|
30
30
|
assert_match_in_file(/class UserNoticeMailer/m, '/tmp/sample_app/app/mailers/user_notice_mailer.rb')
|
31
31
|
assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_app/config/initializers/mailer.rb')
|
@@ -33,7 +33,7 @@ class TestMailerGenerator < Test::Unit::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
should "support generating a new mailer extended from base with capitalized name" do
|
36
|
-
silence_logger { @app.start(['sample_app', '
|
36
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon']) }
|
37
37
|
silence_logger { @mailgen.start(['DEMO', '-r=/tmp/sample_app']) }
|
38
38
|
assert_match_in_file(/class DemoMailer < Padrino::Mailer::Base/m, '/tmp/sample_app/app/mailers/demo_mailer.rb')
|
39
39
|
assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_app/config/initializers/mailer.rb')
|
@@ -44,7 +44,7 @@ class TestMailerGenerator < Test::Unit::TestCase
|
|
44
44
|
context "the mailer destroy option" do
|
45
45
|
|
46
46
|
should "destroy mailer file" do
|
47
|
-
silence_logger { @app.start(['sample_app', '
|
47
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon']) }
|
48
48
|
silence_logger { @mailgen.start(['demo', '-r=/tmp/sample_app']) }
|
49
49
|
silence_logger { @mailgen.start(['demo', '-r=/tmp/sample_app','-d']) }
|
50
50
|
assert_no_dir_exists('/tmp/sample_app/app/views/demo_mailer')
|
@@ -17,30 +17,30 @@ class TestMigrationGenerator < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
should "generate migration inside app root" do
|
20
|
-
silence_logger { @app.start(['sample_app', '
|
20
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
|
21
21
|
response_success = silence_logger { @mig_gen.start(['AddEmailToUsers', '-r=/tmp/sample_app']) }
|
22
22
|
migration_file_path = "/tmp/sample_app/db/migrate/001_add_email_to_users.rb"
|
23
23
|
assert_match_in_file(/class AddEmailToUser/m, migration_file_path)
|
24
24
|
end
|
25
25
|
|
26
26
|
should "generate migration inside app root with lowercase migration argument" do
|
27
|
-
silence_logger { @app.start(['sample_app', '
|
27
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
|
28
28
|
response_success = silence_logger { @mig_gen.start(['add_email_to_users', '-r=/tmp/sample_app']) }
|
29
29
|
migration_file_path = "/tmp/sample_app/db/migrate/001_add_email_to_users.rb"
|
30
30
|
assert_match_in_file(/class AddEmailToUsers/m, migration_file_path)
|
31
31
|
end
|
32
32
|
|
33
33
|
should "generate migration inside app root with singular table" do
|
34
|
-
silence_logger { @app.start(['sample_app', '
|
34
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
|
35
35
|
silence_logger { @mig_gen.start(['add_email_to_user', "email:string", '-r=/tmp/sample_app']) }
|
36
36
|
migration_file_path = "/tmp/sample_app/db/migrate/001_add_email_to_user.rb"
|
37
37
|
assert_match_in_file(/class AddEmailToUser/m, migration_file_path)
|
38
|
-
assert_match_in_file(/t.
|
38
|
+
assert_match_in_file(/t.string :email/, migration_file_path)
|
39
39
|
assert_match_in_file(/t.remove :email/, migration_file_path)
|
40
40
|
end
|
41
41
|
|
42
42
|
should "properly calculate version number" do
|
43
|
-
silence_logger { @app.start(['sample_app', '
|
43
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
|
44
44
|
silence_logger { @mig_gen.start(['add_email_to_person', "email:string", '-r=/tmp/sample_app']) }
|
45
45
|
silence_logger { @mig_gen.start(['add_name_to_person', "email:string", '-r=/tmp/sample_app']) }
|
46
46
|
silence_logger { @mig_gen.start(['add_age_to_user', "email:string", '-r=/tmp/sample_app']) }
|
@@ -52,7 +52,7 @@ class TestMigrationGenerator < Test::Unit::TestCase
|
|
52
52
|
|
53
53
|
context 'the migration generator for activerecord' do
|
54
54
|
should "generate migration for generic needs" do
|
55
|
-
silence_logger { @app.start(['sample_app', '
|
55
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
|
56
56
|
response_success = silence_logger { @mig_gen.start(['ModifyUserFields', '-r=/tmp/sample_app']) }
|
57
57
|
migration_file_path = "/tmp/sample_app/db/migrate/001_modify_user_fields.rb"
|
58
58
|
assert_match_in_file(/class ModifyUserFields/m, migration_file_path)
|
@@ -61,33 +61,33 @@ class TestMigrationGenerator < Test::Unit::TestCase
|
|
61
61
|
end
|
62
62
|
|
63
63
|
should "generate migration for adding columns" do
|
64
|
-
silence_logger { @app.start(['sample_app', '
|
64
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
|
65
65
|
migration_params = ['AddEmailToUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
|
66
66
|
response_success = silence_logger { @mig_gen.start(migration_params) }
|
67
67
|
migration_file_path = "/tmp/sample_app/db/migrate/001_add_email_to_users.rb"
|
68
68
|
assert_match_in_file(/class AddEmailToUsers/m, migration_file_path)
|
69
|
-
assert_match_in_file(/change_table :users.*?t\.
|
70
|
-
assert_match_in_file(/t\.
|
69
|
+
assert_match_in_file(/change_table :users.*?t\.string :email/m, migration_file_path)
|
70
|
+
assert_match_in_file(/t\.integer :age/m, migration_file_path)
|
71
71
|
assert_match_in_file(/change_table :users.*?t\.remove :email/m, migration_file_path)
|
72
72
|
assert_match_in_file(/t\.remove :age/m, migration_file_path)
|
73
73
|
end
|
74
74
|
|
75
75
|
should "generate migration for removing columns" do
|
76
|
-
silence_logger { @app.start(['sample_app', '
|
76
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
|
77
77
|
migration_params = ['RemoveEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
|
78
78
|
response_success = silence_logger { @mig_gen.start(migration_params) }
|
79
79
|
migration_file_path = "/tmp/sample_app/db/migrate/001_remove_email_from_users.rb"
|
80
80
|
assert_match_in_file(/class RemoveEmailFromUsers/m, migration_file_path)
|
81
81
|
assert_match_in_file(/change_table :users.*?t\.remove :email/m, migration_file_path)
|
82
82
|
assert_match_in_file(/t\.remove :age/m, migration_file_path)
|
83
|
-
assert_match_in_file(/change_table :users.*?t\.
|
84
|
-
assert_match_in_file(/t\.
|
83
|
+
assert_match_in_file(/change_table :users.*?t\.string :email/m, migration_file_path)
|
84
|
+
assert_match_in_file(/t\.integer :age/m, migration_file_path)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
context 'the migration generator for datamapper' do
|
89
89
|
should "generate migration for generic needs" do
|
90
|
-
silence_logger { @app.start(['sample_app', '
|
90
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=datamapper']) }
|
91
91
|
response_success = silence_logger { @mig_gen.start(['ModifyUserFields', '-r=/tmp/sample_app']) }
|
92
92
|
migration_file_path = "/tmp/sample_app/db/migrate/001_modify_user_fields.rb"
|
93
93
|
assert_match_in_file(/migration\s1.*?:modify_user_fields/m, migration_file_path)
|
@@ -96,7 +96,7 @@ class TestMigrationGenerator < Test::Unit::TestCase
|
|
96
96
|
end
|
97
97
|
|
98
98
|
should "generate migration for adding columns" do
|
99
|
-
silence_logger { @app.start(['sample_app', '
|
99
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=datamapper']) }
|
100
100
|
migration_params = ['AddEmailToUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
|
101
101
|
response_success = silence_logger { @mig_gen.start(migration_params) }
|
102
102
|
migration_file_path = "/tmp/sample_app/db/migrate/001_add_email_to_users.rb"
|
@@ -108,7 +108,7 @@ class TestMigrationGenerator < Test::Unit::TestCase
|
|
108
108
|
end
|
109
109
|
|
110
110
|
should "generate migration for removing columns" do
|
111
|
-
silence_logger { @app.start(['sample_app', '
|
111
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=datamapper']) }
|
112
112
|
migration_params = ['RemoveEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
|
113
113
|
response_success = silence_logger { @mig_gen.start(migration_params) }
|
114
114
|
migration_file_path = "/tmp/sample_app/db/migrate/001_remove_email_from_users.rb"
|
@@ -120,7 +120,7 @@ class TestMigrationGenerator < Test::Unit::TestCase
|
|
120
120
|
end
|
121
121
|
|
122
122
|
should "properly version migration files" do
|
123
|
-
silence_logger { @app.start(['sample_app', '
|
123
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=datamapper']) }
|
124
124
|
response_success = silence_logger { @mig_gen.start(['ModifyUserFields', '-r=/tmp/sample_app']) }
|
125
125
|
response_success = silence_logger { @mig_gen.start(['ModifyUserFields2', '-r=/tmp/sample_app']) }
|
126
126
|
response_success = silence_logger { @mig_gen.start(['ModifyUserFields3', '-r=/tmp/sample_app']) }
|
@@ -132,7 +132,7 @@ class TestMigrationGenerator < Test::Unit::TestCase
|
|
132
132
|
|
133
133
|
context 'the migration generator for sequel' do
|
134
134
|
should "generate migration for generic needs" do
|
135
|
-
silence_logger { @app.start(['sample_app', '
|
135
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
|
136
136
|
response_success = silence_logger { @mig_gen.start(['ModifyUserFields', '-r=/tmp/sample_app']) }
|
137
137
|
migration_file_path = "/tmp/sample_app/db/migrate/001_modify_user_fields.rb"
|
138
138
|
assert_match_in_file(/class ModifyUserFields/m, migration_file_path)
|
@@ -141,7 +141,7 @@ class TestMigrationGenerator < Test::Unit::TestCase
|
|
141
141
|
end
|
142
142
|
|
143
143
|
should "generate migration for adding columns" do
|
144
|
-
silence_logger { @app.start(['sample_app', '
|
144
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
|
145
145
|
migration_params = ['AddEmailToUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
|
146
146
|
response_success = silence_logger { @mig_gen.start(migration_params) }
|
147
147
|
migration_file_path = "/tmp/sample_app/db/migrate/001_add_email_to_users.rb"
|
@@ -153,7 +153,7 @@ class TestMigrationGenerator < Test::Unit::TestCase
|
|
153
153
|
end
|
154
154
|
|
155
155
|
should "generate migration for removing columns" do
|
156
|
-
silence_logger { @app.start(['sample_app', '
|
156
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
|
157
157
|
migration_params = ['RemoveEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
|
158
158
|
response_success = silence_logger { @mig_gen.start(migration_params) }
|
159
159
|
migration_file_path = "/tmp/sample_app/db/migrate/001_remove_email_from_users.rb"
|
@@ -168,7 +168,7 @@ class TestMigrationGenerator < Test::Unit::TestCase
|
|
168
168
|
context "the migration destroy option" do
|
169
169
|
|
170
170
|
should "destroy the migration files" do
|
171
|
-
silence_logger { @app.start(['sample_app', '
|
171
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
|
172
172
|
migration_params = ['RemoveEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
|
173
173
|
silence_logger { @mig_gen.start(migration_params) }
|
174
174
|
silence_logger { @mig_gen.start(['RemoveEmailFromUsers', '-r=/tmp/sample_app','-d']) }
|
@@ -176,7 +176,7 @@ class TestMigrationGenerator < Test::Unit::TestCase
|
|
176
176
|
end
|
177
177
|
|
178
178
|
should "destroy the migration file regardless of number" do
|
179
|
-
silence_logger { @app.start(['sample_app', '
|
179
|
+
silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
|
180
180
|
migration_params = ['RemoveEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
|
181
181
|
migration_param2 = ['AddEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
|
182
182
|
silence_logger { @mig_gen.start(migration_param2) }
|