Make sure that a MissingInterpolationArgument in the english locale is raised

This commit is contained in:
Raphael Sofaer 2011-07-29 14:29:41 -07:00
parent b56838e5b1
commit bea333842f
2 changed files with 9 additions and 1 deletions

View file

@ -17,7 +17,7 @@ module I18n
options.delete(:fallback)
return super(locale, nil, options.merge(:default => default)) if default
raise(I18n::MissingInterpolationError.new(locale, key, options))
raise(I18n::MissingInterpolationArgument.new(options, "key: #{key} in locale: #{locale}"))
end
end
end

View file

@ -75,6 +75,14 @@ describe 'making sure the spec runner works' do
translation = translate('bob', :hey => "what")
translation.should == "English translation"
end
it 'MissingInterpolationError with no fallback is fatal' do
I18n.backend.stub!(:lookup).
with(:en, 'bob', nil, :hey => "what", :fallback => true).
and_return("English translation %{that_will_fail}")
lambda {
translate('bob', :hey => "what")
}.should raise_error I18n::MissingInterpolationArgument
end
end
end