Sha256: 6ef05db606013f4f0ad4c3958aaec7b2f2efda2bac2e595bb03ef5ca5745671e

Contents?: true

Size: 1.6 KB

Versions: 26

Compression:

Stored size: 1.6 KB

Contents

require File.expand_path("../spec_helper", File.dirname(__FILE__))

describe GettextI18nRails::Backend do
  it "redirects calls to another I18n backend" do
    subject.backend.should_receive(:xxx).with(1,2)
    subject.xxx(1,2)
  end

  describe :available_locales do
    it "maps them to FastGettext" do
      FastGettext.should_receive(:available_locales).and_return [:xxx]
      subject.available_locales.should == [:xxx]
    end

    it "and returns an empty array when FastGettext.available_locales is nil" do
      FastGettext.should_receive(:available_locales).and_return nil
      subject.available_locales.should == []
    end
  end

  describe :translate do
    it "uses gettext when the key is translatable" do
      FastGettext.stub(:current_repository).and_return 'xy.z.u'=>'a'
      subject.translate('xx','u',:scope=>['xy','z']).should == 'a'
    end

    it "interpolates options" do
      FastGettext.stub(:current_repository).and_return 'ab.c'=>'a%{a}b'
      subject.translate('xx','c',:scope=>['ab'], :a => 'X').should == 'aXb'
    end

    it "can translate with gettext using symbols" do
      FastGettext.stub(:current_repository).and_return 'xy.z.v'=>'a'
      subject.translate('xx',:v ,:scope=>['xy','z']).should == 'a'
    end

    it "can translate with gettext using a flat scope" do
      FastGettext.stub(:current_repository).and_return 'xy.z.x'=>'a'
      subject.translate('xx',:x ,:scope=>'xy.z').should == 'a'
    end

    it "uses the super when the key is not translatable" do
      lambda{subject.translate('xx','y',:scope=>['xy','z'])}.should raise_error(I18n::MissingTranslationData)
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
zena-1.2.8 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb
zena-1.2.7 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb
zena-1.2.6 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb
zena-1.2.5 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb
zena-1.2.4 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb
zena-1.2.3 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb
zena-1.2.2 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb
zena-1.2.1 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb
zena-1.2.0 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb
zena-1.1.3 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb
zena-1.1.2 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb
zena-1.1.1 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb
zena-1.1.0 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb
zena-1.0.0 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb
zena-1.0.0.rc3 vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb
gettext_i18n_rails-0.2.19 spec/gettext_i18n_rails/backend_spec.rb
gettext_i18n_rails-0.2.18 spec/gettext_i18n_rails/backend_spec.rb
gettext_i18n_rails-0.2.17 spec/gettext_i18n_rails/backend_spec.rb
gettext_i18n_rails-0.2.16 spec/gettext_i18n_rails/backend_spec.rb
gettext_i18n_rails-0.2.15 spec/gettext_i18n_rails/backend_spec.rb