Sha256: 40faf23cb8709a331a25b51967871b0138c7689a09b1894d8e773f1d6d608f91

Contents?: true

Size: 1.39 KB

Versions: 9

Compression:

Stored size: 1.39 KB

Contents

require 'test_helper'

class I18nBackendExceptionsTest < I18n::TestCase
  def setup
    I18n.backend = I18n::Backend::Simple.new
  end

  test "throw message: MissingTranslation message from #translate includes the given scope and full key" do
    exception = catch(:exception) do
      I18n.t(:'baz.missing', :scope => :'foo.bar', :throw => true)
    end
    assert_equal "translation missing: en.foo.bar.baz.missing", exception.message
  end

  test "exceptions: MissingTranslationData message from #translate includes the given scope and full key" do
    begin
      I18n.t(:'baz.missing', :scope => :'foo.bar', :raise => true)
    rescue I18n::MissingTranslationData => exception
    end
    assert_equal "translation missing: en.foo.bar.baz.missing", exception.message
  end

  test "exceptions: MissingTranslationData message from #localize includes the given scope and full key" do
    begin
      I18n.l(Time.now, :format => :foo)
    rescue I18n::MissingTranslationData => exception
    end
    assert_equal "translation missing: en.time.formats.foo", exception.message
  end

  test "exceptions: MissingInterpolationArgument message includes missing key, provided keys and full string" do
    exception = I18n::MissingInterpolationArgument.new('key', {:this => 'was given'}, 'string')
    assert_equal 'missing interpolation argument "key" in "string" ({:this=>"was given"} given)', exception.message
  end
end

Version data entries

9 entries across 4 versions & 4 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/i18n-0.6.11/test/backend/exceptions_test.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/i18n-0.6.11/test/backend/exceptions_test.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/i18n-0.6.11/test/backend/exceptions_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/i18n-0.6.11/test/backend/exceptions_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/i18n-0.6.11/test/backend/exceptions_test.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/i18n-0.6.11/test/backend/exceptions_test.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/i18n-0.6.11/test/backend/exceptions_test.rb
nanumfont-rails-0.1 vendor/bundle/ruby/2.1.0/gems/i18n-0.6.11/test/backend/exceptions_test.rb
i18n-0.6.11 test/backend/exceptions_test.rb