padrino-gen 0.10.2 → 0.10.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/.document +3 -3
  2. data/.yardopts +1 -0
  3. data/{LICENSE → LICENSE.txt} +0 -0
  4. data/README.rdoc +1 -1
  5. data/lib/padrino-gen/command.rb +7 -0
  6. data/lib/padrino-gen/generators/actions.rb +264 -24
  7. data/lib/padrino-gen/generators/app/app.rb.tt +11 -11
  8. data/lib/padrino-gen/generators/app.rb +10 -9
  9. data/lib/padrino-gen/generators/cli.rb +3 -0
  10. data/lib/padrino-gen/generators/components/actions.rb +86 -11
  11. data/lib/padrino-gen/generators/components/mocks/rr.rb +3 -1
  12. data/lib/padrino-gen/generators/components/orms/mongoid.rb +1 -1
  13. data/lib/padrino-gen/generators/components/orms/mongomapper.rb +1 -1
  14. data/lib/padrino-gen/generators/components/orms/mongomatic.rb +1 -1
  15. data/lib/padrino-gen/generators/components/stylesheets/less.rb +1 -1
  16. data/lib/padrino-gen/generators/components/tests/minitest.rb +78 -0
  17. data/lib/padrino-gen/generators/controller.rb +3 -0
  18. data/lib/padrino-gen/generators/mailer.rb +3 -0
  19. data/lib/padrino-gen/generators/model.rb +3 -0
  20. data/lib/padrino-gen/generators/plugin.rb +2 -0
  21. data/lib/padrino-gen/generators/project.rb +11 -3
  22. data/lib/padrino-gen/generators/runner.rb +85 -34
  23. data/lib/padrino-gen/generators/templates/Gemfile.tt +12 -21
  24. data/lib/padrino-gen/padrino-tasks/activerecord.rb +0 -194
  25. data/lib/padrino-gen.rb +21 -0
  26. data/test/helper.rb +2 -20
  27. data/test/test_app_generator.rb +17 -17
  28. data/test/test_cli.rb +6 -5
  29. data/test/test_controller_generator.rb +52 -44
  30. data/test/test_generator.rb +1 -1
  31. data/test/test_mailer_generator.rb +18 -18
  32. data/test/test_migration_generator.rb +44 -44
  33. data/test/test_model_generator.rb +140 -123
  34. data/test/test_plugin_generator.rb +21 -33
  35. data/test/test_project_generator.rb +125 -103
  36. metadata +10 -8
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/helper')
2
2
 
3
- class TestModelGenerator < Test::Unit::TestCase
3
+ describe "ModelGenerator" do
4
4
  def setup
5
5
  @apptmp = "#{Dir.tmpdir}/padrino-tests/#{UUID.new.generate}"
6
6
  `mkdir -p #{@apptmp}`
@@ -12,45 +12,45 @@ class TestModelGenerator < Test::Unit::TestCase
12
12
 
13
13
  context 'the model generator' do
14
14
  should "fail outside app root" do
15
- output = silence_logger { generate(:model, 'user', "-r=#{@apptmp}") }
16
- assert_match(/not at the root/, output)
15
+ out, err = capture_io { generate(:model, 'user', "-r=#{@apptmp}") }
16
+ assert_match(/not at the root/, out)
17
17
  assert_no_file_exists('/tmp/models/user.rb')
18
18
  end
19
19
 
20
20
  should "generate filename properly" do
21
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=couchrest') }
22
- silence_logger { generate(:model, 'DemoItem', "name:string", "age", "email:string", "-r=#{@apptmp}/sample_project") }
21
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=couchrest') }
22
+ capture_io { generate(:model, 'DemoItem', "name:string", "age", "email:string", "-r=#{@apptmp}/sample_project") }
23
23
  assert_file_exists("#{@apptmp}/sample_project/models/demo_item.rb")
24
24
  end
25
25
 
26
26
  should "fail if field name is not acceptable" do
27
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=couchrest') }
28
- output = silence_logger { generate(:model, 'DemoItem', "re@l$ly:string","display-name:string", "age&year:datetime", "email_two:string", "-r=#{@apptmp}/sample_project") }
29
- assert_match(/Invalid field name:/, output)
30
- assert_match(/display-name:string/, output)
31
- assert_match(/age&year:datetime/, output)
32
- assert_match(/re@l\$ly:string/, output)
33
- assert_no_match(/email_two:string/, output)
34
- assert_no_match(/apply/, output)
27
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=couchrest') }
28
+ out, err = capture_io { generate(:model, 'DemoItem', "re@l$ly:string","display-name:string", "age&year:datetime", "email_two:string", "-r=#{@apptmp}/sample_project") }
29
+ assert_match(/Invalid field name:/, out)
30
+ assert_match(/display-name:string/, out)
31
+ assert_match(/age&year:datetime/, out)
32
+ assert_match(/re@l\$ly:string/, out)
33
+ assert_no_match(/email_two:string/, out)
34
+ assert_no_match(/apply/, out)
35
35
  assert_no_file_exists("#{@apptmp}/sample_project/models/demo_item.rb")
36
36
  end
37
37
 
