Sha256: e369a50b653e1c191fdc949301f690096eda99640900b465488d159a9eea3a90

Contents?: true

Size: 1.23 KB

Versions: 11

Compression:

Stored size: 1.23 KB

Contents

require File.join( File.dirname(__FILE__), '..', 'test_helper' )
require 'globalize/i18n/missing_translations_log_handler'

class MissingTranslationsTest < ActiveSupport::TestCase
  test "defines I18n.missing_translations_logger accessor" do
    assert I18n.respond_to?(:missing_translations_logger)
  end

  test "defines I18n.missing_translations_logger= writer" do
    assert I18n.respond_to?(:missing_translations_logger=)
  end
end

class TestLogger < String
  def warn(msg) self.concat msg; end
end

class LogMissingTranslationsTest < ActiveSupport::TestCase
  def setup
    @locale, @key, @options = :en, :foo, {}
    @exception = I18n::MissingTranslationData.new(@locale, @key, @options)
    
    @logger = TestLogger.new
    I18n.missing_translations_logger = @logger
  end

  test "still returns the exception message for MissingTranslationData exceptions" do
    result = I18n.send(:missing_translations_log_handler, @exception, @locale, @key, @options)
    assert_equal 'translation missing: en, foo', result 
  end
  
  test "logs the missing translation to I18n.missing_translations_logger" do
    I18n.send(:missing_translations_log_handler, @exception, @locale, @key, @options)
    assert_equal 'translation missing: en, foo', @logger 
  end
end

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
kriss-gettext_i18n-0.2.0 vendor/globalize2/test/i18n/missing_translations_test.rb
kriss-gettext_i18n-0.2.1 vendor/globalize2/test/i18n/missing_translations_test.rb
kriss-gettext_i18n-0.2.2 vendor/globalize2/test/i18n/missing_translations_test.rb
kriss-gettext_i18n-0.2.3 vendor/globalize2/test/i18n/missing_translations_test.rb
simonmenke-globalize2-0.0.1 test/i18n/missing_translations_test.rb
simonmenke-globalize2-0.0.4 test/i18n/missing_translations_test.rb
simonmenke-globalize2-0.0.5 test/i18n/missing_translations_test.rb
simonmenke-globalize2-0.0.6 test/i18n/missing_translations_test.rb
simonmenke-simonmenke-globalize2-0.0.2 test/i18n/missing_translations_test.rb
simonmenke-globalize2-0.0.7 test/i18n/missing_translations_test.rb
globalize2-0.1.0 test/i18n/missing_translations_test.rb