Sha256: 958afd5dc9b2128ef6c8bd93dfec5c1e4e049b4d35baba63caa8722a7ace7876

Contents?: true

Size: 945 Bytes

Versions: 21

Compression:

Stored size: 945 Bytes

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
    Localeapp.missing_translations.should_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
    Localeapp.missing_translations.should_receive(:add).with(:en, 'foo', nil, {})
    Localeapp.missing_translations.should_receive(:add).with(:en, 'bar', nil, {})
    I18n.t(['foo', '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

21 entries across 21 versions & 1 rubygems

Version Path
localeapp-0.6.9 spec/localeapp/exception_handler_spec.rb
localeapp-0.6.8 spec/localeapp/exception_handler_spec.rb
localeapp-0.6.7 spec/localeapp/exception_handler_spec.rb
localeapp-0.6.6 spec/localeapp/exception_handler_spec.rb
localeapp-0.6.5 spec/localeapp/exception_handler_spec.rb
localeapp-0.6.4 spec/localeapp/exception_handler_spec.rb
localeapp-0.6.3 spec/localeapp/exception_handler_spec.rb
localeapp-0.6.2 spec/localeapp/exception_handler_spec.rb
localeapp-0.6.1 spec/localeapp/exception_handler_spec.rb
localeapp-0.6.0 spec/localeapp/exception_handler_spec.rb
localeapp-0.5.2 spec/localeapp/exception_handler_spec.rb
localeapp-0.5.1 spec/localeapp/exception_handler_spec.rb
localeapp-0.5.0 spec/localeapp/exception_handler_spec.rb
localeapp-0.4.3 spec/localeapp/exception_handler_spec.rb
localeapp-0.4.2 spec/localeapp/exception_handler_spec.rb
localeapp-0.4.1 spec/localeapp/exception_handler_spec.rb
localeapp-0.4.0 spec/localeapp/exception_handler_spec.rb
localeapp-0.3.2 spec/localeapp/exception_handler_spec.rb
localeapp-0.3.1 spec/localeapp/exception_handler_spec.rb
localeapp-0.3.0 spec/localeapp/exception_handler_spec.rb