Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Overwrite `t` helper in Rails views to raise in tests, which it otherwise doesn't do, even if I18n is configured to.
# Overwrite `t` helper in Rails views to raise in tests,
# which it otherwise doesn't do, even if I18n is configured to.
#
# Installation:
# put in lib/i18n_raise_on_missing_in_action_view.rb
# and require "i18n_raise_on_missing_in_action_view" in e.g. config/environments/test.rb
if Rails.env.test?
module ActionView::Helpers::TranslationHelper
def t_with_raise(*args)
value = t_without_raise(*args)
if value.to_s.match(/title="translation missing: (.+)"/)
raise "Translation missing: #{$1}"
else
value
end
end
alias_method :translate_with_raise, :t_with_raise
alias_method_chain :t, :raise
alias_method_chain :translate, :raise
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.