Sha256: 0e2d2d8cd54d7a01929563a05f08e50b4de6132bfc36de463f5a2d486f00befa
Contents?: true
Size: 1.44 KB
Versions: 2
Compression:
Stored size: 1.44 KB
Contents
require 'spec_helper' require 'localeapp/exception_handler' describe Localeapp::ExceptionHandler, '#call(exception, locale, key, options)' do before(:each) do Localeapp.configure do |config| config.api_key = 'abcdef' end end it "adds the missing translation to the missing translation list" do expect(Localeapp.missing_translations).to receive(:add).with(:en, 'foo', nil, { :baz => 'bam' }) I18n.t('foo', :baz => 'bam') end it "handles when the key is an array of keys" do expect(Localeapp.missing_translations).to receive(:add).with(:en, 'foo', nil, {}) expect(Localeapp.missing_translations).to receive(:add).with(:en, 'bar', nil, {}) I18n.t(['foo', 'bar']) end it "handles when the default is a Symbol that can be resolved" do I18n.backend.store_translations(:en, {:default_symbol_test => 'is resolved'}) expect(Localeapp.missing_translations).not_to receive(:add) expect(I18n.t(:foo, :default => :default_symbol_test)).to eq('is resolved') end it "handles when the default is a Symbol that can't be resolved" do expect(Localeapp.missing_translations).to receive(:add).with(:en, :foo, nil, {:default => :bar}) I18n.t(:foo, :default => :bar) end it "handles missing translation exception" do expect { exception = Localeapp::I18nMissingTranslationException.new(:en, 'foo', {}) Localeapp::ExceptionHandler.call(exception, :en, 'foo', {}) }.to_not raise_error end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
localeapp-1.0.1 | spec/localeapp/exception_handler_spec.rb |
localeapp-1.0.0 | spec/localeapp/exception_handler_spec.rb |