Skip to content

Commit a057bd6

Browse files
stevepolitodesignpurinklelaicuRoot
authored
Configure test environment (#1282)
Alternative to #1261, lifted from the existing [generator][]. However, since the authoring of that generator, the structure of `config/environments/test.rb` has changed, so we no longer need conditionals. Additionally, we set `action_dispatch.show_exceptions` to `:none` rather than comment it out to be explicit about the value. [generator]: https://github.com/thoughtbot/suspenders/blob/main/lib/generators/suspenders/environments/test_generator.rb Co-authored-by: Rob Whittaker <rob@thoughtbot.com> Co-authored-by: Jose Blanco <53355525+laicuRoot@users.noreply.github.com>
1 parent d6e5a02 commit a057bd6

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

FEATURES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The following environment variables are available in `production`:
2929
### Test
3030

3131
- Enables [raise_on_missing_translations][].
32-
- Disables [action_dispatch.show_exceptions][].
32+
- Sets [action_dispatch.show_exceptions][] to `:none`.
3333

3434
[raise_on_missing_translations]: https://guides.rubyonrails.org/configuring.html#config-i18n-raise-on-missing-translations
3535
[action_dispatch.show_exceptions]: https://edgeguides.rubyonrails.org/configuring.html#config-action-dispatch-show-exceptions

lib/templates/web.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def install_gems
4242
configure_inline_svg
4343

4444
# Environments
45+
setup_test_environment
4546
setup_development_environment
4647
setup_production_environment
4748
setup_application
@@ -207,6 +208,11 @@ def configure_inline_svg
207208
RUBY
208209
end
209210

211+
def setup_test_environment
212+
gsub_file "config/environments/test.rb", /config\.action_dispatch\.show_exceptions = :rescuable/, "config.action_dispatch.show_exceptions = :none"
213+
uncomment_lines "config/environments/test.rb", /config\.i18n\.raise_on_missing_translations/
214+
end
215+
210216
def setup_development_environment
211217
environment "config.active_model.i18n_customize_full_message = true", env: "development"
212218
uncomment_lines "config/environments/development.rb", /config\.i18n\.raise_on_missing_translations/
@@ -312,7 +318,7 @@ def update_readme
312318
### Test
313319
314320
- Enables [raise_on_missing_translations][].
315-
- Disables [action_dispatch.show_exceptions][].
321+
- Sets [action_dispatch.show_exceptions][] to `:none`.
316322
317323
[raise_on_missing_translations]: https://guides.rubyonrails.org/configuring.html#config-i18n-raise-on-missing-translations
318324
[action_dispatch.show_exceptions]: https://edgeguides.rubyonrails.org/configuring.html#config-action-dispatch-show-exceptions

0 commit comments

Comments
 (0)