diff --git a/lib/generators/suspenders/development/environment_generator.rb b/lib/generators/suspenders/development/environment_generator.rb new file mode 100644 index 000000000..6a90f7e52 --- /dev/null +++ b/lib/generators/suspenders/development/environment_generator.rb @@ -0,0 +1,11 @@ +module Suspenders + module Generators + module Development + class EnvironmentGenerator < Rails::Generators::Base + def raise_on_missing_translations + uncomment_lines("config/environments/development.rb", "config.i18n.raise_on_missing_translations = true") + end + end + end + end +end diff --git a/test/generators/suspenders/development/environment_generator_test.rb b/test/generators/suspenders/development/environment_generator_test.rb new file mode 100644 index 000000000..86ea05717 --- /dev/null +++ b/test/generators/suspenders/development/environment_generator_test.rb @@ -0,0 +1,36 @@ +require "test_helper" +require "generators/suspenders/development/environment_generator" + +module Suspenders + module Generators + module Development + class EnvironmentGenerator::DefaultTest < Rails::Generators::TestCase + include Suspenders::TestHelpers + + tests Suspenders::Generators::Development::EnvironmentGenerator + destination Rails.root + setup :prepare_destination + teardown :restore_destination + + test "raise on missing translations in development" do + run_generator + + assert_file app_root("config/environments/development.rb") do |file| + assert_match( + /^ +config.i18n.raise_on_missing_translations = true$/, + file + ) + end + end + + def prepare_destination + backup_file "config/environments/development.rb" + end + + def restore_destination + restore_file "config/environments/development.rb" + end + end + end + end +end