-
-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add suspenders:development:environment generator
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
1 parent
8628dcb
commit 32e96e7
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
lib/generators/suspenders/development/environment_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
36 changes: 36 additions & 0 deletions
36
test/generators/suspenders/development/environment_generator_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |