padrino-gen 0.16.0.pre4 → 0.16.0
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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/bin/padrino-gen +4 -4
- data/lib/padrino-gen/command.rb +2 -2
- data/lib/padrino-gen/generators/actions.rb +68 -64
- data/lib/padrino-gen/generators/app/app.rb.tt +6 -6
- data/lib/padrino-gen/generators/app.rb +19 -19
- data/lib/padrino-gen/generators/cli.rb +16 -19
- data/lib/padrino-gen/generators/component.rb +18 -19
- data/lib/padrino-gen/generators/components/actions.rb +42 -42
- data/lib/padrino-gen/generators/components/mocks/mocha.rb +7 -7
- data/lib/padrino-gen/generators/components/mocks/rr.rb +7 -7
- data/lib/padrino-gen/generators/components/orms/activerecord.rb +158 -156
- data/lib/padrino-gen/generators/components/orms/couchrest.rb +33 -33
- data/lib/padrino-gen/generators/components/orms/datamapper.rb +108 -103
- data/lib/padrino-gen/generators/components/orms/dynamoid.rb +40 -40
- data/lib/padrino-gen/generators/components/orms/minirecord.rb +114 -114
- data/lib/padrino-gen/generators/components/orms/mongoid.rb +65 -65
- data/lib/padrino-gen/generators/components/orms/mongomapper.rb +20 -20
- data/lib/padrino-gen/generators/components/orms/mongomatic.rb +63 -59
- data/lib/padrino-gen/generators/components/orms/ohm.rb +49 -47
- data/lib/padrino-gen/generators/components/orms/ripple.rb +45 -45
- data/lib/padrino-gen/generators/components/orms/sequel.rb +51 -46
- data/lib/padrino-gen/generators/components/renderers/erb.rb +1 -1
- data/lib/padrino-gen/generators/components/renderers/liquid.rb +1 -1
- data/lib/padrino-gen/generators/components/scripts/dojo.rb +6 -6
- data/lib/padrino-gen/generators/components/scripts/extcore.rb +6 -6
- data/lib/padrino-gen/generators/components/scripts/jquery.rb +6 -6
- data/lib/padrino-gen/generators/components/scripts/mootools.rb +6 -6
- data/lib/padrino-gen/generators/components/scripts/prototype.rb +8 -8
- data/lib/padrino-gen/generators/components/stylesheets/compass.rb +1 -1
- data/lib/padrino-gen/generators/components/stylesheets/less.rb +4 -4
- data/lib/padrino-gen/generators/components/tests/bacon.rb +66 -66
- data/lib/padrino-gen/generators/components/tests/cucumber.rb +61 -61
- data/lib/padrino-gen/generators/components/tests/minitest.rb +70 -70
- data/lib/padrino-gen/generators/components/tests/rspec.rb +74 -74
- data/lib/padrino-gen/generators/components/tests/shoulda.rb +72 -72
- data/lib/padrino-gen/generators/components/tests/testunit.rb +69 -69
- data/lib/padrino-gen/generators/controller.rb +16 -17
- data/lib/padrino-gen/generators/helper.rb +8 -9
- data/lib/padrino-gen/generators/mailer.rb +8 -9
- data/lib/padrino-gen/generators/migration.rb +6 -6
- data/lib/padrino-gen/generators/model.rb +20 -21
- data/lib/padrino-gen/generators/plugin.rb +9 -9
- data/lib/padrino-gen/generators/project/config/apps.rb.tt +4 -4
- data/lib/padrino-gen/generators/project/config/boot.rb +2 -2
- data/lib/padrino-gen/generators/project/config.ru +1 -1
- data/lib/padrino-gen/generators/project.rb +49 -51
- data/lib/padrino-gen/generators/runner.rb +25 -24
- data/lib/padrino-gen/generators/task.rb +7 -8
- data/lib/padrino-gen/generators/templates/Gemfile.tt +5 -5
- data/lib/padrino-gen/generators/templates/controller.rb.tt +3 -3
- data/lib/padrino-gen/generators/templates/mailer.rb.tt +15 -15
- data/lib/padrino-gen/generators/templates/project_bin.tt +1 -1
- data/lib/padrino-gen/generators/templates/task.rb.tt +1 -1
- data/lib/padrino-gen/padrino-tasks/activerecord.rb +152 -160
- data/lib/padrino-gen/padrino-tasks/database.rb +2 -2
- data/lib/padrino-gen/padrino-tasks/datamapper.rb +31 -31
- data/lib/padrino-gen/padrino-tasks/minirecord.rb +3 -3
- data/lib/padrino-gen/padrino-tasks/mongoid.rb +39 -41
- data/lib/padrino-gen/padrino-tasks/mongomapper.rb +18 -14
- data/lib/padrino-gen/padrino-tasks/sequel.rb +28 -28
- data/lib/padrino-gen/padrino-tasks/sql-helpers.rb +45 -45
- data/lib/padrino-gen.rb +4 -4
- data/padrino-gen.gemspec +19 -19
- data/test/fixtures/admin_template.rb +5 -5
- data/test/fixtures/database_template.rb +19 -22
- data/test/fixtures/example_template.rb +8 -8
- data/test/fixtures/git_template.rb +2 -2
- data/test/fixtures/plugin_template.rb +3 -3
- data/test/fixtures/rake_template.rb +5 -5
- data/test/helper.rb +23 -21
- data/test/test_app_generator.rb +13 -13
- data/test/test_cli.rb +4 -5
- data/test/test_component_generator.rb +17 -17
- data/test/test_controller_generator.rb +62 -63
- data/test/test_generator.rb +6 -6
- data/test/test_helper_generator.rb +23 -24
- data/test/test_mailer_generator.rb +7 -7
- data/test/test_migration_generator.rb +31 -31
- data/test/test_model_generator.rb +80 -80
- data/test/test_plugin_generator.rb +35 -36
- data/test/test_project_generator.rb +171 -169
- data/test/test_sql_helpers.rb +49 -50
- data/test/test_task_generator.rb +13 -13
- metadata +10 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative 'helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
3
|
+
describe 'ProjectGenerator' do
|
|
4
4
|
def setup
|
|
5
5
|
@apptmp = "#{Dir.tmpdir}/padrino-tests/#{SecureRandom.hex}"
|
|
6
6
|
`mkdir -p #{@apptmp}`
|
|
@@ -16,9 +16,9 @@ describe "ProjectGenerator" do
|
|
|
16
16
|
it 'should allow simple generator to run and create base_app with no options' do
|
|
17
17
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
|
18
18
|
assert_dir_exists("#{@apptmp}/sample_project")
|
|
19
|
-
assert_match_in_file(/module SampleProject/,"#{@apptmp}/sample_project/app/app.rb")
|
|
20
|
-
assert_match_in_file(/class App < Padrino::Application/,"#{@apptmp}/sample_project/app/app.rb")
|
|
21
|
-
assert_match_in_file("Padrino.mount('SampleProject::App', :
|
|
19
|
+
assert_match_in_file(/module SampleProject/, "#{@apptmp}/sample_project/app/app.rb")
|
|
20
|
+
assert_match_in_file(/class App < Padrino::Application/, "#{@apptmp}/sample_project/app/app.rb")
|
|
21
|
+
assert_match_in_file("Padrino.mount('SampleProject::App', app_file: Padrino.root('app/app.rb')).to('/')", "#{@apptmp}/sample_project/config/apps.rb")
|
|
22
22
|
assert_file_exists("#{@apptmp}/sample_project/config/boot.rb")
|
|
23
23
|
assert_file_exists("#{@apptmp}/sample_project/Rakefile")
|
|
24
24
|
assert_file_exists("#{@apptmp}/sample_project/exe/sample_project")
|
|
@@ -33,62 +33,64 @@ describe "ProjectGenerator" do
|
|
|
33
33
|
it 'should generate a valid name' do
|
|
34
34
|
capture_io { generate(:project, 'project.com', "--root=#{@apptmp}") }
|
|
35
35
|
assert_dir_exists("#{@apptmp}/project.com")
|
|
36
|
-
assert_match_in_file(/module ProjectCom/,
|
|
37
|
-
assert_match_in_file(/class App < Padrino::Application/,
|
|
38
|
-
assert_match_in_file("Padrino.mount('ProjectCom::App', :
|
|
36
|
+
assert_match_in_file(/module ProjectCom/, "#{@apptmp}/project.com/app/app.rb")
|
|
37
|
+
assert_match_in_file(/class App < Padrino::Application/, "#{@apptmp}/project.com/app/app.rb")
|
|
38
|
+
assert_match_in_file("Padrino.mount('ProjectCom::App', app_file: Padrino.root('app/app.rb')).to('/')", "#{@apptmp}/project.com/config/apps.rb")
|
|
39
|
+
|
|
39
40
|
capture_io { generate(:app, 'ws-dci-2011', "--root=#{@apptmp}/project.com") }
|
|
40
41
|
assert_dir_exists("#{@apptmp}/project.com/ws_dci_2011")
|
|
41
|
-
assert_match_in_file(/module ProjectCom/,
|
|
42
|
-
assert_match_in_file(/class WsDci2011 < Padrino::Application/,
|
|
43
|
-
assert_match_in_file("Padrino.mount('ProjectCom::WsDci2011', :
|
|
42
|
+
assert_match_in_file(/module ProjectCom/, "#{@apptmp}/project.com/ws_dci_2011/app.rb")
|
|
43
|
+
assert_match_in_file(/class WsDci2011 < Padrino::Application/, "#{@apptmp}/project.com/ws_dci_2011/app.rb")
|
|
44
|
+
assert_match_in_file("Padrino.mount('ProjectCom::WsDci2011', app_file: Padrino.root('ws_dci_2011/app.rb')).to('/ws_dci_2011')", "#{@apptmp}/project.com/config/apps.rb")
|
|
44
45
|
end
|
|
45
46
|
|
|
46
47
|
it 'should generate nested path with dashes in name' do
|
|
47
48
|
capture_io { generate(:project, 'sample-project', "--root=#{@apptmp}") }
|
|
48
49
|
assert_dir_exists("#{@apptmp}/sample-project")
|
|
49
|
-
assert_match_in_file(/module SampleProject/,
|
|
50
|
-
assert_match_in_file(/class App < Padrino::Application/,
|
|
51
|
-
assert_match_in_file("Padrino.mount('SampleProject::App', :
|
|
50
|
+
assert_match_in_file(/module SampleProject/, "#{@apptmp}/sample-project/app/app.rb")
|
|
51
|
+
assert_match_in_file(/class App < Padrino::Application/, "#{@apptmp}/sample-project/app/app.rb")
|
|
52
|
+
assert_match_in_file("Padrino.mount('SampleProject::App', app_file: Padrino.root('app/app.rb')).to('/')", "#{@apptmp}/sample-project/config/apps.rb")
|
|
53
|
+
|
|
52
54
|
capture_io { generate(:app, 'ws-dci-2011', "--root=#{@apptmp}/sample-project") }
|
|
53
55
|
assert_dir_exists("#{@apptmp}/sample-project/ws_dci_2011")
|
|
54
|
-
assert_match_in_file(/module SampleProject/,
|
|
55
|
-
assert_match_in_file(/class WsDci2011 < Padrino::Application/,
|
|
56
|
-
assert_match_in_file("Padrino.mount('SampleProject::WsDci2011', :
|
|
56
|
+
assert_match_in_file(/module SampleProject/, "#{@apptmp}/sample-project/ws_dci_2011/app.rb")
|
|
57
|
+
assert_match_in_file(/class WsDci2011 < Padrino::Application/, "#{@apptmp}/sample-project/ws_dci_2011/app.rb")
|
|
58
|
+
assert_match_in_file("Padrino.mount('SampleProject::WsDci2011', app_file: Padrino.root('ws_dci_2011/app.rb')).to('/ws_dci_2011')", "#{@apptmp}/sample-project/config/apps.rb")
|
|
57
59
|
end
|
|
58
60
|
|
|
59
61
|
it 'should raise an Error when given invalid constant names' do
|
|
60
|
-
assert_raises(::NameError) { capture_io { generate(:project,
|
|
61
|
-
assert_raises(::NameError) { capture_io { generate(:project,
|
|
62
|
+
assert_raises(::NameError) { capture_io { generate(:project, '123asdf', "--root=#{@apptmp}") } }
|
|
63
|
+
assert_raises(::NameError) { capture_io { generate(:project, './sample_project', "--root=#{@apptmp}") } }
|
|
62
64
|
end
|
|
63
65
|
|
|
64
66
|
it 'should display the right path' do
|
|
65
|
-
out,
|
|
66
|
-
assert_dir_exists(
|
|
67
|
-
assert_match(
|
|
67
|
+
out, = capture_io { generate(:project, 'project', '--root=/tmp') }
|
|
68
|
+
assert_dir_exists('/tmp/project')
|
|
69
|
+
assert_match(%r{cd /tmp/project}, out)
|
|
68
70
|
end
|
|
69
71
|
|
|
70
72
|
it 'should allow specifying alternate application name' do
|
|
71
73
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--app=base_app') }
|
|
72
74
|
assert_dir_exists("#{@apptmp}/sample_project")
|
|
73
|
-
assert_match_in_file(/module SampleProject/,"#{@apptmp}/sample_project/app/app.rb")
|
|
74
|
-
assert_match_in_file(/class BaseApp < Padrino::Application/,"#{@apptmp}/sample_project/app/app.rb")
|
|
75
|
-
assert_match_in_file("Padrino.mount('SampleProject::BaseApp', :
|
|
75
|
+
assert_match_in_file(/module SampleProject/, "#{@apptmp}/sample_project/app/app.rb")
|
|
76
|
+
assert_match_in_file(/class BaseApp < Padrino::Application/, "#{@apptmp}/sample_project/app/app.rb")
|
|
77
|
+
assert_match_in_file("Padrino.mount('SampleProject::BaseApp', app_file: Padrino.root('app/app.rb')).to('/')", "#{@apptmp}/sample_project/config/apps.rb")
|
|
76
78
|
assert_file_exists("#{@apptmp}/sample_project/config/boot.rb")
|
|
77
79
|
assert_file_exists("#{@apptmp}/sample_project/public/favicon.ico")
|
|
78
80
|
end
|
|
79
81
|
|
|
80
82
|
it 'should add database tasks to Rakefile if an ORM is defined' do
|
|
81
83
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--app=base_app', '--orm=activerecord') }
|
|
82
|
-
assert_match_in_file('PadrinoTasks.use(:database)',"#{@apptmp}/sample_project/Rakefile")
|
|
84
|
+
assert_match_in_file('PadrinoTasks.use(:database)', "#{@apptmp}/sample_project/Rakefile")
|
|
83
85
|
end
|
|
84
86
|
|
|
85
87
|
it 'should avoid add database tasks on Rakefile if no ORM is specified' do
|
|
86
88
|
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--app=base_app') }
|
|
87
|
-
assert_no_match_in_file('PadrinoTasks.use(:database)',"#{@apptmp}/sample_project/Rakefile")
|
|
89
|
+
assert_no_match_in_file('PadrinoTasks.use(:database)', "#{@apptmp}/sample_project/Rakefile")
|
|
88
90
|
end
|
|
89
91
|
|
|
90
92
|
it 'should generate lean project' do
|
|
91
|
-
capture_io { generate(:project,'sample_project', '--lean', "--root=#{@apptmp}") }
|
|
93
|
+
capture_io { generate(:project, 'sample_project', '--lean', "--root=#{@apptmp}") }
|
|
92
94
|
assert_file_exists("#{@apptmp}/sample_project/public/favicon.ico")
|
|
93
95
|
assert_file_exists("#{@apptmp}/sample_project/config/boot.rb")
|
|
94
96
|
assert_no_file_exists("#{@apptmp}/sample_project/app/app.rb")
|
|
@@ -96,12 +98,12 @@ describe "ProjectGenerator" do
|
|
|
96
98
|
end
|
|
97
99
|
|
|
98
100
|
it 'should generate lean project correctly even if the component is specified' do
|
|
99
|
-
|
|
100
|
-
assert_match(
|
|
101
|
+
_, err = capture_io { generate(:project, 'sample_project', '--lean', "--root=#{@apptmp}", '--orm=activerecord', '--stylesheet=compass') }
|
|
102
|
+
assert_match('', err)
|
|
101
103
|
end
|
|
102
104
|
|
|
103
105
|
it 'should generate tiny skeleton' do
|
|
104
|
-
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}") }
|
|
106
|
+
capture_io { generate(:project, 'sample_project', '--tiny', "--root=#{@apptmp}") }
|
|
105
107
|
assert_dir_exists("#{@apptmp}/sample_project")
|
|
106
108
|
assert_dir_exists("#{@apptmp}/sample_project/app")
|
|
107
109
|
assert_file_exists("#{@apptmp}/sample_project/app/controllers.rb")
|
|
@@ -110,7 +112,7 @@ describe "ProjectGenerator" do
|
|
|
110
112
|
assert_dir_exists("#{@apptmp}/sample_project/public/images")
|
|
111
113
|
assert_dir_exists("#{@apptmp}/sample_project/public/javascripts")
|
|
112
114
|
assert_dir_exists("#{@apptmp}/sample_project/public/stylesheets")
|
|
113
|
-
assert_match_in_file(/:notifier/,"#{@apptmp}/sample_project/app/mailers.rb")
|
|
115
|
+
assert_match_in_file(/:notifier/, "#{@apptmp}/sample_project/app/mailers.rb")
|
|
114
116
|
assert_match_in_file(/module Helper/, "#{@apptmp}/sample_project/app/helpers.rb")
|
|
115
117
|
assert_match_in_file(/helpers Helper/, "#{@apptmp}/sample_project/app/helpers.rb")
|
|
116
118
|
assert_no_file_exists("#{@apptmp}/sample_project/demo/helpers")
|
|
@@ -118,30 +120,30 @@ describe "ProjectGenerator" do
|
|
|
118
120
|
end
|
|
119
121
|
|
|
120
122
|
it 'should generate gemspec and special files if gem is expected' do
|
|
121
|
-
capture_io { generate(:project,'sample_gem', '--gem', "--root=#{@apptmp}") }
|
|
123
|
+
capture_io { generate(:project, 'sample_gem', '--gem', "--root=#{@apptmp}") }
|
|
122
124
|
assert_file_exists("#{@apptmp}/sample_gem/sample_gem.gemspec")
|
|
123
|
-
assert_match_in_file(/^gemspec/,"#{@apptmp}/sample_gem/Gemfile")
|
|
124
|
-
assert_match_in_file(/^module SampleGem/,"#{@apptmp}/sample_gem/app/app.rb")
|
|
125
|
-
assert_match_in_file(/class App/,"#{@apptmp}/sample_gem/app/app.rb")
|
|
125
|
+
assert_match_in_file(/^gemspec/, "#{@apptmp}/sample_gem/Gemfile")
|
|
126
|
+
assert_match_in_file(/^module SampleGem/, "#{@apptmp}/sample_gem/app/app.rb")
|
|
127
|
+
assert_match_in_file(/class App/, "#{@apptmp}/sample_gem/app/app.rb")
|
|
126
128
|
assert_file_exists("#{@apptmp}/sample_gem/README.md")
|
|
127
129
|
assert_no_file_exists("#{@apptmp}/sample_gem/tmp/.keep")
|
|
128
130
|
assert_no_file_exists("#{@apptmp}/sample_gem/log/.keep")
|
|
129
131
|
end
|
|
130
132
|
|
|
131
133
|
it 'should generate gemspec and special files with dashes in name' do
|
|
132
|
-
capture_io { generate(:project,'sample-gem', '--gem', "--root=#{@apptmp}") }
|
|
134
|
+
capture_io { generate(:project, 'sample-gem', '--gem', "--root=#{@apptmp}") }
|
|
133
135
|
assert_file_exists("#{@apptmp}/sample-gem/sample-gem.gemspec")
|
|
134
136
|
assert_file_exists("#{@apptmp}/sample-gem/README.md")
|
|
135
|
-
assert_match_in_file(
|
|
136
|
-
assert_match_in_file(/"sample-gem"/,"#{@apptmp}/sample-gem/sample-gem.gemspec")
|
|
137
|
-
assert_match_in_file(/SampleGem::VERSION/,"#{@apptmp}/sample-gem/sample-gem.gemspec")
|
|
138
|
-
assert_match_in_file(/^# SampleGem/,"#{@apptmp}/sample-gem/README.md")
|
|
139
|
-
assert_match_in_file(/SampleGem::App/,"#{@apptmp}/sample-gem/README.md")
|
|
140
|
-
assert_match_in_file(/^module SampleGem/,"#{@apptmp}/sample-gem/lib/sample-gem.rb")
|
|
141
|
-
assert_match_in_file(/gem! "sample-gem"/,"#{@apptmp}/sample-gem/lib/sample-gem.rb")
|
|
142
|
-
assert_match_in_file(/^module SampleGem/,"#{@apptmp}/sample-gem/lib/sample-gem/version.rb")
|
|
143
|
-
assert_match_in_file(/^module SampleGem/,"#{@apptmp}/sample-gem/app/app.rb")
|
|
144
|
-
assert_match_in_file(/class App/,"#{@apptmp}/sample-gem/app/app.rb")
|
|
137
|
+
assert_match_in_file(%r{/lib/sample-gem/version}, "#{@apptmp}/sample-gem/sample-gem.gemspec")
|
|
138
|
+
assert_match_in_file(/"sample-gem"/, "#{@apptmp}/sample-gem/sample-gem.gemspec")
|
|
139
|
+
assert_match_in_file(/SampleGem::VERSION/, "#{@apptmp}/sample-gem/sample-gem.gemspec")
|
|
140
|
+
assert_match_in_file(/^# SampleGem/, "#{@apptmp}/sample-gem/README.md")
|
|
141
|
+
assert_match_in_file(/SampleGem::App/, "#{@apptmp}/sample-gem/README.md")
|
|
142
|
+
assert_match_in_file(/^module SampleGem/, "#{@apptmp}/sample-gem/lib/sample-gem.rb")
|
|
143
|
+
assert_match_in_file(/gem! "sample-gem"/, "#{@apptmp}/sample-gem/lib/sample-gem.rb")
|
|
144
|
+
assert_match_in_file(/^module SampleGem/, "#{@apptmp}/sample-gem/lib/sample-gem/version.rb")
|
|
145
|
+
assert_match_in_file(/^module SampleGem/, "#{@apptmp}/sample-gem/app/app.rb")
|
|
146
|
+
assert_match_in_file(/class App/, "#{@apptmp}/sample-gem/app/app.rb")
|
|
145
147
|
end
|
|
146
148
|
|
|
147
149
|
it 'should not create models folder if no orm is chosen' do
|
|
@@ -158,11 +160,11 @@ describe "ProjectGenerator" do
|
|
|
158
160
|
capture_io { generate(:project, 'warepedia', "--root=#{@apptmp}", '--script=none') }
|
|
159
161
|
assert_match_in_file(/module Warepedia/m, "#{@apptmp}/warepedia/app/app.rb")
|
|
160
162
|
assert_match_in_file(/class App < Padrino::Application/m, "#{@apptmp}/warepedia/app/app.rb")
|
|
161
|
-
assert_match_in_file("Padrino.mount('Warepedia::App', :
|
|
163
|
+
assert_match_in_file("Padrino.mount('Warepedia::App', app_file: Padrino.root('app/app.rb')).to('/')", "#{@apptmp}/warepedia/config/apps.rb")
|
|
162
164
|
end
|
|
163
165
|
|
|
164
166
|
it 'should store and apply session_secret' do
|
|
165
|
-
capture_io { generate(:project,'sample_project', '--tiny',"--root=#{@apptmp}") }
|
|
167
|
+
capture_io { generate(:project, 'sample_project', '--tiny', "--root=#{@apptmp}") }
|
|
166
168
|
assert_match_in_file(/set :session_secret, '[0-9A-z]*'/, "#{@apptmp}/sample_project/config/apps.rb")
|
|
167
169
|
end
|
|
168
170
|
|
|
@@ -189,8 +191,8 @@ describe "ProjectGenerator" do
|
|
|
189
191
|
end
|
|
190
192
|
|
|
191
193
|
it 'should output to log components being applied' do
|
|
192
|
-
component_options = ['--orm=datamapper', '--test=rspec', '--mock=mocha', '--script=prototype', '--renderer=erb','--stylesheet=less']
|
|
193
|
-
out,
|
|
194
|
+
component_options = ['--orm=datamapper', '--test=rspec', '--mock=mocha', '--script=prototype', '--renderer=erb', '--stylesheet=less']
|
|
195
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", *component_options) }
|
|
194
196
|
assert_match(/applying.*?datamapper.*?orm/, out)
|
|
195
197
|
assert_match(/applying.*?rspec.*?test/, out)
|
|
196
198
|
assert_match(/applying.*?mocha.*?mock/, out)
|
|
@@ -205,178 +207,178 @@ describe "ProjectGenerator" do
|
|
|
205
207
|
end
|
|
206
208
|
|
|
207
209
|
it 'should create .keep files for empty directories that are required for running application' do
|
|
208
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}",
|
|
210
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--stylesheet=sass', '--orm=sequel') }
|
|
209
211
|
assert_file_exists("#{@apptmp}/sample_project/tmp/.keep")
|
|
210
212
|
assert_file_exists("#{@apptmp}/sample_project/log/.keep")
|
|
211
213
|
end
|
|
212
214
|
|
|
213
215
|
it 'should allow to pass upcased name as the app name' do
|
|
214
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}",
|
|
216
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--app=API') }
|
|
215
217
|
assert_file_exists("#{@apptmp}/sample_project/app/app.rb")
|
|
216
218
|
assert_match_in_file(/class API < Padrino::Application/, "#{@apptmp}/sample_project/app/app.rb")
|
|
217
219
|
end
|
|
218
220
|
end
|
|
219
221
|
|
|
220
|
-
describe
|
|
222
|
+
describe 'a generator for mock component' do
|
|
221
223
|
it 'should properly generate for rr and minitest' do
|
|
222
|
-
out,
|
|
224
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--mock=rr', '--test=minitest', '--script=none') }
|
|
223
225
|
assert_match(/applying.*?rr.*?mock/, out)
|
|
224
226
|
assert_match_in_file(/gem 'rr'/, "#{@apptmp}/sample_project/Gemfile")
|
|
225
227
|
assert_match_in_file(/include RR::Adapters::MiniTest/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
226
228
|
end
|
|
227
229
|
|
|
228
230
|
it 'should properly generater for rr and bacon' do
|
|
229
|
-
out,
|
|
231
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--mock=rr', '--test=bacon', '--script=none') }
|
|
230
232
|
assert_match(/applying.*?rr.*?mock/, out)
|
|
231
233
|
assert_match_in_file(/gem 'rr'/, "#{@apptmp}/sample_project/Gemfile")
|
|
232
234
|
assert_match_in_file(/include RR::Adapters::TestUnit/m, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
233
235
|
end
|
|
234
236
|
|
|
235
237
|
it 'should properly generate for rr and rspec' do
|
|
236
|
-
out,
|
|
238
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec', '--mock=rr', '--script=none') }
|
|
237
239
|
assert_match(/applying.*?rr.*?mock/, out)
|
|
238
|
-
assert_match_in_file(/gem 'rr', :
|
|
240
|
+
assert_match_in_file(/gem 'rr', require: false/, "#{@apptmp}/sample_project/Gemfile")
|
|
239
241
|
assert_match_in_file(/require 'rr'/m, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
|
240
242
|
end
|
|
241
243
|
|
|
242
244
|
it 'should properly generate for mocha and rspec' do
|
|
243
|
-
out,
|
|
245
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec', '--mock=mocha', '--script=none') }
|
|
244
246
|
assert_match(/applying.*?mocha.*?mock/, out)
|
|
245
247
|
assert_match_in_file(/gem 'mocha'/, "#{@apptmp}/sample_project/Gemfile")
|
|
246
248
|
assert_match_in_file(/conf.mock_with :mocha/m, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
|
247
249
|
end
|
|
248
250
|
end
|
|
249
251
|
|
|
250
|
-
describe
|
|
252
|
+
describe 'the generator for HTTP server' do
|
|
251
253
|
it 'should properly generate for webrick by default' do
|
|
252
|
-
|
|
254
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
|
253
255
|
assert_match_in_file(/# Server requirements\ngem 'webrick'\n/, "#{@apptmp}/sample_project/Gemfile")
|
|
254
256
|
end
|
|
255
257
|
|
|
256
258
|
it 'should properly generate for puma' do
|
|
257
|
-
|
|
259
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--server=puma') }
|
|
258
260
|
assert_match_in_file(/# Server requirements\ngem 'puma'\n/, "#{@apptmp}/sample_project/Gemfile")
|
|
259
261
|
end
|
|
260
262
|
|
|
261
263
|
it 'should properly generate for thin' do
|
|
262
|
-
|
|
264
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--server=thin') }
|
|
263
265
|
assert_match_in_file(/# Server requirements\ngem 'thin'\n/, "#{@apptmp}/sample_project/Gemfile")
|
|
264
266
|
end
|
|
265
267
|
|
|
266
268
|
it 'should properly generate for mongrel' do
|
|
267
|
-
|
|
269
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--server=mongrel') }
|
|
268
270
|
assert_match_in_file(/# Server requirements\ngem 'mongrel'\n/, "#{@apptmp}/sample_project/Gemfile")
|
|
269
271
|
end
|
|
270
272
|
|
|
271
273
|
it 'should properly generate for spider-gazelle' do
|
|
272
|
-
|
|
274
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--server=spider-gazelle') }
|
|
273
275
|
assert_match_in_file(/# Server requirements\ngem 'spider-gazelle'\n/, "#{@apptmp}/sample_project/Gemfile")
|
|
274
276
|
end
|
|
275
277
|
|
|
276
278
|
it 'should properly generate for trinidad' do
|
|
277
|
-
|
|
278
|
-
assert_match_in_file(/# Server requirements\ngem 'trinidad', :
|
|
279
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--server=trinidad') }
|
|
280
|
+
assert_match_in_file(/# Server requirements\ngem 'trinidad', platform: 'jruby'\n/, "#{@apptmp}/sample_project/Gemfile")
|
|
279
281
|
end
|
|
280
282
|
end
|
|
281
283
|
|
|
282
|
-
describe
|
|
283
|
-
describe
|
|
284
|
+
describe 'the generator for orm components' do
|
|
285
|
+
describe 'for sequel' do
|
|
284
286
|
it 'should properly generate default' do
|
|
285
|
-
@app.
|
|
286
|
-
out,
|
|
287
|
+
@app.send(:undef, :setup_orm) if @app.respond_to?(:setup_orm)
|
|
288
|
+
out, = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=sequel', '--script=none') }
|
|
287
289
|
assert_match(/applying.*?sequel.*?orm/, out)
|
|
288
290
|
assert_match_in_file(/gem 'sequel'/, "#{@apptmp}/project.com/Gemfile")
|
|
289
291
|
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/project.com/Gemfile")
|
|
290
292
|
assert_match_in_file(/Sequel.connect/, "#{@apptmp}/project.com/config/database.rb")
|
|
291
293
|
assert_match_in_file(%r{sqlite://}, "#{@apptmp}/project.com/config/database.rb")
|
|
292
|
-
assert_match_in_file(
|
|
294
|
+
assert_match_in_file(/project_com/, "#{@apptmp}/project.com/config/database.rb")
|
|
293
295
|
end
|
|
294
296
|
|
|
295
297
|
it 'should properly generate mysql (default to mysql2)' do
|
|
296
|
-
|
|
298
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=mysql') }
|
|
297
299
|
assert_match_in_file(/gem 'mysql2'/, "#{@apptmp}/sample_project/Gemfile")
|
|
298
300
|
assert_match_in_file(%r{"mysql2://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
299
301
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
300
302
|
end
|
|
301
303
|
|
|
302
304
|
it 'should properly generate mysql2' do
|
|
303
|
-
|
|
305
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=mysql2') }
|
|
304
306
|
assert_match_in_file(/gem 'mysql2'/, "#{@apptmp}/sample_project/Gemfile")
|
|
305
307
|
assert_match_in_file(%r{"mysql2://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
306
308
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
307
309
|
end
|
|
308
310
|
|
|
309
311
|
it 'should properly generate mysql-gem' do
|
|
310
|
-
|
|
312
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=mysql-gem') }
|
|
311
313
|
assert_match_in_file(/gem 'mysql'/, "#{@apptmp}/sample_project/Gemfile")
|
|
312
314
|
assert_match_in_file(%r{"mysql://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
313
315
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
314
316
|
end
|
|
315
317
|
|
|
316
318
|
it 'should properly generate sqlite3' do
|
|
317
|
-
|
|
319
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=sqlite') }
|
|
318
320
|
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/sample_project/Gemfile")
|
|
319
321
|
assert_match_in_file(%r{sqlite://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
320
322
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
321
323
|
end
|
|
322
324
|
|
|
323
325
|
it 'should properly generate postgres' do
|
|
324
|
-
|
|
326
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=postgres') }
|
|
325
327
|
assert_match_in_file(/gem 'pg'/, "#{@apptmp}/sample_project/Gemfile")
|
|
326
328
|
assert_match_in_file(%r{"postgres://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
327
329
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
328
330
|
end
|
|
329
331
|
end
|
|
330
332
|
|
|
331
|
-
describe
|
|
333
|
+
describe 'for activerecord' do
|
|
332
334
|
it 'should properly generate default' do
|
|
333
|
-
out,
|
|
335
|
+
out, = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=activerecord', '--script=none') }
|
|
334
336
|
assert_match(/applying.*?activerecord.*?orm/, out)
|
|
335
|
-
assert_match_in_file(/gem 'activerecord', '>= 3.1', :
|
|
337
|
+
assert_match_in_file(/gem 'activerecord', '>= 3.1', require: 'active_record'/, "#{@apptmp}/project.com/Gemfile")
|
|
336
338
|
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/project.com/Gemfile")
|
|
337
339
|
assert_match_in_file(/ActiveRecord::Base.establish_connection/, "#{@apptmp}/project.com/config/database.rb")
|
|
338
340
|
assert_match_in_file(/project_com/, "#{@apptmp}/project.com/config/database.rb")
|
|
339
341
|
end
|
|
340
342
|
|
|
341
343
|
it 'should properly generate mysql (default to mysql2)' do
|
|
342
|
-
|
|
344
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=mysql') }
|
|
343
345
|
assert_match_in_file(/gem 'mysql2'/, "#{@apptmp}/sample_project/Gemfile")
|
|
344
346
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
345
|
-
assert_match_in_file(
|
|
347
|
+
assert_match_in_file(/adapter: 'mysql2'/, "#{@apptmp}/sample_project/config/database.rb")
|
|
346
348
|
end
|
|
347
349
|
|
|
348
350
|
it 'should properly generate mysql2' do
|
|
349
|
-
|
|
351
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=mysql2') }
|
|
350
352
|
assert_match_in_file(/gem 'mysql2'/, "#{@apptmp}/sample_project/Gemfile")
|
|
351
353
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
352
|
-
assert_match_in_file(
|
|
354
|
+
assert_match_in_file(/adapter: 'mysql2'/, "#{@apptmp}/sample_project/config/database.rb")
|
|
353
355
|
end
|
|
354
356
|
|
|
355
357
|
it 'should properly generate mysql-gem' do
|
|
356
|
-
|
|
358
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=mysql-gem') }
|
|
357
359
|
assert_match_in_file(/gem 'mysql', '~> 2.8.1'/, "#{@apptmp}/sample_project/Gemfile")
|
|
358
360
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
359
|
-
assert_match_in_file(
|
|
361
|
+
assert_match_in_file(/adapter: 'mysql'/, "#{@apptmp}/sample_project/config/database.rb")
|
|
360
362
|
end
|
|
361
363
|
|
|
362
364
|
it 'should properly generate sqlite3' do
|
|
363
|
-
|
|
365
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=sqlite') }
|
|
364
366
|
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/sample_project/Gemfile")
|
|
365
367
|
assert_match_in_file(/sample_project_development.db/, "#{@apptmp}/sample_project/config/database.rb")
|
|
366
|
-
assert_match_in_file(
|
|
368
|
+
assert_match_in_file(/adapter: 'sqlite3'/, "#{@apptmp}/sample_project/config/database.rb")
|
|
367
369
|
end
|
|
368
370
|
|
|
369
371
|
it 'should properly generate postgres' do
|
|
370
|
-
|
|
372
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=postgres') }
|
|
371
373
|
assert_match_in_file(/gem 'pg'$/, "#{@apptmp}/sample_project/Gemfile")
|
|
372
374
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
373
|
-
assert_match_in_file(
|
|
375
|
+
assert_match_in_file(/adapter: 'postgresql'/, "#{@apptmp}/sample_project/config/database.rb")
|
|
374
376
|
end
|
|
375
377
|
end
|
|
376
378
|
|
|
377
|
-
describe
|
|
379
|
+
describe 'for datamapper' do
|
|
378
380
|
it 'should properly generate default' do
|
|
379
|
-
out,
|
|
381
|
+
out, = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=datamapper', '--script=none') }
|
|
380
382
|
assert_match(/applying.*?datamapper.*?orm/, out)
|
|
381
383
|
assert_match_in_file(/gem 'dm-core'/, "#{@apptmp}/project.com/Gemfile")
|
|
382
384
|
assert_match_in_file(/gem 'dm-sqlite-adapter'/, "#{@apptmp}/project.com/Gemfile")
|
|
@@ -385,7 +387,7 @@ describe "ProjectGenerator" do
|
|
|
385
387
|
end
|
|
386
388
|
|
|
387
389
|
it 'should properly generate for mysql' do
|
|
388
|
-
|
|
390
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=datamapper', '--adapter=mysql') }
|
|
389
391
|
assert_match_in_file(/gem 'dm-mysql-adapter'/, "#{@apptmp}/sample_project/Gemfile")
|
|
390
392
|
assert_match_in_file(%r{"mysql://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
391
393
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
@@ -393,20 +395,20 @@ describe "ProjectGenerator" do
|
|
|
393
395
|
|
|
394
396
|
# DataMapper has do_mysql that is the version of MySQL driver.
|
|
395
397
|
it 'should properly generate for mysql2' do
|
|
396
|
-
|
|
398
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=datamapper', '--adapter=mysql2') }
|
|
397
399
|
assert_match_in_file(/gem 'dm-mysql-adapter'/, "#{@apptmp}/sample_project/Gemfile")
|
|
398
400
|
assert_match_in_file(%r{"mysql://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
399
401
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
400
402
|
end
|
|
401
403
|
|
|
402
404
|
it 'should properly generate for sqlite' do
|
|
403
|
-
|
|
405
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=datamapper', '--adapter=sqlite') }
|
|
404
406
|
assert_match_in_file(/gem 'dm-sqlite-adapter'/, "#{@apptmp}/sample_project/Gemfile")
|
|
405
407
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
406
408
|
end
|
|
407
409
|
|
|
408
410
|
it 'should properly generate for postgres' do
|
|
409
|
-
|
|
411
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=datamapper', '--adapter=postgres') }
|
|
410
412
|
assert_match_in_file(/gem 'dm-postgres-adapter'/, "#{@apptmp}/sample_project/Gemfile")
|
|
411
413
|
assert_match_in_file(%r{"postgres://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
412
414
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
@@ -414,7 +416,7 @@ describe "ProjectGenerator" do
|
|
|
414
416
|
end
|
|
415
417
|
|
|
416
418
|
it 'should properly generate for mongomapper' do
|
|
417
|
-
out,
|
|
419
|
+
out, = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=mongomapper', '--script=none') }
|
|
418
420
|
assert_match(/applying.*?mongomapper.*?orm/, out)
|
|
419
421
|
assert_match_in_file(/gem 'mongo_mapper'/, "#{@apptmp}/project.com/Gemfile")
|
|
420
422
|
assert_match_in_file(/gem 'bson_ext'/, "#{@apptmp}/project.com/Gemfile")
|
|
@@ -423,14 +425,14 @@ describe "ProjectGenerator" do
|
|
|
423
425
|
end
|
|
424
426
|
|
|
425
427
|
it 'should properly generate for mongoid' do
|
|
426
|
-
out,
|
|
428
|
+
out, = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=mongoid', '--script=none') }
|
|
427
429
|
assert_match(/applying.*?mongoid.*?orm/, out)
|
|
428
430
|
assert_match_in_file(/gem 'mongoid'/, "#{@apptmp}/project.com/Gemfile")
|
|
429
431
|
assert_match_in_file(/Mongoid::Config.sessions =/, "#{@apptmp}/project.com/config/database.rb")
|
|
430
432
|
end
|
|
431
433
|
|
|
432
434
|
it 'should properly generate for couchrest' do
|
|
433
|
-
out,
|
|
435
|
+
out, = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=couchrest', '--script=none') }
|
|
434
436
|
assert_match(/applying.*?couchrest.*?orm/, out)
|
|
435
437
|
assert_match_in_file(/gem 'couchrest_model'/, "#{@apptmp}/project.com/Gemfile")
|
|
436
438
|
assert_match_in_file(/CouchRest.database!/, "#{@apptmp}/project.com/config/database.rb")
|
|
@@ -438,14 +440,14 @@ describe "ProjectGenerator" do
|
|
|
438
440
|
end
|
|
439
441
|
|
|
440
442
|
it 'should properly generate for ohm' do
|
|
441
|
-
out,
|
|
443
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=ohm', '--script=none') }
|
|
442
444
|
assert_match(/applying.*?ohm.*?orm/, out)
|
|
443
445
|
assert_match_in_file(/gem 'ohm'/, "#{@apptmp}/sample_project/Gemfile")
|
|
444
446
|
assert_match_in_file(/Ohm.connect/, "#{@apptmp}/sample_project/config/database.rb")
|
|
445
447
|
end
|
|
446
448
|
|
|
447
449
|
it 'should properly generate for mongomatic' do
|
|
448
|
-
out,
|
|
450
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=mongomatic', '--script=none') }
|
|
449
451
|
assert_match(/applying.*?mongomatic.*?orm/, out)
|
|
450
452
|
assert_match_in_file(/gem 'bson_ext'/, "#{@apptmp}/sample_project/Gemfile")
|
|
451
453
|
assert_match_in_file(/gem 'mongomatic'/, "#{@apptmp}/sample_project/Gemfile")
|
|
@@ -453,7 +455,7 @@ describe "ProjectGenerator" do
|
|
|
453
455
|
end
|
|
454
456
|
|
|
455
457
|
it 'should properly generate for ripple' do
|
|
456
|
-
out,
|
|
458
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=ripple', '--script=none') }
|
|
457
459
|
assert_match(/applying.*?ripple.*?orm/, out)
|
|
458
460
|
assert_match_in_file(/gem 'ripple'/, "#{@apptmp}/sample_project/Gemfile")
|
|
459
461
|
assert_match_in_file(/Ripple.load_configuration/, "#{@apptmp}/sample_project/config/database.rb")
|
|
@@ -461,7 +463,7 @@ describe "ProjectGenerator" do
|
|
|
461
463
|
end
|
|
462
464
|
|
|
463
465
|
it 'should properly generate for dynamoid' do
|
|
464
|
-
out,
|
|
466
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=dynamoid', '--script=none') }
|
|
465
467
|
assert_match(/applying.*?dynamoid.*?orm/, out)
|
|
466
468
|
assert_match_in_file(/gem 'aws-sdk'/, "#{@apptmp}/sample_project/Gemfile")
|
|
467
469
|
assert_match_in_file(/gem 'dynamoid', '~>0.7.1'/, "#{@apptmp}/sample_project/Gemfile")
|
|
@@ -470,35 +472,35 @@ describe "ProjectGenerator" do
|
|
|
470
472
|
end
|
|
471
473
|
end
|
|
472
474
|
|
|
473
|
-
describe
|
|
475
|
+
describe 'the generator for renderer component' do
|
|
474
476
|
it 'should properly generate for erb' do
|
|
475
|
-
out,
|
|
477
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=erb', '--script=none') }
|
|
476
478
|
assert_match(/applying.*?erb.*?renderer/, out)
|
|
477
479
|
assert_match_in_file(/gem 'erubi'/, "#{@apptmp}/sample_project/Gemfile")
|
|
478
480
|
end
|
|
479
481
|
|
|
480
482
|
it 'should properly generate for haml' do
|
|
481
|
-
out,
|
|
483
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml', '--script=none') }
|
|
482
484
|
assert_match(/applying.*?haml.*?renderer/, out)
|
|
483
485
|
assert_match_in_file(/gem 'haml'/, "#{@apptmp}/sample_project/Gemfile")
|
|
484
486
|
end
|
|
485
487
|
|
|
486
488
|
it 'should properly generate for liquid' do
|
|
487
|
-
out,
|
|
489
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=liquid', '--script=none') }
|
|
488
490
|
assert_match(/applying.*?liquid.*?renderer/, out)
|
|
489
491
|
assert_match_in_file(/gem 'liquid'/, "#{@apptmp}/sample_project/Gemfile")
|
|
490
492
|
end
|
|
491
493
|
|
|
492
494
|
it 'should properly generate for slim' do
|
|
493
|
-
out,
|
|
495
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=slim', '--script=none') }
|
|
494
496
|
assert_match(/applying.*?slim.*?renderer/, out)
|
|
495
497
|
assert_match_in_file(/gem 'slim'/, "#{@apptmp}/sample_project/Gemfile")
|
|
496
498
|
end
|
|
497
499
|
end
|
|
498
500
|
|
|
499
|
-
describe
|
|
501
|
+
describe 'the generator for script component' do
|
|
500
502
|
it 'should properly generate for jquery' do
|
|
501
|
-
out,
|
|
503
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=jquery') }
|
|
502
504
|
assert_match(/applying.*?jquery.*?script/, out)
|
|
503
505
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/jquery.js")
|
|
504
506
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/jquery-ujs.js")
|
|
@@ -506,7 +508,7 @@ describe "ProjectGenerator" do
|
|
|
506
508
|
end
|
|
507
509
|
|
|
508
510
|
it 'should properly generate for mootools' do
|
|
509
|
-
out,
|
|
511
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=mootools') }
|
|
510
512
|
assert_match(/applying.*?mootools.*?script/, out)
|
|
511
513
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/mootools.js")
|
|
512
514
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/mootools-ujs.js")
|
|
@@ -514,7 +516,7 @@ describe "ProjectGenerator" do
|
|
|
514
516
|
end
|
|
515
517
|
|
|
516
518
|
it 'should properly generate for prototype' do
|
|
517
|
-
out,
|
|
519
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=prototype') }
|
|
518
520
|
assert_match(/applying.*?prototype.*?script/, out)
|
|
519
521
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/protopak.js")
|
|
520
522
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/lowpro.js")
|
|
@@ -523,7 +525,7 @@ describe "ProjectGenerator" do
|
|
|
523
525
|
end
|
|
524
526
|
|
|
525
527
|
it 'should properly generate for ext-core' do
|
|
526
|
-
out,
|
|
528
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=extcore') }
|
|
527
529
|
assert_match(/applying.*?extcore.*?script/, out)
|
|
528
530
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/ext.js")
|
|
529
531
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/ext-ujs.js")
|
|
@@ -531,7 +533,7 @@ describe "ProjectGenerator" do
|
|
|
531
533
|
end
|
|
532
534
|
|
|
533
535
|
it 'should properly generate for dojo' do
|
|
534
|
-
out,
|
|
536
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=dojo') }
|
|
535
537
|
assert_match(/applying.*?dojo.*?script/, out)
|
|
536
538
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/dojo.js")
|
|
537
539
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/dojo-ujs.js")
|
|
@@ -539,71 +541,71 @@ describe "ProjectGenerator" do
|
|
|
539
541
|
end
|
|
540
542
|
end
|
|
541
543
|
|
|
542
|
-
describe
|
|
544
|
+
describe 'the generator for test component' do
|
|
543
545
|
it 'should properly generate for bacon' do
|
|
544
|
-
out,
|
|
546
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=bacon', '--script=none') }
|
|
545
547
|
assert_match(/applying.*?bacon.*?test/, out)
|
|
546
548
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
547
|
-
assert_match_in_file(
|
|
548
|
-
assert_match_in_file(
|
|
549
|
+
assert_match_in_file(%r{require: 'rack/test'}, "#{@apptmp}/sample_project/Gemfile")
|
|
550
|
+
assert_match_in_file(/group: 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
549
551
|
assert_match_in_file(/gem 'bacon'/, "#{@apptmp}/sample_project/Gemfile")
|
|
550
552
|
assert_match_in_file(/Bacon::Context/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
551
553
|
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
552
554
|
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
|
553
|
-
assert_match_in_file(/Rake::TestTask.new\("test:\#/,"#{@apptmp}/sample_project/test/test.rake")
|
|
554
|
-
assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake")
|
|
555
|
+
assert_match_in_file(/Rake::TestTask.new\("test:\#/, "#{@apptmp}/sample_project/test/test.rake")
|
|
556
|
+
assert_match_in_file(/task 'test' => test_tasks/, "#{@apptmp}/sample_project/test/test.rake")
|
|
555
557
|
end
|
|
556
558
|
|
|
557
559
|
it 'should properly generate for rspec' do
|
|
558
|
-
out,
|
|
560
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec', '--script=none') }
|
|
559
561
|
assert_match(/applying.*?rspec.*?test/, out)
|
|
560
562
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
561
|
-
assert_match_in_file(
|
|
562
|
-
assert_match_in_file(
|
|
563
|
+
assert_match_in_file(%r{require: 'rack/test'}, "#{@apptmp}/sample_project/Gemfile")
|
|
564
|
+
assert_match_in_file(/group: 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
563
565
|
assert_match_in_file(/gem 'rspec'/, "#{@apptmp}/sample_project/Gemfile")
|
|
564
566
|
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
|
565
567
|
assert_match_in_file(/RSpec.configure/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
|
566
568
|
assert_file_exists("#{@apptmp}/sample_project/spec/spec.rake")
|
|
567
|
-
assert_match_in_file(/RSpec::Core::RakeTask\.new\("spec:\#/,"#{@apptmp}/sample_project/spec/spec.rake")
|
|
568
|
-
assert_match_in_file(/task 'spec' => spec_tasks/,"#{@apptmp}/sample_project/spec/spec.rake")
|
|
569
|
+
assert_match_in_file(/RSpec::Core::RakeTask\.new\("spec:\#/, "#{@apptmp}/sample_project/spec/spec.rake")
|
|
570
|
+
assert_match_in_file(/task 'spec' => spec_tasks/, "#{@apptmp}/sample_project/spec/spec.rake")
|
|
569
571
|
end
|
|
570
572
|
|
|
571
573
|
it 'should properly generate for shoulda' do
|
|
572
|
-
out,
|
|
574
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=shoulda', '--script=none') }
|
|
573
575
|
assert_match(/applying.*?shoulda.*?test/, out)
|
|
574
576
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
575
|
-
assert_match_in_file(
|
|
576
|
-
assert_match_in_file(
|
|
577
|
+
assert_match_in_file(%r{require: 'rack/test'}, "#{@apptmp}/sample_project/Gemfile")
|
|
578
|
+
assert_match_in_file(/group: 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
577
579
|
assert_match_in_file(/gem 'shoulda'/, "#{@apptmp}/sample_project/Gemfile")
|
|
578
580
|
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
579
581
|
assert_match_in_file(/Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
580
582
|
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
|
581
|
-
assert_match_in_file(/Rake::TestTask\.new\("test:\#/,"#{@apptmp}/sample_project/test/test.rake")
|
|
582
|
-
assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake")
|
|
583
|
+
assert_match_in_file(/Rake::TestTask\.new\("test:\#/, "#{@apptmp}/sample_project/test/test.rake")
|
|
584
|
+
assert_match_in_file(/task 'test' => test_tasks/, "#{@apptmp}/sample_project/test/test.rake")
|
|
583
585
|
end
|
|
584
586
|
|
|
585
587
|
it 'should properly generate for minitest' do
|
|
586
|
-
out,
|
|
588
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=minitest', '--script=none') }
|
|
587
589
|
assert_match(/applying.*?minitest.*?test/, out)
|
|
588
590
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
589
|
-
assert_match_in_file(
|
|
590
|
-
assert_match_in_file(
|
|
591
|
+
assert_match_in_file(%r{require: 'rack/test'}, "#{@apptmp}/sample_project/Gemfile")
|
|
592
|
+
assert_match_in_file(/group: 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
591
593
|
assert_match_in_file(/gem 'minitest'/, "#{@apptmp}/sample_project/Gemfile")
|
|
592
594
|
assert_match_in_file(/include Rack::Test::Methods/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
593
595
|
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
594
596
|
assert_match_in_file(/Minitest::Spec/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
595
597
|
assert_match_in_file(/SampleProject::App\.tap/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
596
598
|
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
|
597
|
-
assert_match_in_file(/Rake::TestTask\.new\("test:\#/,"#{@apptmp}/sample_project/test/test.rake")
|
|
598
|
-
assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake")
|
|
599
|
+
assert_match_in_file(/Rake::TestTask\.new\("test:\#/, "#{@apptmp}/sample_project/test/test.rake")
|
|
600
|
+
assert_match_in_file(/task 'test' => test_tasks/, "#{@apptmp}/sample_project/test/test.rake")
|
|
599
601
|
end # minitest
|
|
600
602
|
|
|
601
603
|
it 'should properly generate for cucumber' do
|
|
602
|
-
out,
|
|
604
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=cucumber', '--script=none') }
|
|
603
605
|
assert_match(/applying.*?cucumber.*?test/, out)
|
|
604
606
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
605
|
-
assert_match_in_file(
|
|
606
|
-
assert_match_in_file(
|
|
607
|
+
assert_match_in_file(%r{require: 'rack/test'}, "#{@apptmp}/sample_project/Gemfile")
|
|
608
|
+
assert_match_in_file(/group: 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
607
609
|
assert_match_in_file(/gem 'rspec'/, "#{@apptmp}/sample_project/Gemfile")
|
|
608
610
|
assert_match_in_file(/gem 'cucumber'/, "#{@apptmp}/sample_project/Gemfile")
|
|
609
611
|
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
|
@@ -613,17 +615,17 @@ describe "ProjectGenerator" do
|
|
|
613
615
|
assert_match_in_file(/Capybara.app = /, "#{@apptmp}/sample_project/features/support/env.rb")
|
|
614
616
|
assert_match_in_file(/World\(Cucumber::Web::URLs\)/, "#{@apptmp}/sample_project/features/support/url.rb")
|
|
615
617
|
assert_file_exists("#{@apptmp}/sample_project/spec/spec.rake")
|
|
616
|
-
assert_match_in_file(/RSpec::Core::RakeTask\.new\("spec:\#/,"#{@apptmp}/sample_project/spec/spec.rake")
|
|
617
|
-
assert_match_in_file(/task 'spec' => spec_tasks/,"#{@apptmp}/sample_project/spec/spec.rake")
|
|
618
|
+
assert_match_in_file(/RSpec::Core::RakeTask\.new\("spec:\#/, "#{@apptmp}/sample_project/spec/spec.rake")
|
|
619
|
+
assert_match_in_file(/task 'spec' => spec_tasks/, "#{@apptmp}/sample_project/spec/spec.rake")
|
|
618
620
|
assert_file_exists("#{@apptmp}/sample_project/features/support/env.rb")
|
|
619
621
|
assert_file_exists("#{@apptmp}/sample_project/features/add.feature")
|
|
620
622
|
assert_file_exists("#{@apptmp}/sample_project/features/step_definitions/add_steps.rb")
|
|
621
623
|
end
|
|
622
624
|
end
|
|
623
625
|
|
|
624
|
-
describe
|
|
626
|
+
describe 'the generator for stylesheet component' do
|
|
625
627
|
it 'should properly generate for sass' do
|
|
626
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=sass') }
|
|
628
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml', '--script=none', '--stylesheet=sass') }
|
|
627
629
|
assert_match_in_file(/gem 'sass'/, "#{@apptmp}/sample_project/Gemfile")
|
|
628
630
|
assert_match_in_file(/module SassInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/config/initializers/sass.rb")
|
|
629
631
|
assert_match_in_file(/register SassInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
|
@@ -631,7 +633,7 @@ describe "ProjectGenerator" do
|
|
|
631
633
|
end
|
|
632
634
|
|
|
633
635
|
it 'should properly generate for less' do
|
|
634
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=less') }
|
|
636
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml', '--script=none', '--stylesheet=less') }
|
|
635
637
|
assert_match_in_file(/gem 'rack-less'/, "#{@apptmp}/sample_project/Gemfile")
|
|
636
638
|
assert_match_in_file(/module LessInitializer.*Rack::Less/m, "#{@apptmp}/sample_project/config/initializers/less.rb")
|
|
637
639
|
assert_match_in_file(/register LessInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
|
@@ -639,9 +641,9 @@ describe "ProjectGenerator" do
|
|
|
639
641
|
end
|
|
640
642
|
|
|
641
643
|
it 'should properly generate for compass' do
|
|
642
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=compass') }
|
|
644
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml', '--script=none', '--stylesheet=compass') }
|
|
643
645
|
assert_match_in_file(/gem 'compass-blueprint'/, "#{@apptmp}/sample_project/Gemfile")
|
|
644
|
-
assert_match_in_file(/Compass.configure_sass_plugin
|
|
646
|
+
assert_match_in_file(/Compass.configure_sass_plugin!/, "#{@apptmp}/sample_project/config/initializers/compass.rb")
|
|
645
647
|
assert_match_in_file(/module CompassInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/config/initializers/compass.rb")
|
|
646
648
|
assert_match_in_file(/register CompassInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
|
647
649
|
|
|
@@ -650,7 +652,7 @@ describe "ProjectGenerator" do
|
|
|
650
652
|
end
|
|
651
653
|
|
|
652
654
|
it 'should properly generate for scss' do
|
|
653
|
-
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml','--script=none','--stylesheet=scss') }
|
|
655
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml', '--script=none', '--stylesheet=scss') }
|
|
654
656
|
assert_match_in_file(/gem 'haml'/, "#{@apptmp}/sample_project/Gemfile")
|
|
655
657
|
assert_match_in_file(/module ScssInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/config/initializers/scss.rb")
|
|
656
658
|
assert_match_in_file(/Sass::Plugin.options\[:syntax\] = :scss/m, "#{@apptmp}/sample_project/config/initializers/scss.rb")
|
|
@@ -659,69 +661,69 @@ describe "ProjectGenerator" do
|
|
|
659
661
|
end
|
|
660
662
|
end
|
|
661
663
|
|
|
662
|
-
describe
|
|
663
|
-
it
|
|
664
|
-
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}",
|
|
664
|
+
describe 'tiny app skeleton generator for test component' do
|
|
665
|
+
it 'should properly generate for rspec' do
|
|
666
|
+
capture_io { generate(:project, 'sample_project', '--tiny', "--root=#{@apptmp}", '--test=rspec') }
|
|
665
667
|
assert_dir_exists("#{@apptmp}/sample_project/spec/")
|
|
666
668
|
assert_file_exists("#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
|
667
669
|
assert_file_exists("#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
|
668
|
-
assert_match_in_file(
|
|
670
|
+
assert_match_in_file(%r{Dir\[File\.expand_path\("#\{__dir__\}/\.\./app/helpers\.rb"\)\]\.each\(&method\(:require\)\)}, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
|
669
671
|
assert_match_in_file(/RSpec\.describe "Controller" do/, "#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
|
670
|
-
assert_match_in_file(
|
|
672
|
+
assert_match_in_file(%r{get "/"}, "#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
|
671
673
|
assert_match_in_file(/RSpec.describe "SampleProject::App::Helper" do/, "#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
|
672
674
|
end
|
|
673
675
|
|
|
674
|
-
it
|
|
675
|
-
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}",
|
|
676
|
+
it 'should properly generate for cucumber' do
|
|
677
|
+
capture_io { generate(:project, 'sample_project', '--tiny', "--root=#{@apptmp}", '--test=cucumber') }
|
|
676
678
|
assert_dir_exists("#{@apptmp}/sample_project/spec/")
|
|
677
679
|
assert_file_exists("#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
|
678
680
|
assert_file_exists("#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
|
679
|
-
assert_match_in_file(
|
|
681
|
+
assert_match_in_file(%r{Dir\[File\.expand_path\("#\{__dir__\}/\.\./app/helpers\.rb"\)\]\.each\(&method\(:require\)\)}, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
|
680
682
|
assert_match_in_file(/describe "Controller" do/, "#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
|
681
683
|
assert_match_in_file(/describe "SampleProject::App::Helper" do/, "#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
|
682
684
|
end
|
|
683
685
|
|
|
684
|
-
it
|
|
685
|
-
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}",
|
|
686
|
+
it 'should properly generate for bacon' do
|
|
687
|
+
capture_io { generate(:project, 'sample_project', '--tiny', "--root=#{@apptmp}", '--test=bacon') }
|
|
686
688
|
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
|
687
689
|
assert_file_exists("#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
|
688
690
|
assert_file_exists("#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
|
689
|
-
assert_match_in_file(
|
|
691
|
+
assert_match_in_file(%r{Dir\[File\.expand_path\("#\{__dir__\}/\.\./app/helpers\.rb"\)\]\.each\(&method\(:require\)\)}, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
690
692
|
assert_match_in_file(/describe "Controller" do/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
|
691
693
|
assert_match_in_file(/describe "SampleProject::App::Helper"/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
|
692
694
|
end
|
|
693
695
|
|
|
694
|
-
it
|
|
695
|
-
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}",
|
|
696
|
+
it 'should properly generate for minitest' do
|
|
697
|
+
capture_io { generate(:project, 'sample_project', '--tiny', "--root=#{@apptmp}", '--test=minitest') }
|
|
696
698
|
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
|
697
699
|
assert_file_exists("#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
|
698
700
|
assert_file_exists("#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
|
699
|
-
assert_match_in_file(
|
|
701
|
+
assert_match_in_file(%r{Dir\[File\.expand_path\("#\{__dir__\}/\.\./app/helpers\.rb"\)\]\.each\(&method\(:require\)\)}, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
700
702
|
assert_match_in_file(/describe "Controller" do/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
|
701
703
|
assert_match_in_file(/describe "SampleProject::App::Helper"/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
|
702
704
|
end
|
|
703
705
|
|
|
704
|
-
it
|
|
705
|
-
capture_io { generate(:project,'sample_project', '--tiny', "--root=#{@apptmp}",
|
|
706
|
+
it 'should properly generate for shoulda' do
|
|
707
|
+
capture_io { generate(:project, 'sample_project', '--tiny', "--root=#{@apptmp}", '--test=shoulda') }
|
|
706
708
|
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
|
707
709
|
assert_file_exists("#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
|
708
710
|
assert_file_exists("#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
|
709
|
-
assert_match_in_file(
|
|
711
|
+
assert_match_in_file(%r{Dir\[File\.expand_path\("#\{__dir__\}/\.\./app/helpers\.rb"\)\]\.each\(&method\(:require\)\)}, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
710
712
|
assert_match_in_file(/class ControllerTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
|
711
713
|
assert_match_in_file(/class SampleProject::App::HelperTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
|
712
714
|
end
|
|
713
715
|
|
|
714
|
-
it
|
|
715
|
-
out,
|
|
716
|
+
it 'should properly generate for testunit' do
|
|
717
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=testunit', '--script=none', '--tiny') }
|
|
716
718
|
assert_match(/applying.*?testunit.*?test/, out)
|
|
717
719
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
718
|
-
assert_match_in_file(
|
|
719
|
-
assert_match_in_file(
|
|
720
|
+
assert_match_in_file(%r{require: 'rack/test'}, "#{@apptmp}/sample_project/Gemfile")
|
|
721
|
+
assert_match_in_file(/group: 'test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
720
722
|
assert_match_in_file(/gem 'test-unit'/, "#{@apptmp}/sample_project/Gemfile")
|
|
721
723
|
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
722
724
|
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
|
723
|
-
assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake")
|
|
724
|
-
assert_match_in_file(
|
|
725
|
+
assert_match_in_file(/task 'test' => test_tasks/, "#{@apptmp}/sample_project/test/test.rake")
|
|
726
|
+
assert_match_in_file(%r{Dir\[File\.expand_path\("#\{__dir__\}/\.\./app/helpers\.rb"\)\]\.each\(&method\(:require\)\)}, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
725
727
|
assert_match_in_file(/class ControllerTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
|
726
728
|
assert_match_in_file(/class SampleProject::App::HelperTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
|
727
729
|
end
|