padrino-gen 0.7.9 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/README.rdoc +42 -13
  2. data/Rakefile +7 -6
  3. data/VERSION +1 -1
  4. data/lib/padrino-gen/generators/actions.rb +25 -3
  5. data/lib/padrino-gen/generators/app/{app/app.rb.tt → app.rb.tt} +0 -0
  6. data/lib/padrino-gen/generators/app/{app → controllers}/.empty_directory +0 -0
  7. data/lib/padrino-gen/generators/app/{app/controllers → helpers}/.empty_directory +0 -0
  8. data/lib/padrino-gen/generators/app/{app/helpers → views}/.empty_directory +0 -0
  9. data/lib/padrino-gen/generators/app.rb +28 -36
  10. data/lib/padrino-gen/generators/components/actions.rb +4 -22
  11. data/lib/padrino-gen/generators/components/mocks/rr_gen.rb +8 -4
  12. data/lib/padrino-gen/generators/controller.rb +7 -4
  13. data/lib/padrino-gen/generators/mailer.rb +5 -2
  14. data/lib/padrino-gen/generators/model.rb +1 -1
  15. data/lib/padrino-gen/generators/{app → project}/.gitignore +0 -0
  16. data/lib/padrino-gen/generators/{app/app/views → project/app}/.empty_directory +0 -0
  17. data/lib/padrino-gen/generators/project/app/app.rb.tt +37 -0
  18. data/lib/padrino-gen/generators/{app/config/initializers → project/app/controllers}/.empty_directory +0 -0
  19. data/lib/padrino-gen/generators/{app/public/images → project/app/helpers}/.empty_directory +0 -0
  20. data/lib/padrino-gen/generators/{app/public/javascripts → project/app/views}/.empty_directory +0 -0
  21. data/lib/padrino-gen/generators/{app → project}/config/apps.rb.tt +0 -0
  22. data/lib/padrino-gen/generators/{app → project}/config/boot.rb +1 -1
  23. data/lib/padrino-gen/generators/{app/public/stylesheets → project/config/initializers}/.empty_directory +0 -0
  24. data/lib/padrino-gen/generators/{app → project}/config/initializers/example.rb +0 -0
  25. data/lib/padrino-gen/generators/{app → project}/config.ru +0 -0
  26. data/lib/padrino-gen/generators/{app/tmp → project/public/images}/.empty_directory +0 -0
  27. data/lib/padrino-gen/generators/project/public/javascripts/.empty_directory +0 -0
  28. data/lib/padrino-gen/generators/project/public/stylesheets/.empty_directory +0 -0
  29. data/lib/padrino-gen/generators/project/tmp/.empty_directory +0 -0
  30. data/lib/padrino-gen/generators/project.rb +64 -0
  31. data/lib/padrino-gen/generators/templates/Gemfile.tt +0 -1
  32. data/lib/padrino-gen/generators.rb +7 -3
  33. data/lib/padrino-gen/padrino-tasks/activerecord.rb +1 -1
  34. data/padrino-gen.gemspec +31 -24
  35. data/test/helper.rb +7 -7
  36. data/test/test_app_generator.rb +35 -199
  37. data/test/test_cli.rb +25 -0
  38. data/test/test_controller_generator.rb +45 -45
  39. data/test/test_generator.rb +0 -3
  40. data/test/test_mailer_generator.rb +25 -26
  41. data/test/test_migration_generator.rb +61 -62
  42. data/test/test_model_generator.rb +119 -114
  43. data/test/test_project_generator.rb +222 -0
  44. metadata +26 -19
@@ -3,53 +3,52 @@ require 'thor/group'
3
3
 
4
4
  class TestMailerGenerator < Test::Unit::TestCase
5
5
  def setup
6
- Padrino::Generators.lockup!
7
- @app = Padrino::Generators::App.dup
8
- @mailgen = Padrino::Generators::Mailer.dup
9
- `rm -rf /tmp/sample_app`
6
+ @project = Padrino::Generators::Project.dup
7
+ @mail_gen = Padrino::Generators::Mailer.dup
8
+ `rm -rf /tmp/sample_project`
10
9
  end
11
10
 
12
11
  context 'the mailer generator' do
13
12
  should "fail outside app root" do
14
- output = silence_logger { @mailgen.start(['demo', '-r=/tmp']) }
13
+ output = silence_logger { @mail_gen.start(['demo', '-r=/tmp']) }
15
14
  assert_match(/not at the root/, output)
16
15
  assert_no_file_exists('/tmp/app/mailers/demo_mailer.rb')
17
16
  end
18
17
 
19
18
  should "support generating a new mailer extended from base" do
20
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon']) }
21
- silence_logger { @mailgen.start(['demo', '-r=/tmp/sample_app']) }
22
- assert_match_in_file(/class DemoMailer < Padrino::Mailer::Base/m, '/tmp/sample_app/app/mailers/demo_mailer.rb')
23
- assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_app/config/initializers/mailer.rb')
24
- assert_file_exists('/tmp/sample_app/app/views/demo_mailer')
19
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon']) }
20
+ silence_logger { @mail_gen.start(['demo', '-r=/tmp/sample_project']) }
21
+ assert_match_in_file(/class DemoMailer < Padrino::Mailer::Base/m, '/tmp/sample_project/app/mailers/demo_mailer.rb')
22
+ assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_project/config/initializers/mailer.rb')
23
+ assert_file_exists('/tmp/sample_project/app/views/demo_mailer')
25
24
  end
26
25
 
27
26
  should "support generating a new mailer extended from base with long name" do
28
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon']) }
29
- silence_logger { @mailgen.start(['user_notice', '-r=/tmp/sample_app']) }
30
- assert_match_in_file(/class UserNoticeMailer/m, '/tmp/sample_app/app/mailers/user_notice_mailer.rb')
31
- assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_app/config/initializers/mailer.rb')
32
- assert_file_exists('/tmp/sample_app/app/views/user_notice_mailer')
27
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon']) }
28
+ silence_logger { @mail_gen.start(['user_notice', '-r=/tmp/sample_project']) }
29
+ assert_match_in_file(/class UserNoticeMailer/m, '/tmp/sample_project/app/mailers/user_notice_mailer.rb')
30
+ assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_project/config/initializers/mailer.rb')
31
+ assert_file_exists('/tmp/sample_project/app/views/user_notice_mailer')
33
32
  end
34
33
 
35
34
  should "support generating a new mailer extended from base with capitalized name" do
36
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon']) }
37
- silence_logger { @mailgen.start(['DEMO', '-r=/tmp/sample_app']) }
38
- assert_match_in_file(/class DemoMailer < Padrino::Mailer::Base/m, '/tmp/sample_app/app/mailers/demo_mailer.rb')
39
- assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_app/config/initializers/mailer.rb')
40
- assert_file_exists('/tmp/sample_app/app/views/demo_mailer')
35
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon']) }
36
+ silence_logger { @mail_gen.start(['DEMO', '-r=/tmp/sample_project']) }
37
+ assert_match_in_file(/class DemoMailer < Padrino::Mailer::Base/m, '/tmp/sample_project/app/mailers/demo_mailer.rb')
38
+ assert_match_in_file(/Padrino::Mailer::Base.smtp_settings/m, '/tmp/sample_project/config/initializers/mailer.rb')
39
+ assert_file_exists('/tmp/sample_project/app/views/demo_mailer')
41
40
  end
42
41
  end
43
42
 
44
43
  context "the mailer destroy option" do
45
44
 
46
45
  should "destroy mailer file" do
47
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon']) }
48
- silence_logger { @mailgen.start(['demo', '-r=/tmp/sample_app']) }
49
- silence_logger { @mailgen.start(['demo', '-r=/tmp/sample_app','-d']) }
50
- assert_no_dir_exists('/tmp/sample_app/app/views/demo_mailer')
51
- assert_no_file_exists('/tmp/sample_app/app/mailers/demo_mailer.rb')
52
- assert_no_file_exists('/tmp/sample_app/config/initializers/mailer.rb')
46
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon']) }
47
+ silence_logger { @mail_gen.start(['demo', '-r=/tmp/sample_project']) }
48
+ silence_logger { @mail_gen.start(['demo', '-r=/tmp/sample_project','-d']) }
49
+ assert_no_dir_exists('/tmp/sample_project/app/views/demo_mailer')
50
+ assert_no_file_exists('/tmp/sample_project/app/mailers/demo_mailer.rb')
51
+ assert_no_file_exists('/tmp/sample_project/config/initializers/mailer.rb')
53
52
  end
