Sha256: deabd4079934de519f17397221492226c2252eee56133624dea756a7fa6306a4

Contents?: true

Size: 1.31 KB

Versions: 15

Compression:

Stored size: 1.31 KB

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

require 'spec_helper'

include TwitterCldr

describe TwitterCldr::Normalization do

  describe "#normalize" do
    let(:string) { 'string' }
    let(:normalized_string) { 'normalized' }

    it 'it uses NFD by default' do
      mock(TwitterCldr::Normalization::NFD).normalize(string) { normalized_string }
      Normalization.normalize(string).should == normalized_string
    end

    it "uses specified algorithm if there is any" do
      mock(TwitterCldr::Normalization::NFKD).normalize(string) { normalized_string }
      Normalization.normalize(string, :using => :NFKD).should == normalized_string
    end

    it "raises an ArgumentError if passed an unsupported normalizer name" do
      lambda { Normalization.normalize(string, :using => :blarg) }.should raise_error(ArgumentError)
    end

    it 'accepts normalizer name in a lower case' do
      mock(TwitterCldr::Normalization::NFKD).normalize(string) { normalized_string }
      Normalization.normalize(string, :using => :nfkd).should == normalized_string
    end

    it 'accepts a string' do
      mock(TwitterCldr::Normalization::NFKD).normalize(string) { normalized_string }
      Normalization.normalize(string, :using => 'NFKD').should == normalized_string
    end

  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
twitter_cldr-2.4.3 spec/normalization_spec.rb
twitter_cldr-3.0.0.beta1 spec/normalization_spec.rb
twitter_cldr-2.4.2 spec/normalization_spec.rb
twitter_cldr-2.4.1 spec/normalization_spec.rb
twitter_cldr-2.4.0 spec/normalization_spec.rb
twitter_cldr-2.2.0 spec/normalization_spec.rb
twitter_cldr-2.1.1 spec/normalization_spec.rb
twitter_cldr-2.1.0 spec/normalization_spec.rb
twitter_cldr-2.0.2 spec/normalization_spec.rb
twitter_cldr-2.0.1 spec/normalization_spec.rb
twitter_cldr-2.0.0 spec/normalization_spec.rb
twitter_cldr-1.9.1 spec/normalization_spec.rb
twitter_cldr-1.9.0 spec/normalization_spec.rb
twitter_cldr-1.8.1 spec/normalization_spec.rb
twitter_cldr-1.8.0 spec/normalization_spec.rb