Permalink
Browse files

Raise on missing translations in development/test

  • Loading branch information...
1 parent a1a322c commit ad68ff507a4d5fca0abb496f9310f481fdd59fd7 @gabebw gabebw committed Jun 18, 2014
@@ -9,6 +9,10 @@ def replace_in_file(relative_path, find, replace)
File.open(path, "w") { |file| file.write(contents) }
end
+ def uncomment_in_file(path, uncommented)
@jfelchner
jfelchner Oct 14, 2014

You know Thor already has an uncomment_lines method that's available in the builder right?

@gabebw
gabebw Oct 14, 2014 thoughtbot, inc. member

I did not.

@gabebw
gabebw Oct 14, 2014 thoughtbot, inc. member

PR: #416

@jfelchner
jfelchner Oct 14, 2014

@gabebw just droppin some knowledge 💣 Ya know. 😄

+ replace_in_file(path, "# #{uncommented}", uncommented)
+ end
+
def action_mailer_host(rails_env, host)
host_config = "config.action_mailer.default_url_options = { host: '#{host}' }"
configure_environment(rails_env, host_config)
@@ -183,8 +183,13 @@ def configure_travis
template 'travis.yml.erb', '.travis.yml'
end
- def configure_i18n_in_specs
+ def configure_i18n_for_test_environment
copy_file 'i18n.rb', 'spec/support/i18n.rb'
+ raise_on_missing_translations_in("test")
+ end
+
+ def configure_i18n_for_development_environment
+ raise_on_missing_translations_in("development")
end
def configure_background_jobs_for_rspec
@@ -356,6 +361,12 @@ def setup_default_rake_task
private
+ def raise_on_missing_translations_in(environment)
+ config = 'config.action_view.raise_on_missing_translations = true'
+
+ uncomment_in_file("config/environments/#{environment}.rb", config)
+ end
+
def override_path_for_tests
if ENV['TESTING']
support_bin = File.expand_path(File.join('..', '..', 'spec', 'fakes', 'bin'))
@@ -71,6 +71,7 @@ def setup_development_environment
build :provide_setup_script
build :provide_dev_prime_task
build :configure_generators
+ build :configure_i18n_for_development_environment
end
def setup_test_environment
@@ -82,7 +83,7 @@ def setup_test_environment
build :enable_database_cleaner
build :configure_spec_support_features
build :configure_travis
- build :configure_i18n_in_specs
+ build :configure_i18n_for_test_environment
build :configure_action_mailer_in_specs
end
@@ -62,6 +62,15 @@
to include(%{window.analytics.load("<%= ENV["SEGMENT_IO_KEY"] %>");})
end
+ scenario "raises on missing translations in development/test" do
+ run_suspenders
+
+ %w(test development).each do |environment|
+ environment_file = IO.read("#{project_path}/config/environments/#{environment}.rb")
+ expect(environment_file).to match /^ +config.action_view.raise_on_missing_translations = true$/
+ end
+ end
+
def analytics_partial
IO.read("#{project_path}/app/views/application/_analytics.html.erb")
end

0 comments on commit ad68ff5

Please sign in to comment.