Sha256: 55d1a9ee4376534a56b5bd1a0101a54d3683441016453a0d63eb820a8fd353a1

Contents?: true

Size: 1.4 KB

Versions: 107

Compression:

Stored size: 1.4 KB

Contents

require 'test_helper'

class I18nBackendExceptionsTest < I18n::TestCase
  def setup
    super
    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

107 entries across 94 versions & 22 rubygems

Version Path
mumukit-content-type-1.12.1 vendor/bundle/ruby/2.7.0/gems/i18n-0.9.5/test/backend/exceptions_test.rb
mumukit-content-type-1.12.0 vendor/bundle/ruby/2.7.0/gems/i18n-0.9.5/test/backend/exceptions_test.rb
mumukit-content-type-1.11.1 vendor/bundle/ruby/2.6.0/gems/i18n-0.9.5/test/backend/exceptions_test.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/i18n-0.9.5/test/backend/exceptions_test.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/i18n-0.8.0/test/backend/exceptions_test.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/i18n-1.1.1/test/backend/exceptions_test.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/i18n-1.1.1/test/backend/exceptions_test.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/i18n-1.1.1/test/backend/exceptions_test.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/i18n-1.1.1/test/backend/exceptions_test.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/i18n-1.1.1/test/backend/exceptions_test.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/i18n-0.8.0/test/backend/exceptions_test.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/i18n-1.1.1/test/backend/exceptions_test.rb
cocoapods-dependency-html-0.0.2 vendor/bundle/gems/i18n-0.9.5/test/backend/exceptions_test.rb
cocoapods-dependency-html-0.0.1 vendor/bundle/gems/i18n-0.9.5/test/backend/exceptions_test.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/i18n-0.8.0/test/backend/exceptions_test.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/i18n-1.1.1/test/backend/exceptions_test.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/i18n-1.1.1/test/backend/exceptions_test.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/i18n-1.1.1/test/backend/exceptions_test.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/i18n-0.8.0/test/backend/exceptions_test.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/i18n-0.8.0/test/backend/exceptions_test.rb