Sha256: 7fc347f0021baded217ddc7b153b6ae8b0ea4442b9df499940470f48ca1b258d

Contents?: true

Size: 1.4 KB

Versions: 14

Compression:

Stored size: 1.4 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

class ClassyEnumTranslation < ClassyEnum::Base
end

class ClassyEnumTranslation::One < ClassyEnumTranslation
end

class ClassyEnumTranslation::Two < ClassyEnumTranslation
end

describe ClassyEnum::Translation do

  before do
    I18n.reload!
    I18n.backend.store_translations :en, :classy_enum => {:classy_enum_translation => {:one => 'One!', :two => 'Two!' } }
    I18n.backend.store_translations :es, :classy_enum => {:classy_enum_translation => {:one => 'Uno', :two => 'Dos' } }
  end

  context '#text' do
    subject { ClassyEnumTranslation::One.new }

    context 'default' do
      before { I18n.reload! }
      its(:text) { should == 'One' }
    end

    context 'en' do
      before { I18n.locale = :en }
      its(:text) { should == 'One!' }
    end

    context 'es' do
      before { I18n.locale = :es }
      its(:text) { should == 'Uno' }
    end
  end

  context '.select_options' do
    subject { ClassyEnumTranslation }

    context 'default' do
      before { I18n.reload! }
      its(:select_options) { should == [["One", "one"], ["Two", "two"]] }
    end

    context 'en' do
      before { I18n.locale = :en }
      its(:select_options) { should == [["One!", "one"], ["Two!", "two"]] }
    end

    context 'es' do
      before { I18n.locale = :es }
      its(:select_options) { should == [["Uno", "one"], ["Dos", "two"]] }
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
classy_enum-3.5.0 spec/classy_enum/translation_spec.rb
classy_enum-3.5.0.beta2 spec/classy_enum/translation_spec.rb
classy_enum-3.5.0.beta spec/classy_enum/translation_spec.rb
classy_enum-3.4.0 spec/classy_enum/translation_spec.rb
classy_enum-3.4.0.beta1 spec/classy_enum/translation_spec.rb
classy_enum-3.3.2 spec/classy_enum/translation_spec.rb
classy_enum-3.3.1 spec/classy_enum/translation_spec.rb
classy_enum-3.3.0 spec/classy_enum/translation_spec.rb
classy_enum-3.2.1 spec/classy_enum/translation_spec.rb
classy_enum-3.2.0 spec/classy_enum/translation_spec.rb
classy_enum-3.1.3 spec/classy_enum/translation_spec.rb
classy_enum-3.1.2 spec/classy_enum/translation_spec.rb
classy_enum-3.1.1 spec/classy_enum/translation_spec.rb
classy_enum-3.1.0 spec/classy_enum/translation_spec.rb