Skip to content

Commit

Permalink
Add suspenders:development:environment generator
Browse files Browse the repository at this point in the history
To do:

- [ ] Decide which options we want to include from the existing
  generator
- [ ] Manually test on a real app
- [ ] News and readme entries

Reference:
https://github.com/thoughtbot/suspenders/blob/55cb5c246fe53aea4cf53436c7c208b40ad13e85/lib/suspenders/generators/app_generator.rb#L80-L92
  • Loading branch information
crackofdusk committed Dec 22, 2023
1 parent 8628dcb commit 32e96e7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/generators/suspenders/development/environment_generator.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 32e96e7

Please sign in to comment.