padrino-gen 0.16.0.pre3 → 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 -50
- 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 +9 -6
- 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 +194 -163
- 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,147 +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
|
|
253
|
+
it 'should properly generate for webrick by default' do
|
|
254
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
|
|
255
|
+
assert_match_in_file(/# Server requirements\ngem 'webrick'\n/, "#{@apptmp}/sample_project/Gemfile")
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
it 'should properly generate for puma' do
|
|
259
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--server=puma') }
|
|
260
|
+
assert_match_in_file(/# Server requirements\ngem 'puma'\n/, "#{@apptmp}/sample_project/Gemfile")
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
it 'should properly generate for thin' do
|
|
264
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--server=thin') }
|
|
265
|
+
assert_match_in_file(/# Server requirements\ngem 'thin'\n/, "#{@apptmp}/sample_project/Gemfile")
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
it 'should properly generate for mongrel' do
|
|
269
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--server=mongrel') }
|
|
270
|
+
assert_match_in_file(/# Server requirements\ngem 'mongrel'\n/, "#{@apptmp}/sample_project/Gemfile")
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
it 'should properly generate for spider-gazelle' do
|
|
274
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--server=spider-gazelle') }
|
|
275
|
+
assert_match_in_file(/# Server requirements\ngem 'spider-gazelle'\n/, "#{@apptmp}/sample_project/Gemfile")
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
it 'should properly generate for trinidad' do
|
|
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")
|
|
281
|
+
end
|
|
282
|
+
end
|
|
251
283
|
|
|
252
|
-
|
|
284
|
+
describe 'the generator for orm components' do
|
|
285
|
+
describe 'for sequel' do
|
|
253
286
|
it 'should properly generate default' do
|
|
254
|
-
@app.
|
|
255
|
-
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') }
|
|
256
289
|
assert_match(/applying.*?sequel.*?orm/, out)
|
|
257
290
|
assert_match_in_file(/gem 'sequel'/, "#{@apptmp}/project.com/Gemfile")
|
|
258
291
|
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/project.com/Gemfile")
|
|
259
292
|
assert_match_in_file(/Sequel.connect/, "#{@apptmp}/project.com/config/database.rb")
|
|
260
293
|
assert_match_in_file(%r{sqlite://}, "#{@apptmp}/project.com/config/database.rb")
|
|
261
|
-
assert_match_in_file(
|
|
294
|
+
assert_match_in_file(/project_com/, "#{@apptmp}/project.com/config/database.rb")
|
|
262
295
|
end
|
|
263
296
|
|
|
264
297
|
it 'should properly generate mysql (default to mysql2)' do
|
|
265
|
-
|
|
298
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=mysql') }
|
|
266
299
|
assert_match_in_file(/gem 'mysql2'/, "#{@apptmp}/sample_project/Gemfile")
|
|
267
300
|
assert_match_in_file(%r{"mysql2://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
268
301
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
269
302
|
end
|
|
270
303
|
|
|
271
304
|
it 'should properly generate mysql2' do
|
|
272
|
-
|
|
305
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=mysql2') }
|
|
273
306
|
assert_match_in_file(/gem 'mysql2'/, "#{@apptmp}/sample_project/Gemfile")
|
|
274
307
|
assert_match_in_file(%r{"mysql2://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
275
308
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
276
309
|
end
|
|
277
310
|
|
|
278
311
|
it 'should properly generate mysql-gem' do
|
|
279
|
-
|
|
312
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=mysql-gem') }
|
|
280
313
|
assert_match_in_file(/gem 'mysql'/, "#{@apptmp}/sample_project/Gemfile")
|
|
281
314
|
assert_match_in_file(%r{"mysql://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
282
315
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
283
316
|
end
|
|
284
317
|
|
|
285
318
|
it 'should properly generate sqlite3' do
|
|
286
|
-
|
|
319
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=sqlite') }
|
|
287
320
|
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/sample_project/Gemfile")
|
|
288
321
|
assert_match_in_file(%r{sqlite://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
289
322
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
290
323
|
end
|
|
291
324
|
|
|
292
325
|
it 'should properly generate postgres' do
|
|
293
|
-
|
|
326
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=sequel', '--adapter=postgres') }
|
|
294
327
|
assert_match_in_file(/gem 'pg'/, "#{@apptmp}/sample_project/Gemfile")
|
|
295
328
|
assert_match_in_file(%r{"postgres://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
296
329
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
297
330
|
end
|
|
298
331
|
end
|
|
299
332
|
|
|
300
|
-
describe
|
|
333
|
+
describe 'for activerecord' do
|
|
301
334
|
it 'should properly generate default' do
|
|
302
|
-
out,
|
|
335
|
+
out, = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=activerecord', '--script=none') }
|
|
303
336
|
assert_match(/applying.*?activerecord.*?orm/, out)
|
|
304
|
-
assert_match_in_file(/gem 'activerecord', '>= 3.1', :
|
|
337
|
+
assert_match_in_file(/gem 'activerecord', '>= 3.1', require: 'active_record'/, "#{@apptmp}/project.com/Gemfile")
|
|
305
338
|
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/project.com/Gemfile")
|
|
306
339
|
assert_match_in_file(/ActiveRecord::Base.establish_connection/, "#{@apptmp}/project.com/config/database.rb")
|
|
307
340
|
assert_match_in_file(/project_com/, "#{@apptmp}/project.com/config/database.rb")
|
|
308
341
|
end
|
|
309
342
|
|
|
310
343
|
it 'should properly generate mysql (default to mysql2)' do
|
|
311
|
-
|
|
344
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=mysql') }
|
|
312
345
|
assert_match_in_file(/gem 'mysql2'/, "#{@apptmp}/sample_project/Gemfile")
|
|
313
346
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
314
|
-
assert_match_in_file(
|
|
347
|
+
assert_match_in_file(/adapter: 'mysql2'/, "#{@apptmp}/sample_project/config/database.rb")
|
|
315
348
|
end
|
|
316
349
|
|
|
317
350
|
it 'should properly generate mysql2' do
|
|
318
|
-
|
|
351
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=mysql2') }
|
|
319
352
|
assert_match_in_file(/gem 'mysql2'/, "#{@apptmp}/sample_project/Gemfile")
|
|
320
353
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
321
|
-
assert_match_in_file(
|
|
354
|
+
assert_match_in_file(/adapter: 'mysql2'/, "#{@apptmp}/sample_project/config/database.rb")
|
|
322
355
|
end
|
|
323
356
|
|
|
324
357
|
it 'should properly generate mysql-gem' do
|
|
325
|
-
|
|
358
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=mysql-gem') }
|
|
326
359
|
assert_match_in_file(/gem 'mysql', '~> 2.8.1'/, "#{@apptmp}/sample_project/Gemfile")
|
|
327
360
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
328
|
-
assert_match_in_file(
|
|
361
|
+
assert_match_in_file(/adapter: 'mysql'/, "#{@apptmp}/sample_project/config/database.rb")
|
|
329
362
|
end
|
|
330
363
|
|
|
331
364
|
it 'should properly generate sqlite3' do
|
|
332
|
-
|
|
365
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=sqlite') }
|
|
333
366
|
assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/sample_project/Gemfile")
|
|
334
367
|
assert_match_in_file(/sample_project_development.db/, "#{@apptmp}/sample_project/config/database.rb")
|
|
335
|
-
assert_match_in_file(
|
|
368
|
+
assert_match_in_file(/adapter: 'sqlite3'/, "#{@apptmp}/sample_project/config/database.rb")
|
|
336
369
|
end
|
|
337
370
|
|
|
338
371
|
it 'should properly generate postgres' do
|
|
339
|
-
|
|
372
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=postgres') }
|
|
340
373
|
assert_match_in_file(/gem 'pg'$/, "#{@apptmp}/sample_project/Gemfile")
|
|
341
374
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
342
|
-
assert_match_in_file(
|
|
375
|
+
assert_match_in_file(/adapter: 'postgresql'/, "#{@apptmp}/sample_project/config/database.rb")
|
|
343
376
|
end
|
|
344
377
|
end
|
|
345
378
|
|
|
346
|
-
describe
|
|
379
|
+
describe 'for datamapper' do
|
|
347
380
|
it 'should properly generate default' do
|
|
348
|
-
out,
|
|
381
|
+
out, = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=datamapper', '--script=none') }
|
|
349
382
|
assert_match(/applying.*?datamapper.*?orm/, out)
|
|
350
383
|
assert_match_in_file(/gem 'dm-core'/, "#{@apptmp}/project.com/Gemfile")
|
|
351
384
|
assert_match_in_file(/gem 'dm-sqlite-adapter'/, "#{@apptmp}/project.com/Gemfile")
|
|
@@ -354,7 +387,7 @@ describe "ProjectGenerator" do
|
|
|
354
387
|
end
|
|
355
388
|
|
|
356
389
|
it 'should properly generate for mysql' do
|
|
357
|
-
|
|
390
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=datamapper', '--adapter=mysql') }
|
|
358
391
|
assert_match_in_file(/gem 'dm-mysql-adapter'/, "#{@apptmp}/sample_project/Gemfile")
|
|
359
392
|
assert_match_in_file(%r{"mysql://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
360
393
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
@@ -362,20 +395,20 @@ describe "ProjectGenerator" do
|
|
|
362
395
|
|
|
363
396
|
# DataMapper has do_mysql that is the version of MySQL driver.
|
|
364
397
|
it 'should properly generate for mysql2' do
|
|
365
|
-
|
|
398
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=datamapper', '--adapter=mysql2') }
|
|
366
399
|
assert_match_in_file(/gem 'dm-mysql-adapter'/, "#{@apptmp}/sample_project/Gemfile")
|
|
367
400
|
assert_match_in_file(%r{"mysql://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
368
401
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
369
402
|
end
|
|
370
403
|
|
|
371
404
|
it 'should properly generate for sqlite' do
|
|
372
|
-
|
|
405
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=datamapper', '--adapter=sqlite') }
|
|
373
406
|
assert_match_in_file(/gem 'dm-sqlite-adapter'/, "#{@apptmp}/sample_project/Gemfile")
|
|
374
407
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
375
408
|
end
|
|
376
409
|
|
|
377
410
|
it 'should properly generate for postgres' do
|
|
378
|
-
|
|
411
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=datamapper', '--adapter=postgres') }
|
|
379
412
|
assert_match_in_file(/gem 'dm-postgres-adapter'/, "#{@apptmp}/sample_project/Gemfile")
|
|
380
413
|
assert_match_in_file(%r{"postgres://}, "#{@apptmp}/sample_project/config/database.rb")
|
|
381
414
|
assert_match_in_file(/sample_project_development/, "#{@apptmp}/sample_project/config/database.rb")
|
|
@@ -383,7 +416,7 @@ describe "ProjectGenerator" do
|
|
|
383
416
|
end
|
|
384
417
|
|
|
385
418
|
it 'should properly generate for mongomapper' do
|
|
386
|
-
out,
|
|
419
|
+
out, = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=mongomapper', '--script=none') }
|
|
387
420
|
assert_match(/applying.*?mongomapper.*?orm/, out)
|
|
388
421
|
assert_match_in_file(/gem 'mongo_mapper'/, "#{@apptmp}/project.com/Gemfile")
|
|
389
422
|
assert_match_in_file(/gem 'bson_ext'/, "#{@apptmp}/project.com/Gemfile")
|
|
@@ -392,15 +425,14 @@ describe "ProjectGenerator" do
|
|
|
392
425
|
end
|
|
393
426
|
|
|
394
427
|
it 'should properly generate for mongoid' do
|
|
395
|
-
out,
|
|
428
|
+
out, = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=mongoid', '--script=none') }
|
|
396
429
|
assert_match(/applying.*?mongoid.*?orm/, out)
|
|
397
430
|
assert_match_in_file(/gem 'mongoid'/, "#{@apptmp}/project.com/Gemfile")
|
|
398
431
|
assert_match_in_file(/Mongoid::Config.sessions =/, "#{@apptmp}/project.com/config/database.rb")
|
|
399
432
|
end
|
|
400
433
|
|
|
401
|
-
|
|
402
434
|
it 'should properly generate for couchrest' do
|
|
403
|
-
out,
|
|
435
|
+
out, = capture_io { generate(:project, 'project.com', "--root=#{@apptmp}", '--orm=couchrest', '--script=none') }
|
|
404
436
|
assert_match(/applying.*?couchrest.*?orm/, out)
|
|
405
437
|
assert_match_in_file(/gem 'couchrest_model'/, "#{@apptmp}/project.com/Gemfile")
|
|
406
438
|
assert_match_in_file(/CouchRest.database!/, "#{@apptmp}/project.com/config/database.rb")
|
|
@@ -408,14 +440,14 @@ describe "ProjectGenerator" do
|
|
|
408
440
|
end
|
|
409
441
|
|
|
410
442
|
it 'should properly generate for ohm' do
|
|
411
|
-
out,
|
|
443
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=ohm', '--script=none') }
|
|
412
444
|
assert_match(/applying.*?ohm.*?orm/, out)
|
|
413
445
|
assert_match_in_file(/gem 'ohm'/, "#{@apptmp}/sample_project/Gemfile")
|
|
414
446
|
assert_match_in_file(/Ohm.connect/, "#{@apptmp}/sample_project/config/database.rb")
|
|
415
447
|
end
|
|
416
448
|
|
|
417
449
|
it 'should properly generate for mongomatic' do
|
|
418
|
-
out,
|
|
450
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=mongomatic', '--script=none') }
|
|
419
451
|
assert_match(/applying.*?mongomatic.*?orm/, out)
|
|
420
452
|
assert_match_in_file(/gem 'bson_ext'/, "#{@apptmp}/sample_project/Gemfile")
|
|
421
453
|
assert_match_in_file(/gem 'mongomatic'/, "#{@apptmp}/sample_project/Gemfile")
|
|
@@ -423,7 +455,7 @@ describe "ProjectGenerator" do
|
|
|
423
455
|
end
|
|
424
456
|
|
|
425
457
|
it 'should properly generate for ripple' do
|
|
426
|
-
out,
|
|
458
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=ripple', '--script=none') }
|
|
427
459
|
assert_match(/applying.*?ripple.*?orm/, out)
|
|
428
460
|
assert_match_in_file(/gem 'ripple'/, "#{@apptmp}/sample_project/Gemfile")
|
|
429
461
|
assert_match_in_file(/Ripple.load_configuration/, "#{@apptmp}/sample_project/config/database.rb")
|
|
@@ -431,7 +463,7 @@ describe "ProjectGenerator" do
|
|
|
431
463
|
end
|
|
432
464
|
|
|
433
465
|
it 'should properly generate for dynamoid' do
|
|
434
|
-
out,
|
|
466
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=dynamoid', '--script=none') }
|
|
435
467
|
assert_match(/applying.*?dynamoid.*?orm/, out)
|
|
436
468
|
assert_match_in_file(/gem 'aws-sdk'/, "#{@apptmp}/sample_project/Gemfile")
|
|
437
469
|
assert_match_in_file(/gem 'dynamoid', '~>0.7.1'/, "#{@apptmp}/sample_project/Gemfile")
|
|
@@ -440,36 +472,35 @@ describe "ProjectGenerator" do
|
|
|
440
472
|
end
|
|
441
473
|
end
|
|
442
474
|
|
|
443
|
-
|
|
444
|
-
describe "the generator for renderer component" do
|
|
475
|
+
describe 'the generator for renderer component' do
|
|
445
476
|
it 'should properly generate for erb' do
|
|
446
|
-
out,
|
|
477
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=erb', '--script=none') }
|
|
447
478
|
assert_match(/applying.*?erb.*?renderer/, out)
|
|
448
479
|
assert_match_in_file(/gem 'erubi'/, "#{@apptmp}/sample_project/Gemfile")
|
|
449
480
|
end
|
|
450
481
|
|
|
451
482
|
it 'should properly generate for haml' do
|
|
452
|
-
out,
|
|
483
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=haml', '--script=none') }
|
|
453
484
|
assert_match(/applying.*?haml.*?renderer/, out)
|
|
454
485
|
assert_match_in_file(/gem 'haml'/, "#{@apptmp}/sample_project/Gemfile")
|
|
455
486
|
end
|
|
456
487
|
|
|
457
488
|
it 'should properly generate for liquid' do
|
|
458
|
-
out,
|
|
489
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=liquid', '--script=none') }
|
|
459
490
|
assert_match(/applying.*?liquid.*?renderer/, out)
|
|
460
491
|
assert_match_in_file(/gem 'liquid'/, "#{@apptmp}/sample_project/Gemfile")
|
|
461
492
|
end
|
|
462
493
|
|
|
463
494
|
it 'should properly generate for slim' do
|
|
464
|
-
out,
|
|
495
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--renderer=slim', '--script=none') }
|
|
465
496
|
assert_match(/applying.*?slim.*?renderer/, out)
|
|
466
497
|
assert_match_in_file(/gem 'slim'/, "#{@apptmp}/sample_project/Gemfile")
|
|
467
498
|
end
|
|
468
499
|
end
|
|
469
500
|
|
|
470
|
-
describe
|
|
501
|
+
describe 'the generator for script component' do
|
|
471
502
|
it 'should properly generate for jquery' do
|
|
472
|
-
out,
|
|
503
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=jquery') }
|
|
473
504
|
assert_match(/applying.*?jquery.*?script/, out)
|
|
474
505
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/jquery.js")
|
|
475
506
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/jquery-ujs.js")
|
|
@@ -477,7 +508,7 @@ describe "ProjectGenerator" do
|
|
|
477
508
|
end
|
|
478
509
|
|
|
479
510
|
it 'should properly generate for mootools' do
|
|
480
|
-
out,
|
|
511
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=mootools') }
|
|
481
512
|
assert_match(/applying.*?mootools.*?script/, out)
|
|
482
513
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/mootools.js")
|
|
483
514
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/mootools-ujs.js")
|
|
@@ -485,7 +516,7 @@ describe "ProjectGenerator" do
|
|
|
485
516
|
end
|
|
486
517
|
|
|
487
518
|
it 'should properly generate for prototype' do
|
|
488
|
-
out,
|
|
519
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=prototype') }
|
|
489
520
|
assert_match(/applying.*?prototype.*?script/, out)
|
|
490
521
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/protopak.js")
|
|
491
522
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/lowpro.js")
|
|
@@ -494,7 +525,7 @@ describe "ProjectGenerator" do
|
|
|
494
525
|
end
|
|
495
526
|
|
|
496
527
|
it 'should properly generate for ext-core' do
|
|
497
|
-
out,
|
|
528
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=extcore') }
|
|
498
529
|
assert_match(/applying.*?extcore.*?script/, out)
|
|
499
530
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/ext.js")
|
|
500
531
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/ext-ujs.js")
|
|
@@ -502,7 +533,7 @@ describe "ProjectGenerator" do
|
|
|
502
533
|
end
|
|
503
534
|
|
|
504
535
|
it 'should properly generate for dojo' do
|
|
505
|
-
out,
|
|
536
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--script=dojo') }
|
|
506
537
|
assert_match(/applying.*?dojo.*?script/, out)
|
|
507
538
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/dojo.js")
|
|
508
539
|
assert_file_exists("#{@apptmp}/sample_project/public/javascripts/dojo-ujs.js")
|
|
@@ -510,71 +541,71 @@ describe "ProjectGenerator" do
|
|
|
510
541
|
end
|
|
511
542
|
end
|
|
512
543
|
|
|
513
|
-
describe
|
|
544
|
+
describe 'the generator for test component' do
|
|
514
545
|
it 'should properly generate for bacon' do
|
|
515
|
-
out,
|
|
546
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=bacon', '--script=none') }
|
|
516
547
|
assert_match(/applying.*?bacon.*?test/, out)
|
|
517
548
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
518
|
-
assert_match_in_file(
|
|
519
|
-
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")
|
|
520
551
|
assert_match_in_file(/gem 'bacon'/, "#{@apptmp}/sample_project/Gemfile")
|
|
521
552
|
assert_match_in_file(/Bacon::Context/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
522
553
|
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
523
554
|
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
|
524
|
-
assert_match_in_file(/Rake::TestTask.new\("test:\#/,"#{@apptmp}/sample_project/test/test.rake")
|
|
525
|
-
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")
|
|
526
557
|
end
|
|
527
558
|
|
|
528
559
|
it 'should properly generate for rspec' do
|
|
529
|
-
out,
|
|
560
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=rspec', '--script=none') }
|
|
530
561
|
assert_match(/applying.*?rspec.*?test/, out)
|
|
531
562
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
532
|
-
assert_match_in_file(
|
|
533
|
-
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")
|
|
534
565
|
assert_match_in_file(/gem 'rspec'/, "#{@apptmp}/sample_project/Gemfile")
|
|
535
566
|
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
|
536
567
|
assert_match_in_file(/RSpec.configure/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
|
537
568
|
assert_file_exists("#{@apptmp}/sample_project/spec/spec.rake")
|
|
538
|
-
assert_match_in_file(/RSpec::Core::RakeTask\.new\("spec:\#/,"#{@apptmp}/sample_project/spec/spec.rake")
|
|
539
|
-
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")
|
|
540
571
|
end
|
|
541
572
|
|
|
542
573
|
it 'should properly generate for shoulda' do
|
|
543
|
-
out,
|
|
574
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=shoulda', '--script=none') }
|
|
544
575
|
assert_match(/applying.*?shoulda.*?test/, out)
|
|
545
576
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
546
|
-
assert_match_in_file(
|
|
547
|
-
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")
|
|
548
579
|
assert_match_in_file(/gem 'shoulda'/, "#{@apptmp}/sample_project/Gemfile")
|
|
549
580
|
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
550
581
|
assert_match_in_file(/Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
551
582
|
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
|
552
|
-
assert_match_in_file(/Rake::TestTask\.new\("test:\#/,"#{@apptmp}/sample_project/test/test.rake")
|
|
553
|
-
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")
|
|
554
585
|
end
|
|
555
586
|
|
|
556
587
|
it 'should properly generate for minitest' do
|
|
557
|
-
out,
|
|
588
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=minitest', '--script=none') }
|
|
558
589
|
assert_match(/applying.*?minitest.*?test/, out)
|
|
559
590
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
560
|
-
assert_match_in_file(
|
|
561
|
-
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")
|
|
562
593
|
assert_match_in_file(/gem 'minitest'/, "#{@apptmp}/sample_project/Gemfile")
|
|
563
594
|
assert_match_in_file(/include Rack::Test::Methods/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
564
595
|
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
565
596
|
assert_match_in_file(/Minitest::Spec/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
566
597
|
assert_match_in_file(/SampleProject::App\.tap/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
567
598
|
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
|
568
|
-
assert_match_in_file(/Rake::TestTask\.new\("test:\#/,"#{@apptmp}/sample_project/test/test.rake")
|
|
569
|
-
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")
|
|
570
601
|
end # minitest
|
|
571
602
|
|
|
572
603
|
it 'should properly generate for cucumber' do
|
|
573
|
-
out,
|
|
604
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=cucumber', '--script=none') }
|
|
574
605
|
assert_match(/applying.*?cucumber.*?test/, out)
|
|
575
606
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
576
|
-
assert_match_in_file(
|
|
577
|
-
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")
|
|
578
609
|
assert_match_in_file(/gem 'rspec'/, "#{@apptmp}/sample_project/Gemfile")
|
|
579
610
|
assert_match_in_file(/gem 'cucumber'/, "#{@apptmp}/sample_project/Gemfile")
|
|
580
611
|
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/spec/spec_helper.rb")
|
|
@@ -584,17 +615,17 @@ describe "ProjectGenerator" do
|
|
|
584
615
|
assert_match_in_file(/Capybara.app = /, "#{@apptmp}/sample_project/features/support/env.rb")
|
|
585
616
|
assert_match_in_file(/World\(Cucumber::Web::URLs\)/, "#{@apptmp}/sample_project/features/support/url.rb")
|
|
586
617
|
assert_file_exists("#{@apptmp}/sample_project/spec/spec.rake")
|
|
587
|
-
assert_match_in_file(/RSpec::Core::RakeTask\.new\("spec:\#/,"#{@apptmp}/sample_project/spec/spec.rake")
|
|
588
|
-
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")
|
|
589
620
|
assert_file_exists("#{@apptmp}/sample_project/features/support/env.rb")
|
|
590
621
|
assert_file_exists("#{@apptmp}/sample_project/features/add.feature")
|
|
591
622
|
assert_file_exists("#{@apptmp}/sample_project/features/step_definitions/add_steps.rb")
|
|
592
623
|
end
|
|
593
624
|
end
|
|
594
625
|
|
|
595
|
-
describe
|
|
626
|
+
describe 'the generator for stylesheet component' do
|
|
596
627
|
it 'should properly generate for sass' do
|
|
597
|
-
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') }
|
|
598
629
|
assert_match_in_file(/gem 'sass'/, "#{@apptmp}/sample_project/Gemfile")
|
|
599
630
|
assert_match_in_file(/module SassInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/config/initializers/sass.rb")
|
|
600
631
|
assert_match_in_file(/register SassInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
|
@@ -602,7 +633,7 @@ describe "ProjectGenerator" do
|
|
|
602
633
|
end
|
|
603
634
|
|
|
604
635
|
it 'should properly generate for less' do
|
|
605
|
-
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') }
|
|
606
637
|
assert_match_in_file(/gem 'rack-less'/, "#{@apptmp}/sample_project/Gemfile")
|
|
607
638
|
assert_match_in_file(/module LessInitializer.*Rack::Less/m, "#{@apptmp}/sample_project/config/initializers/less.rb")
|
|
608
639
|
assert_match_in_file(/register LessInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
|
@@ -610,9 +641,9 @@ describe "ProjectGenerator" do
|
|
|
610
641
|
end
|
|
611
642
|
|
|
612
643
|
it 'should properly generate for compass' do
|
|
613
|
-
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') }
|
|
614
645
|
assert_match_in_file(/gem 'compass-blueprint'/, "#{@apptmp}/sample_project/Gemfile")
|
|
615
|
-
assert_match_in_file(/Compass.configure_sass_plugin
|
|
646
|
+
assert_match_in_file(/Compass.configure_sass_plugin!/, "#{@apptmp}/sample_project/config/initializers/compass.rb")
|
|
616
647
|
assert_match_in_file(/module CompassInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/config/initializers/compass.rb")
|
|
617
648
|
assert_match_in_file(/register CompassInitializer/m, "#{@apptmp}/sample_project/app/app.rb")
|
|
618
649
|
|
|
@@ -621,7 +652,7 @@ describe "ProjectGenerator" do
|
|
|
621
652
|
end
|
|
622
653
|
|
|
623
654
|
it 'should properly generate for scss' do
|
|
624
|
-
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') }
|
|
625
656
|
assert_match_in_file(/gem 'haml'/, "#{@apptmp}/sample_project/Gemfile")
|
|
626
657
|
assert_match_in_file(/module ScssInitializer.*Sass::Plugin::Rack/m, "#{@apptmp}/sample_project/config/initializers/scss.rb")
|
|
627
658
|
assert_match_in_file(/Sass::Plugin.options\[:syntax\] = :scss/m, "#{@apptmp}/sample_project/config/initializers/scss.rb")
|
|
@@ -630,69 +661,69 @@ describe "ProjectGenerator" do
|
|
|
630
661
|
end
|
|
631
662
|
end
|
|
632
663
|
|
|
633
|
-
describe
|
|
634
|
-
it
|
|
635
|
-
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') }
|
|
636
667
|
assert_dir_exists("#{@apptmp}/sample_project/spec/")
|
|
637
668
|
assert_file_exists("#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
|
638
669
|
assert_file_exists("#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
|
639
|
-
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")
|
|
640
671
|
assert_match_in_file(/RSpec\.describe "Controller" do/, "#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
|
641
|
-
assert_match_in_file(
|
|
672
|
+
assert_match_in_file(%r{get "/"}, "#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
|
642
673
|
assert_match_in_file(/RSpec.describe "SampleProject::App::Helper" do/, "#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
|
643
674
|
end
|
|
644
675
|
|
|
645
|
-
it
|
|
646
|
-
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') }
|
|
647
678
|
assert_dir_exists("#{@apptmp}/sample_project/spec/")
|
|
648
679
|
assert_file_exists("#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
|
649
680
|
assert_file_exists("#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
|
650
|
-
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")
|
|
651
682
|
assert_match_in_file(/describe "Controller" do/, "#{@apptmp}/sample_project/spec/app/controllers/controllers_spec.rb")
|
|
652
683
|
assert_match_in_file(/describe "SampleProject::App::Helper" do/, "#{@apptmp}/sample_project/spec/app/helpers/helpers_spec.rb")
|
|
653
684
|
end
|
|
654
685
|
|
|
655
|
-
it
|
|
656
|
-
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') }
|
|
657
688
|
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
|
658
689
|
assert_file_exists("#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
|
659
690
|
assert_file_exists("#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
|
660
|
-
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")
|
|
661
692
|
assert_match_in_file(/describe "Controller" do/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
|
662
693
|
assert_match_in_file(/describe "SampleProject::App::Helper"/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
|
663
694
|
end
|
|
664
695
|
|
|
665
|
-
it
|
|
666
|
-
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') }
|
|
667
698
|
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
|
668
699
|
assert_file_exists("#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
|
669
700
|
assert_file_exists("#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
|
670
|
-
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")
|
|
671
702
|
assert_match_in_file(/describe "Controller" do/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
|
672
703
|
assert_match_in_file(/describe "SampleProject::App::Helper"/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
|
673
704
|
end
|
|
674
705
|
|
|
675
|
-
it
|
|
676
|
-
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') }
|
|
677
708
|
assert_dir_exists("#{@apptmp}/sample_project/test/")
|
|
678
709
|
assert_file_exists("#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
|
679
710
|
assert_file_exists("#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
|
680
|
-
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")
|
|
681
712
|
assert_match_in_file(/class ControllerTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
|
682
713
|
assert_match_in_file(/class SampleProject::App::HelperTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
|
683
714
|
end
|
|
684
715
|
|
|
685
|
-
it
|
|
686
|
-
out,
|
|
716
|
+
it 'should properly generate for testunit' do
|
|
717
|
+
out, = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--test=testunit', '--script=none', '--tiny') }
|
|
687
718
|
assert_match(/applying.*?testunit.*?test/, out)
|
|
688
719
|
assert_match_in_file(/gem 'rack-test'/, "#{@apptmp}/sample_project/Gemfile")
|
|
689
|
-
assert_match_in_file(
|
|
690
|
-
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")
|
|
691
722
|
assert_match_in_file(/gem 'test-unit'/, "#{@apptmp}/sample_project/Gemfile")
|
|
692
723
|
assert_match_in_file(/RACK_ENV = 'test' unless defined\?\(RACK_ENV\)/, "#{@apptmp}/sample_project/test/test_config.rb")
|
|
693
724
|
assert_file_exists("#{@apptmp}/sample_project/test/test.rake")
|
|
694
|
-
assert_match_in_file(/task 'test' => test_tasks/,"#{@apptmp}/sample_project/test/test.rake")
|
|
695
|
-
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")
|
|
696
727
|
assert_match_in_file(/class ControllerTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/controllers/controllers_test.rb")
|
|
697
728
|
assert_match_in_file(/class SampleProject::App::HelperTest < Test::Unit::TestCase/, "#{@apptmp}/sample_project/test/app/helpers/helpers_test.rb")
|
|
698
729
|
end
|