Sha256: 10b26d2c8361e62849e4c2674ab98d5a621ab9784af669ba5953ee6efeb65d34

Contents?: true

Size: 1.28 KB

Versions: 80

Compression:

Stored size: 1.28 KB

Contents

require 'test_helper'
# TODO: change back to "require 'backend/simple'" when dropping support to Ruby 1.8.7.
require File.expand_path('../simple_test', __FILE__)

class I18nBackendMemoizeTest < I18nBackendSimpleTest
  module MemoizeSpy
    attr_accessor :spy_calls

    def available_locales
      self.spy_calls = (self.spy_calls || 0) + 1
      super
    end
  end

  class MemoizeBackend < I18n::Backend::Simple
    include MemoizeSpy
    include I18n::Backend::Memoize
  end

  def setup
    super
    I18n.backend = MemoizeBackend.new
  end

  def test_memoizes_available_locales
    I18n.backend.spy_calls = 0
    assert_equal I18n.available_locales, I18n.available_locales
    assert_equal 1, I18n.backend.spy_calls
  end

  def test_resets_available_locales_on_reload!
    I18n.available_locales
    I18n.backend.spy_calls = 0
    I18n.reload!
    assert_equal I18n.available_locales, I18n.available_locales
    assert_equal 1, I18n.backend.spy_calls
  end

  def test_resets_available_locales_on_store_translations
    I18n.available_locales
    I18n.backend.spy_calls = 0
    I18n.backend.store_translations(:copa, :ca => :bana)
    assert_equal I18n.available_locales, I18n.available_locales
    assert I18n.available_locales.include?(:copa)
    assert_equal 1, I18n.backend.spy_calls
  end
end

Version data entries

80 entries across 74 versions & 18 rubygems

Version Path
lazy_record-0.1.2 vendor/bundle/gems/i18n-0.8.1/test/backend/memoize_test.rb
lazy_record-0.1.1 vendor/bundle/gems/i18n-0.8.1/test/backend/memoize_test.rb
lazy_record-0.1.0 vendor/bundle/gems/i18n-0.8.1/test/backend/memoize_test.rb
i18n-0.8.1 test/backend/memoize_test.rb
i18n-0.8.0 test/backend/memoize_test.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/i18n-0.7.0/test/backend/memoize_test.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/i18n-0.7.0/test/backend/memoize_test.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/i18n-0.7.0/test/backend/memoize_test.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/i18n-0.7.0/test/backend/memoize_test.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/i18n-0.7.0/test/backend/memoize_test.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/i18n-0.7.0/test/backend/memoize_test.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/i18n-0.7.0/test/backend/memoize_test.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/i18n-0.7.0/test/backend/memoize_test.rb
abaci-0.3.0 vendor/bundle/gems/i18n-0.7.0/test/backend/memoize_test.rb
i18n-0.8.0.beta1 test/backend/memoize_test.rb
second_step-0.1.2 secondstep-notify-1.0.0-osx/lib/ruby/lib/ruby/gems/2.2.0/gems/i18n-0.7.0/test/backend/memoize_test.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/i18n-0.7.0/test/backend/memoize_test.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/i18n-0.7.0/test/backend/memoize_test.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/i18n-0.7.0/test/backend/memoize_test.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/i18n-0.7.0/test/backend/memoize_test.rb