Sha256: 6c7e4f968f0bf5e25b1eec3c240b4e8063e64c50e5ad7e09f2cf537a2325f164
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
# encoding: UTF-8 require 'spec_helper' describe Localized do let(:klass) do Class.new do include ActiveData::Model attribute :name, type: Localized end end let(:translations) { { en: 'Hello', ru: 'Привет' } } before { I18n.locale = :en } describe '#name_translations' do subject { klass.new name_translations: translations } its(:name_translations) { should == translations.stringify_keys } its(:name) { should == translations[:en] } end describe '#name' do subject { klass.new name: 'Hello' } its(:name_translations) { should == { 'en' => 'Hello' } } its(:name) { should == 'Hello' } end describe '#name_before_type_cast' do let(:object) { Object.new } subject { klass.new name: object } its(:name_before_type_cast) { should == object } end context 'fallbacks' do subject { klass.new name_translations: { ru: 'Привет' } } context do its(:name) { should be_nil } end context do before do require "i18n/backend/fallbacks" I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) I18n.fallbacks.map(en: :ru) end its(:name) { should == 'Привет' } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_data-0.1.0 | spec/lib/active_data/model/attributes/localized_spec.rb |