Sha256: 8f62f18b5fc9da7113aa2e1f4fa667adf356898cf9dc5352ae2e9eb81ef9ca8b

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

# encoding: UTF-8

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

require 'spec_helper'

describe TwitterCldr::Normalization do

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

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

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

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

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

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

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twitter_cldr-3.0.1 spec/normalization_spec.rb
twitter_cldr-3.0.0 spec/normalization_spec.rb