Sha256: 7025f0684ff167b014089db8070060f15d124116def159638d3252456f3fc8b8

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

# encoding: utf-8
$:.unshift "lib"

require 'rubygems'
require 'test/unit'
require 'mocha'
require 'i18n'
require 'time'
require 'yaml'

class EqualLocalesTestHelperTest < Test::Unit::TestCase
  include I18n::TestHelper

  def setup
    I18n.reload!

    I18n.backend.store_translations :'en', {
      :foo => "Bar",
      :nested => {
        :translation => {
          :should => "Work"
        }
      }
    }

    I18n.backend.store_translations :'pirate', {
      :nested => {
        :translation => {
          :should => "Wark me hearties!"
        }
      },
      :foo => "Barrrr!"
    }
  end

  def test_should_not_raise_a_test_failure
    assert_nothing_raised() { assert_all_locales_have_translations_available_to_the_default_locale }
  end

  def test_should_show_deeply_nested_translation_keys_correctly
    I18n.backend.store_translations :'en', {
      :nested => {
        :translations => {
          :should => {
            :work => "Well"
          }
        }
      }
    }

    e = assert_raise(Test::Unit::AssertionFailedError) { assert_all_locales_have_translations_available_to_the_default_locale }
    assert_match %r/ * nested.translations.should.work$/, e.message
  end
end


class UnequalLocalesTestHelperTest < Test::Unit::TestCase
  include I18n::TestHelper

  def setup
    I18n.reload!

    I18n.backend.store_translations :'en', {
      :bar => {
        :foo => "Bar"
      }
    }

    I18n.backend.store_translations :'pirate', {
      :bar => {
      }
    }
  end

  def test_should_raise_a_test_failure_for_none_matching_nested_keys
    e = assert_raise(Test::Unit::AssertionFailedError) { assert_all_locales_have_translations_available_to_the_default_locale }
    assert_match %r/Missing translations for :pirate/, e.message
    assert_match %r/ * bar.foo/, e.message
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
everythingbehind-i18n-0.1.1.1 test/i18n_test_helper_test.rb