Sha256: 2ca6bbb3fc05166f2869212b7a84e876a0a4106200f7820f19d4a23b47f8b9ca
Contents?: true
Size: 1.4 KB
Versions: 2
Compression:
Stored size: 1.4 KB
Contents
# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 require 'spec_helper' include TwitterCldr::Localized describe LocalizedArray do describe '#code_points_to_string' do it 'transforms an array of code points into a string' do [0x74, 0x77, 0x69, 0x74, 0x74, 0x65, 0x72].localize.code_points_to_string.should == 'twitter' end end describe 'strings sorting' do let(:locale) { :da } let(:array) { %w[bca aaa abc] } let(:sorted) { %w[aaa abc bca] } let(:localized) { array.localize(locale) } before(:each) { mock(TwitterCldr::Collation::Collator).new(locale) { FakeCollator.new } } describe '#sort' do it 'returns a new LocalizedArray' do localized.sort.should be_instance_of(LocalizedArray) end it 'does not change the original array' do lambda { localized.sort }.should_not change { localized.base_obj } end it 'sorts strings in the array with corresponding collator' do localized.sort.base_obj.should == sorted end end describe '#sort!' do it 'returns self' do localized.sort!.object_id.should == localized.object_id end it 'sorts the array in-place' do localized.sort!.base_obj.should == sorted end end end end class FakeCollator def sort(array) array.sort end def sort!(array) array.sort! end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
twitter_cldr-1.8.1 | spec/localized/localized_array_spec.rb |
twitter_cldr-1.8.0 | spec/localized/localized_array_spec.rb |