Sha256: 23328d9a862343fa71e802ba64d399c222c1df92811080e1322dba02e2d20518

Contents?: true

Size: 1.4 KB

Versions: 35

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'

describe TwitterCldr::Normalization do

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

    it 'it uses NFD by default' do
      expect(Eprun).to receive(:normalize).with(string, :nfd).and_return(normalized_string)
      expect(TwitterCldr::Normalization.normalize(string)).to eq(normalized_string)
    end

    it "uses specified algorithm if there is any" do
      expect(Eprun).to receive(:normalize).with(string, :nfkd).and_return(normalized_string)
      expect(TwitterCldr::Normalization.normalize(string, using: :nfkd)).to eq(normalized_string)
    end

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

    it 'accepts normalizer name in upper case' do
      expect(Eprun).to receive(:normalize).with(string, :nfkd).and_return(normalized_string)
      expect(TwitterCldr::Normalization.normalize(string, using: :NFKD)).to eq(normalized_string)
    end

    it 'accepts a string' do
      expect(Eprun).to receive(:normalize).with(string, :nfkd).and_return(normalized_string)
      expect(TwitterCldr::Normalization.normalize(string, using: 'nfkd')).to eq(normalized_string)
    end

  end

end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
twitter_cldr-6.12.0 spec/normalization_spec.rb
twitter_cldr-6.11.5 spec/normalization_spec.rb
twitter_cldr-6.11.4 spec/normalization_spec.rb
twitter_cldr-6.11.3 spec/normalization_spec.rb
twitter_cldr-6.11.2 spec/normalization_spec.rb
twitter_cldr-6.11.1 spec/normalization_spec.rb
twitter_cldr-6.11.0 spec/normalization_spec.rb
twitter_cldr-6.10.0 spec/normalization_spec.rb
twitter_cldr-6.9.0 spec/normalization_spec.rb
twitter_cldr-6.8.0 spec/normalization_spec.rb
twitter_cldr-6.7.0 spec/normalization_spec.rb
twitter_cldr-6.6.2 spec/normalization_spec.rb
twitter_cldr-6.6.1 spec/normalization_spec.rb
twitter_cldr-6.6.0 spec/normalization_spec.rb
twitter_cldr-6.5.0 spec/normalization_spec.rb
twitter_cldr-6.4.0 spec/normalization_spec.rb
twitter_cldr-6.3.0 spec/normalization_spec.rb
twitter_cldr-6.2.0 spec/normalization_spec.rb
twitter_cldr-6.1.0 spec/normalization_spec.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/twitter_cldr-4.4.5/spec/normalization_spec.rb