Sha256: d7bbd9e3b934913e74c91486860c5681dfcd85e08966f38b9c7a886dd674e49e

Contents?: true

Size: 930 Bytes

Versions: 4

Compression:

Stored size: 930 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', { :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', {})
    Localeapp.missing_translations.should_receive(:add).with(:en, 'bar', {})
    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

4 entries across 4 versions & 1 rubygems

Version Path
localeapp-0.1.2 spec/localeapp/exception_handler_spec.rb
localeapp-0.1.1 spec/localeapp/exception_handler_spec.rb
localeapp-0.0.11 spec/localeapp/exception_handler_spec.rb
localeapp-0.0.10 spec/localeapp/exception_handler_spec.rb