suspenders 1.51.0 → 1.55.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +6 -3
- data/CONTRIBUTING.md +15 -15
- data/GOALS.md +65 -0
- data/Gemfile +1 -1
- data/NEWS.md +52 -0
- data/README.md +5 -4
- data/Rakefile +6 -5
- data/docs/heroku_deploy.md +19 -0
- data/lib/suspenders.rb +7 -0
- data/lib/suspenders/actions.rb +2 -2
- data/lib/suspenders/adapters/heroku.rb +27 -14
- data/lib/suspenders/app_builder.rb +42 -111
- data/lib/suspenders/generators/advisories_generator.rb +15 -0
- data/lib/suspenders/generators/analytics_generator.rb +1 -1
- data/lib/suspenders/generators/app_generator.rb +36 -58
- data/lib/suspenders/generators/base.rb +40 -1
- data/lib/suspenders/generators/ci_generator.rb +19 -9
- data/lib/suspenders/generators/db_optimizations_generator.rb +5 -17
- data/lib/suspenders/generators/factories_generator.rb +2 -2
- data/lib/suspenders/generators/forms_generator.rb +1 -1
- data/lib/suspenders/generators/inline_svg_generator.rb +14 -0
- data/lib/suspenders/generators/jobs_generator.rb +4 -4
- data/lib/suspenders/generators/js_driver_generator.rb +7 -4
- data/lib/suspenders/generators/json_generator.rb +1 -1
- data/lib/suspenders/generators/lint_generator.rb +5 -0
- data/lib/suspenders/generators/preloader_generator.rb +122 -0
- data/lib/suspenders/generators/production/compression_generator.rb +14 -0
- data/lib/suspenders/generators/production/deployment_generator.rb +1 -12
- data/lib/suspenders/generators/production/email_generator.rb +9 -12
- data/lib/suspenders/generators/production/manifest_generator.rb +8 -7
- data/lib/suspenders/generators/production/single_redirect.rb +15 -0
- data/lib/suspenders/generators/production/timeout_generator.rb +3 -2
- data/lib/suspenders/generators/profiler_generator.rb +35 -0
- data/lib/suspenders/generators/runner_generator.rb +48 -0
- data/lib/suspenders/generators/staging/pull_requests_generator.rb +4 -12
- data/lib/suspenders/generators/static_generator.rb +5 -1
- data/lib/suspenders/generators/stylelint_generator.rb +2 -1
- data/lib/suspenders/generators/stylesheet_base_generator.rb +7 -8
- data/lib/suspenders/generators/testing_generator.rb +6 -17
- data/lib/suspenders/version.rb +6 -6
- data/spec/adapters/heroku_spec.rb +36 -10
- data/spec/expand_json_spec.rb +89 -0
- data/spec/fakes/bin/heroku +1 -1
- data/spec/fakes/bin/hub +1 -1
- data/spec/features/advisories_spec.rb +24 -0
- data/spec/features/api_spec.rb +1 -1
- data/spec/features/ci_spec.rb +31 -0
- data/spec/features/cli_help_spec.rb +4 -4
- data/spec/features/db_optimizations_spec.rb +19 -0
- data/spec/features/heroku_spec.rb +9 -16
- data/spec/features/inline_svg_spec.rb +10 -0
- data/spec/features/lint_spec.rb +26 -0
- data/spec/features/new_project_spec.rb +38 -60
- data/spec/features/preloader_spec.rb +25 -0
- data/spec/features/production/compression_spec.rb +23 -0
- data/spec/features/production/email_spec.rb +10 -10
- data/spec/features/production/manifest_spec.rb +16 -14
- data/spec/features/production/single_redirect_spec.rb +25 -0
- data/spec/features/profiler_spec.rb +20 -0
- data/spec/features/runner_spec.rb +30 -0
- data/spec/features/staging/pull_requests_spec.rb +1 -1
- data/spec/features/static_spec.rb +17 -0
- data/spec/features/stylelint_spec.rb +7 -7
- data/spec/spec_helper.rb +3 -3
- data/spec/support/contain_json_matcher.rb +16 -10
- data/spec/support/fake_github.rb +3 -3
- data/spec/support/fake_heroku.rb +8 -8
- data/spec/support/project_files.rb +12 -0
- data/spec/support/rails_template.rb +1 -0
- data/spec/support/suspenders.rb +21 -19
- data/suspenders.gemspec +20 -20
- data/templates/Gemfile.erb +2 -10
- data/templates/_javascript.html.erb +1 -1
- data/templates/application.scss +0 -1
- data/templates/bin_auto_migrate +5 -0
- data/templates/bin_deploy +0 -2
- data/templates/bin_setup +2 -2
- data/templates/bin_setup_review_app.erb +0 -1
- data/templates/capybara_silence_puma.rb +1 -0
- data/templates/chromedriver.rb +14 -4
- data/templates/descriptions/advisories.md +5 -0
- data/templates/descriptions/analytics.md +4 -0
- data/templates/descriptions/ci.md +4 -0
- data/templates/descriptions/compression.md +4 -0
- data/templates/descriptions/db_optimizations.md +2 -0
- data/templates/descriptions/deployment.md +5 -0
- data/templates/descriptions/email.md +9 -0
- data/templates/descriptions/factories.md +12 -0
- data/templates/descriptions/force_tls.md +1 -0
- data/templates/descriptions/forms.md +1 -0
- data/templates/descriptions/inline_svg.md +2 -0
- data/templates/descriptions/jobs.md +3 -0
- data/templates/descriptions/js_driver.md +4 -0
- data/templates/descriptions/json.md +1 -0
- data/templates/descriptions/lint.md +3 -0
- data/templates/descriptions/manifest.md +2 -0
- data/templates/descriptions/preloader.md +3 -0
- data/templates/descriptions/profiler.md +7 -0
- data/templates/descriptions/pull_requests.md +4 -0
- data/templates/descriptions/runner.md +10 -0
- data/templates/descriptions/single_redirect.md +1 -0
- data/templates/descriptions/static.md +5 -0
- data/templates/descriptions/stylelint.md +3 -0
- data/templates/descriptions/stylesheet_base.md +4 -0
- data/templates/descriptions/testing.md +9 -0
- data/templates/descriptions/timeout.md +4 -0
- data/templates/descriptions/views.md +8 -0
- data/templates/errors.rb +3 -3
- data/templates/hound.yml +1 -2
- data/templates/inline_svg.rb +3 -0
- data/templates/partials/ci_simplecov.rb +14 -0
- data/templates/partials/db_optimizations_configuration.rb +5 -0
- data/templates/partials/deployment_readme.md +8 -0
- data/templates/partials/email_smtp.rb +2 -0
- data/templates/partials/profiler_readme.md +8 -0
- data/templates/partials/pull_requests_config.rb +4 -0
- data/templates/partials/runner_readme.md +31 -0
- data/templates/partials/runner_setup.rb +2 -0
- data/templates/rack_mini_profiler.rb +2 -0
- data/templates/rails_helper.rb +7 -4
- data/templates/{dotfiles/.env → sample_env} +0 -2
- data/templates/spec_helper.rb +4 -7
- data/templates/spring.rb +6 -0
- data/templates/suspenders_gitignore +1 -1
- metadata +99 -14
- data/templates/browserslist +0 -3
- data/templates/dotfiles/.ctags +0 -2
- data/templates/puma.rb +0 -28
@@ -11,27 +11,27 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
11
11
|
it "uses custom Gemfile" do
|
12
12
|
gemfile_file = IO.read("#{project_path}/Gemfile")
|
13
13
|
expect(gemfile_file).to match(
|
14
|
-
/^ruby "#{Suspenders::RUBY_VERSION}"
|
14
|
+
/^ruby "#{Suspenders::RUBY_VERSION}"$/
|
15
15
|
)
|
16
16
|
expect(gemfile_file).to match(
|
17
|
-
/^gem "autoprefixer-rails"
|
17
|
+
/^gem "autoprefixer-rails"$/
|
18
18
|
)
|
19
19
|
expect(gemfile_file).to match(
|
20
|
-
/^gem "rails", "#{Suspenders::RAILS_VERSION}"
|
20
|
+
/^gem "rails", "#{Suspenders::RAILS_VERSION}"$/
|
21
21
|
)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "ensures project specs pass" do
|
25
25
|
Dir.chdir(project_path) do
|
26
|
-
Bundler.
|
27
|
-
expect(`rake`).to include(
|
26
|
+
Bundler.with_unbundled_env do
|
27
|
+
expect(`rake`).to include("0 failures")
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
it "includes the bundle:audit task" do
|
33
33
|
Dir.chdir(project_path) do
|
34
|
-
Bundler.
|
34
|
+
Bundler.with_unbundled_env do
|
35
35
|
expect(`rails -T`).to include("rails bundle:audit")
|
36
36
|
end
|
37
37
|
end
|
@@ -44,9 +44,7 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
it "copies dotfiles" do
|
47
|
-
|
48
|
-
expect(File).to exist("#{project_path}/#{dotfile}")
|
49
|
-
end
|
47
|
+
expect(File).to exist("#{project_path}/.sample.env")
|
50
48
|
end
|
51
49
|
|
52
50
|
it "doesn't generate test directory" do
|
@@ -56,8 +54,8 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
56
54
|
it "loads secret_key_base from env" do
|
57
55
|
secrets_file = IO.read("#{project_path}/config/secrets.yml")
|
58
56
|
|
59
|
-
expect(secrets_file)
|
60
|
-
to match(/secret_key_base: <%= ENV\["SECRET_KEY_BASE"\] %>/)
|
57
|
+
expect(secrets_file)
|
58
|
+
.to match(/secret_key_base: <%= ENV\["SECRET_KEY_BASE"\] %>/)
|
61
59
|
end
|
62
60
|
|
63
61
|
it "adds bin/setup file" do
|
@@ -86,33 +84,16 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
86
84
|
expect(hound_config_file).to include "enabled: true"
|
87
85
|
end
|
88
86
|
|
89
|
-
it "ensures Gemfile contains `rack-mini-profiler`" do
|
90
|
-
gemfile = IO.read("#{project_path}/Gemfile")
|
91
|
-
|
92
|
-
expect(gemfile).to include %{gem "rack-mini-profiler", require: false}
|
93
|
-
end
|
94
|
-
|
95
|
-
it "ensures .sample.env defaults to RACK_MINI_PROFILER=0" do
|
96
|
-
env = IO.read("#{project_path}/.env")
|
97
|
-
|
98
|
-
expect(env).to include "RACK_MINI_PROFILER=0"
|
99
|
-
end
|
100
|
-
|
101
87
|
it "initializes ActiveJob to avoid memory bloat" do
|
102
|
-
expect(File)
|
103
|
-
to exist("#{project_path}/config/initializers/active_job.rb")
|
104
|
-
end
|
105
|
-
|
106
|
-
it "creates a rack-mini-profiler initializer" do
|
107
|
-
expect(File).
|
108
|
-
to exist("#{project_path}/config/initializers/rack_mini_profiler.rb")
|
88
|
+
expect(File)
|
89
|
+
.to exist("#{project_path}/config/initializers/active_job.rb")
|
109
90
|
end
|
110
91
|
|
111
92
|
it "records pageviews through Segment if ENV variable set" do
|
112
|
-
expect(analytics_partial)
|
113
|
-
to include(%
|
114
|
-
expect(analytics_partial)
|
115
|
-
to include(%{analytics.load("<%= ENV["SEGMENT_KEY"] %>");})
|
93
|
+
expect(analytics_partial)
|
94
|
+
.to include(%(<% if ENV["SEGMENT_KEY"] %>))
|
95
|
+
expect(analytics_partial)
|
96
|
+
.to include(%{analytics.load("<%= ENV["SEGMENT_KEY"] %>");})
|
116
97
|
end
|
117
98
|
|
118
99
|
it "raises on unpermitted parameters in all environments" do
|
@@ -131,13 +112,13 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
131
112
|
|
132
113
|
it "configures public_file_server.headers in production" do
|
133
114
|
expect(production_config).to match(
|
134
|
-
/^ +config.public_file_server.headers = {\n +"Cache-Control" => "public
|
115
|
+
/^ +config.public_file_server.headers = {\n +"Cache-Control" => "public,/
|
135
116
|
)
|
136
117
|
end
|
137
118
|
|
138
119
|
it "configures production environment to enforce SSL" do
|
139
120
|
expect(production_config).to match(
|
140
|
-
/^ +config.force_ssl = true
|
121
|
+
/^ +config.force_ssl = true/
|
141
122
|
)
|
142
123
|
end
|
143
124
|
|
@@ -160,8 +141,8 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
160
141
|
end
|
161
142
|
|
162
143
|
it "configs :test email delivery method for development" do
|
163
|
-
expect(development_config)
|
164
|
-
to match(/^ +config.action_mailer.delivery_method = :file$/)
|
144
|
+
expect(development_config)
|
145
|
+
.to match(/^ +config.action_mailer.delivery_method = :file$/)
|
165
146
|
end
|
166
147
|
|
167
148
|
it "sets action mailer default host and asset host" do
|
@@ -180,8 +161,8 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
180
161
|
email_file = File.join(project_path, "config", "initializers", "email.rb")
|
181
162
|
email_config = IO.read(email_file)
|
182
163
|
|
183
|
-
expect(email_config)
|
184
|
-
to include(%{RecipientInterceptor.new(ENV["EMAIL_RECIPIENTS"])})
|
164
|
+
expect(email_config)
|
165
|
+
.to include(%{RecipientInterceptor.new(ENV["EMAIL_RECIPIENTS"])})
|
185
166
|
end
|
186
167
|
|
187
168
|
it "configures language in html element" do
|
@@ -205,26 +186,26 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
205
186
|
delayed_job = IO.read("#{project_path}/bin/delayed_job")
|
206
187
|
|
207
188
|
expect(delayed_job).to match(
|
208
|
-
/^require 'delayed\/command'
|
189
|
+
/^require 'delayed\/command'$/
|
209
190
|
)
|
210
191
|
end
|
211
192
|
|
212
193
|
it "configs bullet gem in development" do
|
213
|
-
expect(development_config).to match
|
214
|
-
expect(development_config).to match
|
215
|
-
expect(development_config).to match
|
194
|
+
expect(development_config).to match(/^ +Bullet.enable = true$/)
|
195
|
+
expect(development_config).to match(/^ +Bullet.bullet_logger = true$/)
|
196
|
+
expect(development_config).to match(/^ +Bullet.rails_logger = true$/)
|
216
197
|
end
|
217
198
|
|
218
199
|
it "configs missing assets to raise in test" do
|
219
200
|
expect(test_config).to match(
|
220
|
-
/^ +config.assets.raise_runtime_errors = true
|
201
|
+
/^ +config.assets.raise_runtime_errors = true$/
|
221
202
|
)
|
222
203
|
end
|
223
204
|
|
224
205
|
it "adds spring to binstubs" do
|
225
206
|
expect(File).to exist("#{project_path}/bin/spring")
|
226
207
|
|
227
|
-
bin_stubs = %w
|
208
|
+
bin_stubs = %w[rake rails rspec]
|
228
209
|
bin_stubs.each do |bin_stub|
|
229
210
|
expect(IO.read("#{project_path}/bin/#{bin_stub}")).to match(/spring/)
|
230
211
|
end
|
@@ -236,7 +217,7 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
236
217
|
IO.read("#{project_path}/config/environment.rb"),
|
237
218
|
development_config,
|
238
219
|
test_config,
|
239
|
-
production_config
|
220
|
+
production_config
|
240
221
|
]
|
241
222
|
|
242
223
|
config_files.each do |file|
|
@@ -256,8 +237,6 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
256
237
|
|
257
238
|
expect(bin_setup).to include("PARENT_APP_NAME=#{app_name.dasherize}-staging")
|
258
239
|
expect(bin_setup).to include("APP_NAME=#{app_name.dasherize}-staging-pr-$1")
|
259
|
-
expect(bin_setup).
|
260
|
-
to include("heroku run rails db:migrate --exit-code --app $APP_NAME")
|
261
240
|
expect(bin_setup).to include("heroku ps:scale worker=1 --app $APP_NAME")
|
262
241
|
expect(bin_setup).to include("heroku restart --app $APP_NAME")
|
263
242
|
|
@@ -268,7 +247,7 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
268
247
|
bin_deploy_path = "#{project_path}/bin/deploy"
|
269
248
|
bin_deploy = IO.read(bin_deploy_path)
|
270
249
|
|
271
|
-
expect(bin_deploy).to include("
|
250
|
+
expect(bin_deploy).to include("git push")
|
272
251
|
expect("bin/deploy").to be_executable
|
273
252
|
end
|
274
253
|
|
@@ -293,42 +272,41 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
293
272
|
expect(gemfile).to match(/sassc-rails/)
|
294
273
|
end
|
295
274
|
|
296
|
-
it "adds and configures bourbon
|
275
|
+
it "adds and configures bourbon" do
|
297
276
|
gemfile = read_project_file("Gemfile")
|
298
277
|
|
299
278
|
expect(gemfile).to match(/bourbon/)
|
300
|
-
expect(gemfile).to match(/neat/)
|
301
279
|
end
|
302
280
|
|
303
|
-
it "configures bourbon,
|
304
|
-
app_css = read_project_file(%w
|
281
|
+
it "configures bourbon, and bitters" do
|
282
|
+
app_css = read_project_file(%w[app assets stylesheets application.scss])
|
305
283
|
expect(app_css).to match(
|
306
|
-
/normalize\.css\/normalize.*bourbon.*
|
284
|
+
/normalize\.css\/normalize.*bourbon.*base/m
|
307
285
|
)
|
308
286
|
end
|
309
287
|
|
310
288
|
it "doesn't use turbolinks" do
|
311
|
-
app_js = read_project_file(%w
|
289
|
+
app_js = read_project_file(%w[app javascript packs application.js])
|
312
290
|
expect(app_js).not_to match(/turbolinks/)
|
313
291
|
end
|
314
292
|
|
315
293
|
it "configures Timecop safe mode" do
|
316
|
-
spec_helper = read_project_file(%w
|
294
|
+
spec_helper = read_project_file(%w[spec spec_helper.rb])
|
317
295
|
expect(spec_helper).to match(/Timecop.safe_mode = true/)
|
318
296
|
end
|
319
297
|
|
320
298
|
def development_config
|
321
299
|
@_development_config ||=
|
322
|
-
read_project_file %w
|
300
|
+
read_project_file %w[config environments development.rb]
|
323
301
|
end
|
324
302
|
|
325
303
|
def test_config
|
326
|
-
@_test_config ||= read_project_file %w
|
304
|
+
@_test_config ||= read_project_file %w[config environments test.rb]
|
327
305
|
end
|
328
306
|
|
329
307
|
def production_config
|
330
308
|
@_production_config ||=
|
331
|
-
read_project_file %w
|
309
|
+
read_project_file %w[config environments production.rb]
|
332
310
|
end
|
333
311
|
|
334
312
|
def analytics_partial
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "suspenders:preloader", type: :generator do
|
4
|
+
it "adds binstubs for Spring" do
|
5
|
+
with_app { generate("suspenders:preloader") }
|
6
|
+
|
7
|
+
expect("bin/rails").to match_contents(/spring/)
|
8
|
+
expect("config/spring.rb").to exist_as_a_file
|
9
|
+
expect("config/environments/test.rb").to \
|
10
|
+
match_contents(/config.cache_classes = false/)
|
11
|
+
expect("Gemfile").to match_contents(/spring/)
|
12
|
+
expect("Gemfile").to match_contents(/spring-watcher-listen/)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "removes Spring binstubs" do
|
16
|
+
with_app { destroy("suspenders:preloader") }
|
17
|
+
|
18
|
+
expect("config/environments/test.rb").to \
|
19
|
+
match_contents(/config.cache_classes = true/)
|
20
|
+
expect("config/spring.rb").not_to exist_as_a_file
|
21
|
+
expect("bin/rails").not_to match_contents(/spring/)
|
22
|
+
expect("Gemfile").not_to match_contents(/spring-watcher-listen/)
|
23
|
+
expect("Gemfile").not_to match_contents(/spring/)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "suspenders:production:compression", type: :generator do
|
4
|
+
context "generate" do
|
5
|
+
it "adds Rack::Deflater to the middleware" do
|
6
|
+
with_app { generate("suspenders:production:compression") }
|
7
|
+
|
8
|
+
expect("config/environments/production.rb").to match_contents(
|
9
|
+
%r{config.middleware.use Rack::Deflater}
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "destroy" do
|
15
|
+
it "removes Rack::Deflater to the middleware" do
|
16
|
+
with_app { destroy("suspenders:production:compression") }
|
17
|
+
|
18
|
+
expect("config/environments/production.rb").not_to match_contents(
|
19
|
+
%r{Rack::Deflater}
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -15,11 +15,11 @@ RSpec.describe "suspenders:production:email", type: :generator do
|
|
15
15
|
|
16
16
|
expect("app.json").to contain_json(
|
17
17
|
env: {
|
18
|
-
SMTP_ADDRESS: {
|
19
|
-
SMTP_DOMAIN: {
|
20
|
-
SMTP_PASSWORD: {
|
21
|
-
SMTP_USERNAME: {
|
22
|
-
}
|
18
|
+
SMTP_ADDRESS: {required: true},
|
19
|
+
SMTP_DOMAIN: {required: true},
|
20
|
+
SMTP_PASSWORD: {required: true},
|
21
|
+
SMTP_USERNAME: {required: true}
|
22
|
+
}
|
23
23
|
)
|
24
24
|
end
|
25
25
|
|
@@ -37,11 +37,11 @@ RSpec.describe "suspenders:production:email", type: :generator do
|
|
37
37
|
|
38
38
|
expect("app.json").not_to contain_json(
|
39
39
|
env: {
|
40
|
-
SMTP_ADDRESS: {
|
41
|
-
SMTP_DOMAIN: {
|
42
|
-
SMTP_PASSWORD: {
|
43
|
-
SMTP_USERNAME: {
|
44
|
-
}
|
40
|
+
SMTP_ADDRESS: {required: true},
|
41
|
+
SMTP_DOMAIN: {required: true},
|
42
|
+
SMTP_PASSWORD: {required: true},
|
43
|
+
SMTP_USERNAME: {required: true}
|
44
|
+
}
|
45
45
|
)
|
46
46
|
end
|
47
47
|
end
|
@@ -7,13 +7,14 @@ RSpec.describe "suspenders:production:manifest", type: :generator do
|
|
7
7
|
expect("app.json").to contain_json(
|
8
8
|
name: SuspendersTestHelpers::APP_NAME.dasherize,
|
9
9
|
env: {
|
10
|
-
APPLICATION_HOST: {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
APPLICATION_HOST: {required: true},
|
11
|
+
AUTO_MIGRATE_DB: {value: true},
|
12
|
+
EMAIL_RECIPIENTS: {required: true},
|
13
|
+
HEROKU_APP_NAME: {required: true},
|
14
|
+
HEROKU_PARENT_APP_NAME: {required: true},
|
15
|
+
RACK_ENV: {required: true},
|
16
|
+
SECRET_KEY_BASE: {generator: "secret"}
|
17
|
+
}
|
17
18
|
)
|
18
19
|
end
|
19
20
|
|
@@ -23,13 +24,14 @@ RSpec.describe "suspenders:production:manifest", type: :generator do
|
|
23
24
|
expect("app.json").not_to contain_json(
|
24
25
|
name: SuspendersTestHelpers::APP_NAME.dasherize,
|
25
26
|
env: {
|
26
|
-
APPLICATION_HOST: {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
APPLICATION_HOST: {required: true},
|
28
|
+
AUTO_MIGRATE_DB: {value: true},
|
29
|
+
EMAIL_RECIPIENTS: {required: true},
|
30
|
+
HEROKU_APP_NAME: {required: true},
|
31
|
+
HEROKU_PARENT_APP_NAME: {required: true},
|
32
|
+
RACK_ENV: {required: true},
|
33
|
+
SECRET_KEY_BASE: {generator: "secret"}
|
34
|
+
}
|
33
35
|
)
|
34
36
|
end
|
35
37
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "suspenders:production:single_redirect", type: :generator do
|
4
|
+
context "generate" do
|
5
|
+
it "adds Rack::CanonicalHost to the production middleware" do
|
6
|
+
with_app { generate("suspenders:production:single_redirect") }
|
7
|
+
middleware_canonical_host = %r{config.middleware.use Rack::CanonicalHost, ENV.fetch\("APPLICATION_HOST"\)}
|
8
|
+
|
9
|
+
expect("config/environments/production.rb").to match_contents(
|
10
|
+
middleware_canonical_host
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "destroy" do
|
16
|
+
it "removes Rack::CanonicalHost from the production middleware" do
|
17
|
+
with_app { destroy("suspenders:production:single_redirect") }
|
18
|
+
middleware_canonical_host = %r{config.middleware.use Rack::CanonicalHost, ENV.fetch\("APPLICATION_HOST"\)}
|
19
|
+
|
20
|
+
expect("config/environments/production.rb").not_to match_contents(
|
21
|
+
middleware_canonical_host
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "suspenders:profiler", type: :generator do
|
4
|
+
it "sets up rack-min-profiler" do
|
5
|
+
with_app { generate("suspenders:profiler") }
|
6
|
+
|
7
|
+
expect("config/initializers/rack_mini_profiler.rb").to \
|
8
|
+
match_contents(/Rack::MiniProfilerRails.initialize/)
|
9
|
+
expect("Gemfile").to match_contents(/rack-mini-profiler/)
|
10
|
+
expect(".sample.env").to match_contents(/RACK_MINI_PROFILER=0/)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "removes rack-min-profiler" do
|
14
|
+
with_app { destroy("suspenders:profiler") }
|
15
|
+
|
16
|
+
expect("config/initializers/rack_mini_profiler.rb").not_to exist_as_a_file
|
17
|
+
expect("Gemfile").not_to match_contents(/rack-mini-profiler/)
|
18
|
+
expect(".sample.env").not_to exist_as_a_file
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "suspenders:runner", type: :generator do
|
4
|
+
it "configures the app for running" do
|
5
|
+
with_app { generate("suspenders:runner") }
|
6
|
+
|
7
|
+
expect("Procfile").to exist_as_a_file
|
8
|
+
expect(".sample.env").to exist_as_a_file
|
9
|
+
expect("bin/setup").to match_contents(/\.sample\.env/)
|
10
|
+
expect("README.md").to match_contents(/\.sample\.env/)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "removes custom app running configuration" do
|
14
|
+
with_app { destroy("suspenders:runner") }
|
15
|
+
|
16
|
+
expect("README.md").not_to match_contents(/\.sample\.env/)
|
17
|
+
expect("bin/setup").not_to match_contents(/\.sample\.env/)
|
18
|
+
expect(".sample.env").not_to exist_as_a_file
|
19
|
+
expect("Procfile").not_to exist_as_a_file
|
20
|
+
end
|
21
|
+
|
22
|
+
it "configures the app with a shell script bin/setup" do
|
23
|
+
with_app do
|
24
|
+
copy_file "bin_setup", "bin/setup"
|
25
|
+
generate("suspenders:runner")
|
26
|
+
end
|
27
|
+
|
28
|
+
expect("bin/setup").to match_contents(/\.sample\.env/)
|
29
|
+
end
|
30
|
+
end
|