54
53
  end
55
54
 
@@ -3,10 +3,9 @@ require 'thor/group'
3
3
 
4
4
  class TestMigrationGenerator < Test::Unit::TestCase
5
5
  def setup
6
- Padrino::Generators.lockup!
7
- @app = Padrino::Generators::App.dup
6
+ @project = Padrino::Generators::Project.dup
8
7
  @mig_gen = Padrino::Generators::Migration.dup
9
- `rm -rf /tmp/sample_app`
8
+ `rm -rf /tmp/sample_project`
10
9
  end
11
10
 
12
11
  context 'the migration generator' do
@@ -17,54 +16,54 @@ class TestMigrationGenerator < Test::Unit::TestCase
17
16
  end
18
17
 
19
18
  should "generate migration inside app root" do
20
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
21
- response_success = silence_logger { @mig_gen.start(['AddEmailToUsers', '-r=/tmp/sample_app']) }
22
- migration_file_path = "/tmp/sample_app/db/migrate/001_add_email_to_users.rb"
19
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
20
+ response_success = silence_logger { @mig_gen.start(['AddEmailToUsers', '-r=/tmp/sample_project']) }
21
+ migration_file_path = "/tmp/sample_project/db/migrate/001_add_email_to_users.rb"
23
22
  assert_match_in_file(/class AddEmailToUser/m, migration_file_path)
24
23
  end
25
24
 
26
25
  should "generate migration inside app root with lowercase migration argument" do
27
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
28
- response_success = silence_logger { @mig_gen.start(['add_email_to_users', '-r=/tmp/sample_app']) }
29
- migration_file_path = "/tmp/sample_app/db/migrate/001_add_email_to_users.rb"
26
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
27
+ response_success = silence_logger { @mig_gen.start(['add_email_to_users', '-r=/tmp/sample_project']) }
28
+ migration_file_path = "/tmp/sample_project/db/migrate/001_add_email_to_users.rb"
30
29
  assert_match_in_file(/class AddEmailToUsers/m, migration_file_path)
31
30
  end
32
31
 
33
32
  should "generate migration inside app root with singular table" do
34
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
35
- silence_logger { @mig_gen.start(['add_email_to_user', "email:string", '-r=/tmp/sample_app']) }
36
- migration_file_path = "/tmp/sample_app/db/migrate/001_add_email_to_user.rb"
33
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
34
+ silence_logger { @mig_gen.start(['add_email_to_user', "email:string", '-r=/tmp/sample_project']) }
35
+ migration_file_path = "/tmp/sample_project/db/migrate/001_add_email_to_user.rb"
37
36
  assert_match_in_file(/class AddEmailToUser/m, migration_file_path)
38
37
  assert_match_in_file(/t.string :email/, migration_file_path)
39
38
  assert_match_in_file(/t.remove :email/, migration_file_path)
40
39
  end
41
40
 
42
41
  should "properly calculate version number" do
43
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
44
- silence_logger { @mig_gen.start(['add_email_to_person', "email:string", '-r=/tmp/sample_app']) }
45
- silence_logger { @mig_gen.start(['add_name_to_person', "email:string", '-r=/tmp/sample_app']) }
46
- silence_logger { @mig_gen.start(['add_age_to_user', "email:string", '-r=/tmp/sample_app']) }
47
- assert_match_in_file(/class AddEmailToPerson/m, "/tmp/sample_app/db/migrate/001_add_email_to_person.rb")
48
- assert_match_in_file(/class AddNameToPerson/m, "/tmp/sample_app/db/migrate/002_add_name_to_person.rb")
49
- assert_match_in_file(/class AddAgeToUser/m, "/tmp/sample_app/db/migrate/003_add_age_to_user.rb")
42
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
43
+ silence_logger { @mig_gen.start(['add_email_to_person', "email:string", '-r=/tmp/sample_project']) }
44
+ silence_logger { @mig_gen.start(['add_name_to_person', "email:string", '-r=/tmp/sample_project']) }
45
+ silence_logger { @mig_gen.start(['add_age_to_user', "email:string", '-r=/tmp/sample_project']) }
46
+ assert_match_in_file(/class AddEmailToPerson/m, "/tmp/sample_project/db/migrate/001_add_email_to_person.rb")
47
+ assert_match_in_file(/class AddNameToPerson/m, "/tmp/sample_project/db/migrate/002_add_name_to_person.rb")
48
+ assert_match_in_file(/class AddAgeToUser/m, "/tmp/sample_project/db/migrate/003_add_age_to_user.rb")
50
49
  end