38
38
  should "fail if we don't use an adapter" do
39
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon') }
40
- assert_raise(SystemExit) { silence_logger { generate(:model, 'user', "-r=#{@apptmp}/sample_project") } }
39
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon') }
40
+ assert_raises(SystemExit) { capture_io { generate(:model, 'user', "-r=#{@apptmp}/sample_project") } }
41
41
  end
42
42
 
43
43
  should "not fail if we don't have test component" do
44
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=none', '-d=activerecord') }
45
- response_success = silence_logger { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
44
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=none', '-d=activerecord') }
45
+ response_success = capture_io { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
46
46
  assert_match_in_file(/class User < ActiveRecord::Base/m, "#{@apptmp}/sample_project/models/user.rb")
47
47
  assert_no_file_exists("#{@apptmp}/sample_project/test")
48
48
  end
49
49
 
50
50
  should "generate model in specified app" do
51
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=datamapper', '--script=none', '-t=bacon') }
52
- silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
53
- silence_logger { generate(:model, 'Post', "body:string", '-a=/subby', "-r=#{@apptmp}/sample_project") }
51
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=datamapper', '--script=none', '-t=bacon') }
52
+ capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
53
+ capture_io { generate(:model, 'Post', "body:string", '-a=/subby', "-r=#{@apptmp}/sample_project") }
54
54
  assert_match_in_file(/class Post\n\s+include DataMapper::Resource/m, "#{@apptmp}/sample_project/subby/models/post.rb")
55
55
  assert_match_in_file(/property :body, String/m, "#{@apptmp}/sample_project/subby/models/post.rb")
56
56
  assert_match_in_file(/migration 1, :create_posts do/m, "#{@apptmp}/sample_project/db/migrate/001_create_posts.rb")
@@ -59,19 +59,19 @@ class TestModelGenerator < Test::Unit::TestCase
59
59
  end
60
60
 
61
61
  should "generate only generate model once" do
62
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
63
- response_success = silence_logger { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
64
- response_duplicate = silence_logger { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
62
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
63
+ response_success = capture_io { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
64
+ out, err = capture_io { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
65
65
  assert_match_in_file(/class User < ActiveRecord::Base/m, "#{@apptmp}/sample_project/models/user.rb")
66
- assert_match "identical\e[0m models/user.rb", response_duplicate
67
- assert_match "identical\e[0m test/models/user_test.rb", response_duplicate
66
+ assert_match(/identical\e\[0m models\/user\.rb/, out)
67
+ assert_match(/identical\e\[0m test\/models\/user_test\.rb/, out)
68
68
  end
69
69
 
70
70
  should "generate migration file versions properly" do
71
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
72
- silence_logger { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
73
- silence_logger { generate(:model, 'account', "-r=#{@apptmp}/sample_project") }
74
- silence_logger { generate(:model, 'bank', "-r=#{@apptmp}/sample_project") }
71
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
72
+ capture_io { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
73
+ capture_io { generate(:model, 'account', "-r=#{@apptmp}/sample_project") }
74
+ capture_io { generate(:model, 'bank', "-r=#{@apptmp}/sample_project") }
75
75
  assert_file_exists("#{@apptmp}/sample_project/db/migrate/001_create_users.rb")
76
76
  assert_file_exists("#{@apptmp}/sample_project/db/migrate/002_create_accounts.rb")
77
77
  assert_file_exists("#{@apptmp}/sample_project/db/migrate/003_create_banks.rb")
@@ -81,22 +81,22 @@ class TestModelGenerator < Test::Unit::TestCase
81
81
  # ACTIVERECORD
82
82
  context "model generator using activerecord" do
83
83
  should "generate model file" do
84
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
85
- silence_logger { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
84
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
85
+ capture_io { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
86
86
  assert_match_in_file(/class User < ActiveRecord::Base/m, "#{@apptmp}/sample_project/models/user.rb")
87
87
  end
88
88
 
89
89
  should "generate model file with camelized name" do
90
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
91
- silence_logger { generate(:model, 'ChunkyBacon', "-r=#{@apptmp}/sample_project") }
90
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
91
+ capture_io { generate(:model, 'ChunkyBacon', "-r=#{@apptmp}/sample_project") }
92
92
  assert_match_in_file(/class ChunkyBacon < ActiveRecord::Base/m, "#{@apptmp}/sample_project/models/chunky_bacon.rb")
93
93
  assert_match_in_file(/ChunkyBacon Model/, "#{@apptmp}/sample_project/test/models/chunky_bacon_test.rb")
94
94
  end
95
95
 
96
96
  should "generate migration file with no fields" do
97
97
  current_time = stop_time_for_test.strftime("%Y%m%d%H%M%S")
98
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
99
- silence_logger { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
98
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
99
+ capture_io { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
100
100
  migration_file_path = "#{@apptmp}/sample_project/db/migrate/001_create_users.rb"
101
101
  assert_match_in_file(/class CreateUsers < ActiveRecord::Migration/m, migration_file_path)
102
102
  assert_match_in_file(/create_table :users/m, migration_file_path)
@@ -105,8 +105,8 @@ class TestModelGenerator < Test::Unit::TestCase
105
105
 
106
106
  should "generate migration file with given fields" do
107
107
  current_time = stop_time_for_test.strftime("%Y%m%d%H%M%S")
108
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
109
- silence_logger { generate(:model, 'person', "name:string", "age:integer", "email:string", "-r=#{@apptmp}/sample_project") }
108
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
109
+ capture_io { generate(:model, 'person', "name:string", "age:integer", "email:string", "-r=#{@apptmp}/sample_project") }
110
110
  migration_file_path = "#{@apptmp}/sample_project/db/migrate/001_create_people.rb"
111
111
  assert_match_in_file(/class CreatePeople < ActiveRecord::Migration/m, migration_file_path)
112
112
  assert_match_in_file(/create_table :people/m, migration_file_path)
@@ -120,15 +120,15 @@ class TestModelGenerator < Test::Unit::TestCase
120
120
  # COUCHREST
121
121
  context "model generator using couchrest" do
122
122
  should "generate model file with no properties" do
123
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=couchrest') }
124
- silence_logger { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
123
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=couchrest') }
124
+ capture_io { generate(:model, 'user', "-r=#{@apptmp}/sample_project") }
125
125
  assert_match_in_file(/class User < CouchRest::Model::Base/m, "#{@apptmp}/sample_project/models/user.rb")
126
126
  assert_match_in_file(/# property <name>[\s\n]+?end/m, "#{@apptmp}/sample_project/models/user.rb")
127
127
  end
128
128
 
129
129
  should "generate model file with given fields" do
130
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=couchrest') }
131
- silence_logger { generate(:model, 'person', "name:string", "age", "email:string", "-r=#{@apptmp}/sample_project") }
130
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=couchrest') }
131
+ capture_io { generate(:model, 'person', "name:string", "age", "email:string", "-r=#{@apptmp}/sample_project") }
132
132
  assert_match_in_file(/class Person < CouchRest::Model::Base/m, "#{@apptmp}/sample_project/models/person.rb")
133
133
  assert_match_in_file(/property :name/m, "#{@apptmp}/sample_project/models/person.rb")
134
134
  assert_match_in_file(/property :age/m, "#{@apptmp}/sample_project/models/person.rb")
@@ -140,21 +140,21 @@ class TestModelGenerator < Test::Unit::TestCase
140
140
  context "model generator using datamapper" do
141
141
 
142
142
  should "generate gemfile gem" do
143
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=datamapper') }
144
- silence_logger { generate(:model, 'user', "name:string", "age:integer", "created_at:datetime", "-r=#{@apptmp}/sample_project") }
143
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=datamapper') }
144
+ capture_io { generate(:model, 'user', "name:string", "age:integer", "created_at:datetime", "-r=#{@apptmp}/sample_project") }
145
145
  assert_match_in_file(/gem 'dm-core'/m,"#{@apptmp}/sample_project/Gemfile")
146
146
  end
147
147
 
148
148
  should "generate model file with camelized name" do
149
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=datamapper') }
150
- silence_logger { generate(:model, 'ChunkyBacon', "-r=#{@apptmp}/sample_project") }
149
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=datamapper') }
150
+ capture_io { generate(:model, 'ChunkyBacon', "-r=#{@apptmp}/sample_project") }
151
151
  assert_match_in_file(/class ChunkyBacon\n\s+include DataMapper::Resource/m, "#{@apptmp}/sample_project/models/chunky_bacon.rb")
152
152
  assert_match_in_file(/ChunkyBacon Model/, "#{@apptmp}/sample_project/test/models/chunky_bacon_test.rb")
153
153
  end
154
154
 
155
155
  should "generate model file with fields" do
156
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=datamapper') }
157
- silence_logger { generate(:model, 'user', "name:string", "age:integer", "created_at:datetime", "-r=#{@apptmp}/sample_project") }
156
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=datamapper') }
157
+ capture_io { generate(:model, 'user', "name:string", "age:integer", "created_at:datetime", "-r=#{@apptmp}/sample_project") }
158
158
  assert_match_in_file(/class User\n\s+include DataMapper::Resource/m, "#{@apptmp}/sample_project/models/user.rb")
159
159
  assert_match_in_file(/property :name, String/m, "#{@apptmp}/sample_project/models/user.rb")
160
160
  assert_match_in_file(/property :age, Integer/m, "#{@apptmp}/sample_project/models/user.rb")
@@ -162,10 +162,10 @@ class TestModelGenerator < Test::Unit::TestCase
162
162
  end
163
163
 
164
164
  should "properly generate version numbers" do
165
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=datamapper') }
166
- silence_logger { generate(:model, 'user', "name:string", "age:integer", "created_at:datetime", "-r=#{@apptmp}/sample_project") }
167
- silence_logger { generate(:model, 'person', "name:string", "age:integer", "created_at:datetime", "-r=#{@apptmp}/sample_project") }
168
- silence_logger { generate(:model, 'account', "name:string", "age:integer", "created_at:datetime", "-r=#{@apptmp}/sample_project") }
165
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=datamapper') }
166
+ capture_io { generate(:model, 'user', "name:string", "age:integer", "created_at:datetime", "-r=#{@apptmp}/sample_project") }
167
+ capture_io { generate(:model, 'person', "name:string", "age:integer", "created_at:datetime", "-r=#{@apptmp}/sample_project") }
168
+ capture_io { generate(:model, 'account', "name:string", "age:integer", "created_at:datetime", "-r=#{@apptmp}/sample_project") }
169
169
  assert_match_in_file(/class User\n\s+include DataMapper::Resource/m, "#{@apptmp}/sample_project/models/user.rb")
170
170
  assert_match_in_file(/migration 1, :create_users do/m, "#{@apptmp}/sample_project/db/migrate/001_create_users.rb")
171
171
  assert_match_in_file(/class Person\n\s+include DataMapper::Resource/m, "#{@apptmp}/sample_project/models/person.rb")
@@ -176,8 +176,8 @@ class TestModelGenerator < Test::Unit::TestCase
176
176
 
177
177
  should "generate migration with given fields" do
178
178
  current_time = stop_time_for_test.strftime("%Y%m%d%H%M%S")
179
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=datamapper') }
180
- silence_logger { generate(:model, 'person', "name:string", "created_at:date_time", "email:string", "-r=#{@apptmp}/sample_project") }
179
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=datamapper') }
180
+ capture_io { generate(:model, 'person', "name:string", "created_at:date_time", "email:string", "-r=#{@apptmp}/sample_project") }
181
181
  assert_match_in_file(/class Person\n\s+include DataMapper::Resource/m, "#{@apptmp}/sample_project/models/person.rb")
182
182
  migration_file_path = "#{@apptmp}/sample_project/db/migrate/001_create_people.rb"
183
183
  assert_match_in_file(/migration 1, :create_people do/m, migration_file_path)
@@ -192,22 +192,22 @@ class TestModelGenerator < Test::Unit::TestCase
192
192
  # SEQUEL
193
193
  context "model generator using sequel" do
194
194
  should "generate model file with given properties" do
195
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=sequel') }
196
- silence_logger { generate(:model, 'user', "name:string", "age:integer", "created:datetime", "-r=#{@apptmp}/sample_project") }
195
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=sequel') }
196
+ capture_io { generate(:model, 'user', "name:string", "age:integer", "created:datetime", "-r=#{@apptmp}/sample_project") }
197
197
  assert_match_in_file(/class User < Sequel::Model/m, "#{@apptmp}/sample_project/models/user.rb")
198
198
  end
199
199
 
200
200
  should "generate model file with camelized name" do
201
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=sequel') }
202
- silence_logger { generate(:model, 'ChunkyBacon', "-r=#{@apptmp}/sample_project") }
201
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=sequel') }
202
+ capture_io { generate(:model, 'ChunkyBacon', "-r=#{@apptmp}/sample_project") }
203
203
  assert_match_in_file(/class ChunkyBacon < Sequel::Model/m, "#{@apptmp}/sample_project/models/chunky_bacon.rb")
204
204
  assert_match_in_file(/ChunkyBacon Model/, "#{@apptmp}/sample_project/test/models/chunky_bacon_test.rb")
205
205
  end
206
206
 
207
207
  should "generate migration file with given properties" do
208
208
  current_time = stop_time_for_test.strftime("%Y%m%d%H%M%S")
209
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=sequel') }
210
- silence_logger { generate(:model, 'person', "name:string", "age:integer", "created:datetime", "-r=#{@apptmp}/sample_project") }
209
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=sequel') }
210
+ capture_io { generate(:model, 'person', "name:string", "age:integer", "created:datetime", "-r=#{@apptmp}/sample_project") }
211
211
  migration_file_path = "#{@apptmp}/sample_project/db/migrate/001_create_people.rb"
212
212
  assert_match_in_file(/class Person < Sequel::Model/m, "#{@apptmp}/sample_project/models/person.rb")
213
213
  assert_match_in_file(/class CreatePeople < Sequel::Migration/m, migration_file_path)
@@ -222,16 +222,16 @@ class TestModelGenerator < Test::Unit::TestCase
222
222
  # MONGODB
223
223
  context "model generator using mongomapper" do
224
224
  should "generate model file with no properties" do
225
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=mongomapper') }
226
- silence_logger { generate(:model, 'person', "-r=#{@apptmp}/sample_project") }
225
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=mongomapper') }
226
+ capture_io { generate(:model, 'person', "-r=#{@apptmp}/sample_project") }
227
227
  assert_match_in_file(/class Person\n\s+include MongoMapper::Document/m, "#{@apptmp}/sample_project/models/person.rb")
228
228
  assert_match_in_file(/# key <name>, <type>/m, "#{@apptmp}/sample_project/models/person.rb")
229
229
  assert_match_in_file(/timestamps![\n\s]+end/m, "#{@apptmp}/sample_project/models/person.rb")
230
230
  end
231
231
 
232
232
  should "generate model file with given fields" do
233
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=mongomapper') }
234
- silence_logger { generate(:model, 'user', "name:string", "age:integer", "email:string", "-r=#{@apptmp}/sample_project") }
233
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=mongomapper') }
234
+ capture_io { generate(:model, 'user', "name:string", "age:integer", "email:string", "-r=#{@apptmp}/sample_project") }
235
235
  assert_match_in_file(/class User\n\s+include MongoMapper::Document/m, "#{@apptmp}/sample_project/models/user.rb")
236
236
  assert_match_in_file(/key :name, String/m, "#{@apptmp}/sample_project/models/user.rb")
237
237
  assert_match_in_file(/key :age, Integer/m, "#{@apptmp}/sample_project/models/user.rb")
@@ -242,15 +242,15 @@ class TestModelGenerator < Test::Unit::TestCase
242
242
 
243
243
  context "model generator using mongoid" do
244
244
  should "generate model file with no properties" do
245
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=mongoid') }
246
- silence_logger { generate(:model, 'person', "-r=#{@apptmp}/sample_project") }
245
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=mongoid') }
246
+ capture_io { generate(:model, 'person', "-r=#{@apptmp}/sample_project") }
247
247
  assert_match_in_file(/class Person\n\s+include Mongoid::Document/m, "#{@apptmp}/sample_project/models/person.rb")
248
248
  assert_match_in_file(/# field <name>, :type => <type>, :default => <value>/m, "#{@apptmp}/sample_project/models/person.rb")
249
249
  end
250
250
 
251
251
  should "generate model file with given fields" do
252
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=mongoid') }
253
- silence_logger { generate(:model, 'user', "name:string", "age:integer", "email:string", "-r=#{@apptmp}/sample_project") }
252
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=mongoid') }
253
+ capture_io { generate(:model, 'user', "name:string", "age:integer", "email:string", "-r=#{@apptmp}/sample_project") }
254
254
  assert_match_in_file(/class User\n\s+include Mongoid::Document/m, "#{@apptmp}/sample_project/models/user.rb")
255
255
  assert_match_in_file(/field :name, :type => String/m, "#{@apptmp}/sample_project/models/user.rb")
256
256
  assert_match_in_file(/field :age, :type => Integer/m, "#{@apptmp}/sample_project/models/user.rb")
@@ -261,8 +261,8 @@ class TestModelGenerator < Test::Unit::TestCase
261
261
  # REDIS
262
262
  context "model generator using ohm" do
263
263
  should "generate model file with no properties" do
264
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=ohm') }
265
- silence_logger { generate(:model, 'person', "-r=#{@apptmp}/sample_project") }
264
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=ohm') }
265
+ capture_io { generate(:model, 'person', "-r=#{@apptmp}/sample_project") }
266
266
  assert_match_in_file(/class Person < Ohm::Model/, "#{@apptmp}/sample_project/models/person.rb")
267
267
  assert_match_in_file(/include Ohm::Timestamping/, "#{@apptmp}/sample_project/models/person.rb")
268
268
  assert_match_in_file(/include Ohm::Typecast/, "#{@apptmp}/sample_project/models/person.rb")
@@ -271,8 +271,8 @@ class TestModelGenerator < Test::Unit::TestCase
271
271
  end
272
272
 
273
273
  should "generate model file with given fields" do
274
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=ohm') }
275
- silence_logger { generate(:model, 'user', "name:string", "age:integer", "email:string", "-r=#{@apptmp}/sample_project") }
274
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=ohm') }
275
+ capture_io { generate(:model, 'user', "name:string", "age:integer", "email:string", "-r=#{@apptmp}/sample_project") }
276
276
  assert_match_in_file(/class User < Ohm::Model/, "#{@apptmp}/sample_project/models/user.rb")
277
277
  assert_match_in_file(/attribute :name, String/m, "#{@apptmp}/sample_project/models/user.rb")
278
278
  assert_match_in_file(/attribute :age, Integer/m, "#{@apptmp}/sample_project/models/user.rb")
@@ -283,15 +283,15 @@ class TestModelGenerator < Test::Unit::TestCase
283
283
  # MONGOMATIC
284
284
  context "model generator using mongomatic" do
285
285
  should "generate model file with no properties" do
286
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=mongomatic') }
287
- silence_logger { generate(:model, 'person', "-r=#{@apptmp}/sample_project") }
286
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=mongomatic') }
287
+ capture_io { generate(:model, 'person', "-r=#{@apptmp}/sample_project") }
288
288
  assert_match_in_file(/class Person < Mongomatic::Base/, "#{@apptmp}/sample_project/models/person.rb")
289
289
  assert_match_in_file(/include Mongomatic::Expectations::Helper/m, "#{@apptmp}/sample_project/models/person.rb")
290
290
  end
291
291
 
292
292
  should "generate model file with given fields" do
293
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=mongomatic') }
294
- silence_logger { generate(:model, 'user', "name:string", "age:integer", "email:string", "-r=#{@apptmp}/sample_project") }
293
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=mongomatic') }
294
+ capture_io { generate(:model, 'user', "name:string", "age:integer", "email:string", "-r=#{@apptmp}/sample_project") }
295
295
  assert_match_in_file(/class User < Mongomatic::Base/, "#{@apptmp}/sample_project/models/user.rb")
296
296
  assert_match_in_file(/include Mongomatic::Expectations::Helper/, "#{@apptmp}/sample_project/models/user.rb")
297
297
  assert_match_in_file(/be_present self\['name'\]/m, "#{@apptmp}/sample_project/models/user.rb")
@@ -304,8 +304,8 @@ class TestModelGenerator < Test::Unit::TestCase
304
304
  # RIPPLE
305
305
  context "model generator using ripple" do
306
306
  should "generate model file with no properties" do
307
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=ripple') }
308
- silence_logger { generate(:model, 'person', "name:string", "-r=#{@apptmp}/sample_project") }
307
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=ripple') }
308
+ capture_io { generate(:model, 'person', "name:string", "-r=#{@apptmp}/sample_project") }
309
309
  assert_match_in_file(/class Person\n\s+include Ripple::Document/m, "#{@apptmp}/sample_project/models/person.rb")
310
310
  assert_match_in_file(/# property :name, String/m, "#{@apptmp}/sample_project/models/person.rb")
311
311
  assert_match_in_file(/# many :addresses/m, "#{@apptmp}/sample_project/models/person.rb")
@@ -313,8 +313,8 @@ class TestModelGenerator < Test::Unit::TestCase
313
313
  end
314
314
 
315
315
  should "generate model file with given fields" do
316
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=ripple') }
317
- silence_logger { generate(:model, 'user', "name:string", "age:integer", "email:string", "-r=#{@apptmp}/sample_project") }
316
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-d=ripple') }
317
+ capture_io { generate(:model, 'user', "name:string", "age:integer", "email:string", "-r=#{@apptmp}/sample_project") }
318
318
  assert_match_in_file(/class User\n\s+include Ripple::Document/m, "#{@apptmp}/sample_project/models/user.rb")
319
319
  assert_match_in_file(/property :name, String/m, "#{@apptmp}/sample_project/models/user.rb")
320
320
  assert_match_in_file(/property :age, Integer/m, "#{@apptmp}/sample_project/models/user.rb")
@@ -325,9 +325,9 @@ class TestModelGenerator < Test::Unit::TestCase
325
325
  context "model generator testing files" do
326
326
  # BACON
327
327
  should "generate test file for bacon" do
328
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
329
- silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
330
- silence_logger { generate(:model, 'SomeUser', "-r=#{@apptmp}/sample_project") }
328
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
329
+ capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
330
+ capture_io { generate(:model, 'SomeUser', "-r=#{@apptmp}/sample_project") }
331
331
  assert_match_in_file(/describe "SomeUser Model"/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
332
332
  assert_match_in_file(/@some_user = SomeUser.new/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
333
333
  assert_match_in_file(/@some_user\.should\.not\.be\.nil/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
@@ -335,9 +335,9 @@ class TestModelGenerator < Test::Unit::TestCase
335
335
  end
336
336
 
337
337
  should "generate test file for bacon in specified app" do
338
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
339
- silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
340
- silence_logger { generate(:model, 'SomeUser', "-a=/subby", "-r=#{@apptmp}/sample_project") }
338
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
339
+ capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
340
+ capture_io { generate(:model, 'SomeUser', "-a=/subby", "-r=#{@apptmp}/sample_project") }
341
341
  assert_match_in_file(/describe "SomeUser Model"/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
342
342
  assert_match_in_file(/@some_user = SomeUser.new/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
343
343
  assert_match_in_file(/@some_user\.should\.not\.be\.nil/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
@@ -346,9 +346,9 @@ class TestModelGenerator < Test::Unit::TestCase
346
346
 
347
347
  # RIOT
348
348
  should "generate test file for riot" do
349
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=riot', '-d=activerecord') }
350
- silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
351
- silence_logger { generate(:model, 'SomeUser', "-r=#{@apptmp}/sample_project") }
349
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=riot', '-d=activerecord') }
350
+ capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
351
+ capture_io { generate(:model, 'SomeUser', "-r=#{@apptmp}/sample_project") }
352
352
  assert_match_in_file(/context "SomeUser Model" do/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
353
353
  assert_match_in_file(/SomeUser.new/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
354
354
  assert_match_in_file(/asserts\("that record is not nil"\) \{ \!topic.nil\? \}/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
@@ -356,29 +356,46 @@ class TestModelGenerator < Test::Unit::TestCase
356
356
  end
357
357
 
358
358
  should "generate test file for riot in specified app" do
359
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=riot', '-d=activerecord') }
360
- silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
361
- silence_logger { generate(:model, 'SomeUser', "-a=/subby", "-r=#{@apptmp}/sample_project") }
359
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=riot', '-d=activerecord') }
360
+ capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
361
+ capture_io { generate(:model, 'SomeUser', "-a=/subby", "-r=#{@apptmp}/sample_project") }
362
362
  assert_match_in_file(/context "SomeUser Model" do/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
363
363
  assert_match_in_file(/SomeUser.new/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
364
364
  assert_match_in_file(/asserts\("that record is not nil"\) \{ \!topic.nil\? \}/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
365
365
  assert_match_in_file(/'(\/\.\.){2}\/test/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
366
366
  end
367
367
 
368
+ # MINITEST
369
+ should "generate test file for minitest" do
370
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=minitest', '-d=activerecord') }
371
+ capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
372
+ capture_io { generate(:model, 'SomeUser', "-r=#{@apptmp}/sample_project") }
373
+ assert_match_in_file(/describe "SomeUser Model"/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
374
+ assert_match_in_file(/refute_nil @some_user/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
375
+ end
376
+
377
+ should "generate test file for minitest in specified app" do
378
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=minitest', '-d=activerecord') }
379
+ capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
380
+ capture_io { generate(:model, 'SomeUser', "-a=/subby", "-r=#{@apptmp}/sample_project") }
381
+ assert_match_in_file(/describe "SomeUser Model"/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
382
+ assert_match_in_file(/refute_nil @some_user/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
383
+ end
384
+
368
385
  # RSPEC
369
386
  should "generate test file for rspec" do
370
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec', '-d=activerecord') }
371
- silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
372
- silence_logger { generate(:model, 'SomeUser', "-r=#{@apptmp}/sample_project") }
387
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec', '-d=activerecord') }
388
+ capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
389
+ capture_io { generate(:model, 'SomeUser', "-r=#{@apptmp}/sample_project") }
373
390
  assert_match_in_file(/describe "SomeUser Model"/m, "#{@apptmp}/sample_project/spec/models/some_user_spec.rb")
374
391
  assert_match_in_file(/let\(:some_user\) \{ SomeUser.new \}/m, "#{@apptmp}/sample_project/spec/models/some_user_spec.rb")
375
392
  assert_match_in_file(/some_user\.should_not be_nil/m, "#{@apptmp}/sample_project/spec/models/some_user_spec.rb")
376
393
  end
377
394
 
378
395
  should "generate test file for rspec in specified app" do
379
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec', '-d=activerecord') }
380
- silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
381
- silence_logger { generate(:model, 'SomeUser', "-a=/subby", "-r=#{@apptmp}/sample_project") }
396
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec', '-d=activerecord') }
397
+ capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
398
+ capture_io { generate(:model, 'SomeUser', "-a=/subby", "-r=#{@apptmp}/sample_project") }
382
399
  assert_match_in_file(/describe "SomeUser Model"/m, "#{@apptmp}/sample_project/spec/subby/models/some_user_spec.rb")
383
400
  assert_match_in_file(/let\(:some_user\) \{ SomeUser.new \}/m, "#{@apptmp}/sample_project/spec/subby/models/some_user_spec.rb")
384
401
  assert_match_in_file(/some_user\.should_not be_nil/m, "#{@apptmp}/sample_project/spec/subby/models/some_user_spec.rb")
@@ -386,9 +403,9 @@ class TestModelGenerator < Test::Unit::TestCase
386
403
 
387
404
  # SHOULDA
388
405
  should "generate test file for shoulda" do
389
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=shoulda', '-d=activerecord') }
390
- silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
391
- silence_logger { generate(:model, 'SomePerson', "-r=#{@apptmp}/sample_project") }
406
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=shoulda', '-d=activerecord') }
407
+ capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
408
+ capture_io { generate(:model, 'SomePerson', "-r=#{@apptmp}/sample_project") }
392
409
  assert_match_in_file(/class SomePersonTest < Test::Unit::TestCase/m, "#{@apptmp}/sample_project/test/models/some_person_test.rb")
393
410
  assert_match_in_file(/context "SomePerson Model"/m, "#{@apptmp}/sample_project/test/models/some_person_test.rb")
394
411
  assert_match_in_file(/@some_person = SomePerson.new/m, "#{@apptmp}/sample_project/test/models/some_person_test.rb")
@@ -397,9 +414,9 @@ class TestModelGenerator < Test::Unit::TestCase
397
414
  end
398
415
 
399
416
  should "generate test file for shoulda in specified app" do
400
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=shoulda', '-d=activerecord') }
401
- silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
402
- silence_logger { generate(:model, 'SomePerson', "-a=/subby", "-r=#{@apptmp}/sample_project") }
417
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=shoulda', '-d=activerecord') }
418
+ capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
419
+ capture_io { generate(:model, 'SomePerson', "-a=/subby", "-r=#{@apptmp}/sample_project") }
403
420
  assert_match_in_file(/class SomePersonTest < Test::Unit::TestCase/m, "#{@apptmp}/sample_project/test/subby/models/some_person_test.rb")
404
421
  assert_match_in_file(/context "SomePerson Model"/m, "#{@apptmp}/sample_project/test/subby/models/some_person_test.rb")
405
422
  assert_match_in_file(/@some_person = SomePerson.new/m, "#{@apptmp}/sample_project/test/subby/models/some_person_test.rb")
@@ -409,9 +426,9 @@ class TestModelGenerator < Test::Unit::TestCase
409
426
 
410
427
  # TESTSPEC
411
428
  should "generate test file for testspec" do
412
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=testspec', '-d=activerecord') }
413
- silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
414
- silence_logger { generate(:model, 'SomeUser', "-r=#{@apptmp}/sample_project") }
429
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=testspec', '-d=activerecord') }
430
+ capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
431
+ capture_io { generate(:model, 'SomeUser', "-r=#{@apptmp}/sample_project") }
415
432
  assert_match_in_file(/context "SomeUser Model"/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
416
433
  assert_match_in_file(/@some_user = SomeUser.new/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
417
434
  assert_match_in_file(/@some_user\.should\.not\.be\.nil/m, "#{@apptmp}/sample_project/test/models/some_user_test.rb")
@@ -419,9 +436,9 @@ class TestModelGenerator < Test::Unit::TestCase
419
436
  end
420
437
 
421
438
  should "generate test file for testspec in specified app" do
422
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=testspec', '-d=activerecord') }
423
- silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
424
- silence_logger { generate(:model, 'SomeUser', "-a=/subby", "-r=#{@apptmp}/sample_project") }
439
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=testspec', '-d=activerecord') }
440
+ capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
441
+ capture_io { generate(:model, 'SomeUser', "-a=/subby", "-r=#{@apptmp}/sample_project") }
425
442
  assert_match_in_file(/context "SomeUser Model"/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
426
443
  assert_match_in_file(/@some_user = SomeUser.new/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
427
444
  assert_match_in_file(/@some_user\.should\.not\.be\.nil/m, "#{@apptmp}/sample_project/test/subby/models/some_user_test.rb")
@@ -432,36 +449,36 @@ class TestModelGenerator < Test::Unit::TestCase
432
449
  context "the model destroy option" do
433
450
 
434
451
  should "destroy the model file" do
435
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
436
- silence_logger { generate(:model, 'User', "-r=#{@apptmp}/sample_project") }
437
- silence_logger { generate(:model, 'User', "-r=#{@apptmp}/sample_project", '-d') }
452
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
453
+ capture_io { generate(:model, 'User', "-r=#{@apptmp}/sample_project") }
454
+ capture_io { generate(:model, 'User', "-r=#{@apptmp}/sample_project", '-d') }
438
455
  assert_no_file_exists("#{@apptmp}/sample_project/models/user.rb")
439
456
  assert_no_file_exists("#{@apptmp}/sample_project/test/models/user_test.rb")
440
457
  assert_no_file_exists("#{@apptmp}/sample_project/db/migrate/001_create_users.rb")
441
458
  end
442
459
 
443
460
  should "destroy the model test file with rspec" do
444
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec', '-d=activerecord') }
445
- silence_logger { generate(:model, 'User', "-r=#{@apptmp}/sample_project") }
446
- silence_logger { generate(:model, 'User', "-r=#{@apptmp}/sample_project", '-d') }
461
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec', '-d=activerecord') }
462
+ capture_io { generate(:model, 'User', "-r=#{@apptmp}/sample_project") }
463
+ capture_io { generate(:model, 'User', "-r=#{@apptmp}/sample_project", '-d') }
447
464
  assert_no_file_exists("#{@apptmp}/sample_project/spec/models/user_spec.rb")
448
465
  end
449
466
 
450
467
  should "destroy the model test file in a sub app" do
451
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
452
- silence_logger { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
453
- silence_logger { generate(:model, 'User', "-a=/subby","-r=#{@apptmp}/sample_project") }
454
- silence_logger { generate(:model, 'User', "-a=/subby","-r=#{@apptmp}/sample_project", '-d') }
468
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=bacon', '-d=activerecord') }
469
+ capture_io { generate(:app, 'subby', "-r=#{@apptmp}/sample_project") }
470
+ capture_io { generate(:model, 'User', "-a=/subby","-r=#{@apptmp}/sample_project") }
471
+ capture_io { generate(:model, 'User', "-a=/subby","-r=#{@apptmp}/sample_project", '-d') }
455
472
  assert_no_file_exists("#{@apptmp}/sample_project/subby/models/user.rb")
456
473
  assert_no_file_exists("#{@apptmp}/sample_project/test/subby/models/user_test.rb")
457
474
  assert_no_file_exists("#{@apptmp}/sample_project/db/migrate/001_create_users.rb")
458
475
  end
459
476
 
460
477
  should "destroy the right model migration" do
461
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec', '-d=activerecord') }
462
- silence_logger { generate(:model, 'bar_foo', "-r=#{@apptmp}/sample_project") }
463
- silence_logger { generate(:model, 'foo', "-r=#{@apptmp}/sample_project") }
464
- silence_logger { generate(:model, 'foo', "-r=#{@apptmp}/sample_project", '-d') }
478
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=none', '-t=rspec', '-d=activerecord') }
479
+ capture_io { generate(:model, 'bar_foo', "-r=#{@apptmp}/sample_project") }
480
+ capture_io { generate(:model, 'foo', "-r=#{@apptmp}/sample_project") }
481
+ capture_io { generate(:model, 'foo', "-r=#{@apptmp}/sample_project", '-d') }
465
482
  assert_no_file_exists("#{@apptmp}/sample_project/db/migrate/002_create_foos.rb")
466
483
  assert_file_exists("#{@apptmp}/sample_project/db/migrate/001_create_bar_foos.rb")
467
484
  end