51
50
  end
52
51
 
53
52
  context 'the migration generator for activerecord' do
54
53
  should "generate migration for generic needs" do
55
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
56
- response_success = silence_logger { @mig_gen.start(['ModifyUserFields', '-r=/tmp/sample_app']) }
57
- migration_file_path = "/tmp/sample_app/db/migrate/001_modify_user_fields.rb"
54
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
55
+ response_success = silence_logger { @mig_gen.start(['ModifyUserFields', '-r=/tmp/sample_project']) }
56
+ migration_file_path = "/tmp/sample_project/db/migrate/001_modify_user_fields.rb"
58
57
  assert_match_in_file(/class ModifyUserFields/m, migration_file_path)
59
58
  assert_match_in_file(/def self\.up\s+end/m, migration_file_path)
60
59
  assert_match_in_file(/def self\.down\s+end/m, migration_file_path)
61
60
  end
62
61
 
63
62
  should "generate migration for adding columns" do
64
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
65
- migration_params = ['AddEmailToUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
63
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
64
+ migration_params = ['AddEmailToUsers', "email:string", "age:integer", '-r=/tmp/sample_project']
66
65
  response_success = silence_logger { @mig_gen.start(migration_params) }
67
- migration_file_path = "/tmp/sample_app/db/migrate/001_add_email_to_users.rb"
66
+ migration_file_path = "/tmp/sample_project/db/migrate/001_add_email_to_users.rb"
68
67
  assert_match_in_file(/class AddEmailToUsers/m, migration_file_path)
69
68
  assert_match_in_file(/change_table :users.*?t\.string :email/m, migration_file_path)
70
69
  assert_match_in_file(/t\.integer :age/m, migration_file_path)
@@ -73,10 +72,10 @@ class TestMigrationGenerator < Test::Unit::TestCase
73
72
  end
74
73
 
75
74
  should "generate migration for removing columns" do
76
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
77
- migration_params = ['RemoveEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
75
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=activerecord']) }
76
+ migration_params = ['RemoveEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_project']
78
77
  response_success = silence_logger { @mig_gen.start(migration_params) }
79
- migration_file_path = "/tmp/sample_app/db/migrate/001_remove_email_from_users.rb"
78
+ migration_file_path = "/tmp/sample_project/db/migrate/001_remove_email_from_users.rb"
80
79
  assert_match_in_file(/class RemoveEmailFromUsers/m, migration_file_path)
81
80
  assert_match_in_file(/change_table :users.*?t\.remove :email/m, migration_file_path)
82
81
  assert_match_in_file(/t\.remove :age/m, migration_file_path)
@@ -87,19 +86,19 @@ class TestMigrationGenerator < Test::Unit::TestCase
87
86
 
88
87
  context 'the migration generator for datamapper' do
89
88
  should "generate migration for generic needs" do
90
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=datamapper']) }
91
- response_success = silence_logger { @mig_gen.start(['ModifyUserFields', '-r=/tmp/sample_app']) }
92
- migration_file_path = "/tmp/sample_app/db/migrate/001_modify_user_fields.rb"
89
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=datamapper']) }
90
+ response_success = silence_logger { @mig_gen.start(['ModifyUserFields', '-r=/tmp/sample_project']) }
91
+ migration_file_path = "/tmp/sample_project/db/migrate/001_modify_user_fields.rb"
93
92
  assert_match_in_file(/migration\s1.*?:modify_user_fields/m, migration_file_path)
94
93
  assert_match_in_file(/up\sdo\s+end/m, migration_file_path)
95
94
  assert_match_in_file(/down\sdo\s+end/m, migration_file_path)
96
95
  end
97
96
 
98
97
  should "generate migration for adding columns" do
99
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=datamapper']) }
100
- migration_params = ['AddEmailToUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
98
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=datamapper']) }
99
+ migration_params = ['AddEmailToUsers', "email:string", "age:integer", '-r=/tmp/sample_project']
101
100
  response_success = silence_logger { @mig_gen.start(migration_params) }
102
- migration_file_path = "/tmp/sample_app/db/migrate/001_add_email_to_users.rb"
101
+ migration_file_path = "/tmp/sample_project/db/migrate/001_add_email_to_users.rb"
103
102
  assert_match_in_file(/migration\s1.*?:add_email_to_users/m, migration_file_path)
104
103
  assert_match_in_file(/modify_table :users.*?add_column :email, String/m, migration_file_path)
105
104
  assert_match_in_file(/add_column :age, Integer/m, migration_file_path)
@@ -108,10 +107,10 @@ class TestMigrationGenerator < Test::Unit::TestCase
108
107
  end
109
108
 
110
109
  should "generate migration for removing columns" do
111
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=datamapper']) }
112
- migration_params = ['RemoveEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
110
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=datamapper']) }
111
+ migration_params = ['RemoveEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_project']
113
112
  response_success = silence_logger { @mig_gen.start(migration_params) }
114
- migration_file_path = "/tmp/sample_app/db/migrate/001_remove_email_from_users.rb"
113
+ migration_file_path = "/tmp/sample_project/db/migrate/001_remove_email_from_users.rb"
115
114
  assert_match_in_file(/migration\s1.*?:remove_email_from_users/m, migration_file_path)
116
115
  assert_match_in_file(/modify_table :users.*?drop_column :email/m, migration_file_path)
117
116
  assert_match_in_file(/drop_column :age/m, migration_file_path)
@@ -120,31 +119,31 @@ class TestMigrationGenerator < Test::Unit::TestCase
120
119
  end
121
120
 
122
121
  should "properly version migration files" do
123
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=datamapper']) }
124
- response_success = silence_logger { @mig_gen.start(['ModifyUserFields', '-r=/tmp/sample_app']) }
125
- response_success = silence_logger { @mig_gen.start(['ModifyUserFields2', '-r=/tmp/sample_app']) }
126
- response_success = silence_logger { @mig_gen.start(['ModifyUserFields3', '-r=/tmp/sample_app']) }
127
- assert_match_in_file(/migration\s1.*?:modify_user_fields/m, "/tmp/sample_app/db/migrate/001_modify_user_fields.rb")
128
- assert_match_in_file(/migration\s2.*?:modify_user_fields2/m, "/tmp/sample_app/db/migrate/002_modify_user_fields2.rb")
129
- assert_match_in_file(/migration\s3.*?:modify_user_fields3/m, "/tmp/sample_app/db/migrate/003_modify_user_fields3.rb")
122
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=datamapper']) }
123
+ response_success = silence_logger { @mig_gen.start(['ModifyUserFields', '-r=/tmp/sample_project']) }
124
+ response_success = silence_logger { @mig_gen.start(['ModifyUserFields2', '-r=/tmp/sample_project']) }
125
+ response_success = silence_logger { @mig_gen.start(['ModifyUserFields3', '-r=/tmp/sample_project']) }
126
+ assert_match_in_file(/migration\s1.*?:modify_user_fields/m, "/tmp/sample_project/db/migrate/001_modify_user_fields.rb")
127
+ assert_match_in_file(/migration\s2.*?:modify_user_fields2/m, "/tmp/sample_project/db/migrate/002_modify_user_fields2.rb")
128
+ assert_match_in_file(/migration\s3.*?:modify_user_fields3/m, "/tmp/sample_project/db/migrate/003_modify_user_fields3.rb")
130
129
  end
131
130
  end
132
131
 
133
132
  context 'the migration generator for sequel' do
134
133
  should "generate migration for generic needs" do
135
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
136
- response_success = silence_logger { @mig_gen.start(['ModifyUserFields', '-r=/tmp/sample_app']) }
137
- migration_file_path = "/tmp/sample_app/db/migrate/001_modify_user_fields.rb"
134
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
135
+ response_success = silence_logger { @mig_gen.start(['ModifyUserFields', '-r=/tmp/sample_project']) }
136
+ migration_file_path = "/tmp/sample_project/db/migrate/001_modify_user_fields.rb"
138
137
  assert_match_in_file(/class ModifyUserFields/m, migration_file_path)
139
138
  assert_match_in_file(/def\sup\s+end/m, migration_file_path)
140
139
  assert_match_in_file(/def\sdown\s+end/m, migration_file_path)
141
140
  end
142
141
 
143
142
  should "generate migration for adding columns" do
144
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
145
- migration_params = ['AddEmailToUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
143
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
144
+ migration_params = ['AddEmailToUsers', "email:string", "age:integer", '-r=/tmp/sample_project']
146
145
  response_success = silence_logger { @mig_gen.start(migration_params) }
147
- migration_file_path = "/tmp/sample_app/db/migrate/001_add_email_to_users.rb"
146
+ migration_file_path = "/tmp/sample_project/db/migrate/001_add_email_to_users.rb"
148
147
  assert_match_in_file(/class AddEmailToUsers/m, migration_file_path)
149
148
  assert_match_in_file(/alter_table :users.*?add_column :email, String/m, migration_file_path)
150
149
  assert_match_in_file(/add_column :age, Integer/m, migration_file_path)
@@ -153,10 +152,10 @@ class TestMigrationGenerator < Test::Unit::TestCase
153
152
  end
154
153
 
155
154
  should "generate migration for removing columns" do
156
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
157
- migration_params = ['RemoveEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
155
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
156
+ migration_params = ['RemoveEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_project']
158
157
  response_success = silence_logger { @mig_gen.start(migration_params) }
159
- migration_file_path = "/tmp/sample_app/db/migrate/001_remove_email_from_users.rb"
158
+ migration_file_path = "/tmp/sample_project/db/migrate/001_remove_email_from_users.rb"
160
159
  assert_match_in_file(/class RemoveEmailFromUsers/m, migration_file_path)
161
160
  assert_match_in_file(/alter_table :users.*?drop_column :email/m, migration_file_path)
162
161
  assert_match_in_file(/drop_column :age/m, migration_file_path)
@@ -168,21 +167,21 @@ class TestMigrationGenerator < Test::Unit::TestCase
168
167
  context "the migration destroy option" do
169
168
 
170
169
  should "destroy the migration files" do
171
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
172
- migration_params = ['RemoveEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
170
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
171
+ migration_params = ['RemoveEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_project']
173
172
  silence_logger { @mig_gen.start(migration_params) }
174
- silence_logger { @mig_gen.start(['RemoveEmailFromUsers', '-r=/tmp/sample_app','-d']) }
175
- assert_no_file_exists("/tmp/sample_app/db/migrate/001_remove_email_from_users.rb")
173
+ silence_logger { @mig_gen.start(['RemoveEmailFromUsers', '-r=/tmp/sample_project','-d']) }
174
+ assert_no_file_exists("/tmp/sample_project/db/migrate/001_remove_email_from_users.rb")
176
175
  end
177
176
 
178
177
  should "destroy the migration file regardless of number" do
179
- silence_logger { @app.start(['sample_app', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
180
- migration_params = ['RemoveEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
181
- migration_param2 = ['AddEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_app']
178
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '--script=none', '-t=bacon', '-d=sequel']) }
179
+ migration_params = ['RemoveEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_project']
180
+ migration_param2 = ['AddEmailFromUsers', "email:string", "age:integer", '-r=/tmp/sample_project']
182
181
  silence_logger { @mig_gen.start(migration_param2) }
183
182
  silence_logger { @mig_gen.start(migration_params) }
184
- silence_logger { @mig_gen.start(['RemoveEmailFromUsers', '-r=/tmp/sample_app','-d']) }
185
- assert_no_file_exists("/tmp/sample_app/db/migrate/002_remove_email_from_users.rb")
183
+ silence_logger { @mig_gen.start(['RemoveEmailFromUsers', '-r=/tmp/sample_project','-d']) }
184
+ assert_no_file_exists("/tmp/sample_project/db/migrate/002_remove_email_from_users.rb")
186
185
  end
187
186
 
188
187
  end