Sha256: 8bbc39e5b787586b20fd368b5551518886b9814cfdddf09aaa4b1663d4490dba

Contents?: true

Size: 1.62 KB

Versions: 8

Compression:

Stored size: 1.62 KB

Contents

# -*- encoding: utf-8 -*- 

require File.dirname(__FILE__) + '/spec_helper'

describe Russian do
  describe "transliteration" do
    def t(str)
      Russian::transliterate(str)
    end

    %w(transliterate translit).each do |method|
      it "'#{method}' method should perform transliteration" do
        str = mock(:str)
        Russian::Transliteration.should_receive(:transliterate).with(str)
        Russian.send(method, str)
      end
    end

    # These tests are from rutils, <http://rutils.rubyforge.org>.
    
    it "should transliterate properly" do
      t("Это просто некий текст").should == "Eto prosto nekiy tekst"
      t("щ").should == "sch"
      t("стансы").should == "stansy"
      t("упущение").should == "upuschenie"
      t("ш").should == "sh"
      t("Ш").should == "SH"
      t("ц").should == "ts"
    end
    
    it "should properly transliterate mixed russian-english strings" do
      t("Это кусок строки русских букв v peremeshku s latinizey i амперсандом (pozor!) & something").should == 
        "Eto kusok stroki russkih bukv v peremeshku s latinizey i ampersandom (pozor!) & something"      
    end
    
    it "should properly transliterate mixed case chars in a string" do
      t("НЕВЕРОЯТНОЕ УПУЩЕНИЕ").should == "NEVEROYATNOE UPUSCHENIE"
      t("Невероятное Упущение").should == "Neveroyatnoe Upuschenie"
      t("Шерстяной Заяц").should == "Sherstyanoy Zayats"
      t("Н.П. Шерстяков").should == "N.P. Sherstyakov"
      t("ШАРОВАРЫ").should == "SHAROVARY"
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
krasivotokak-russian-0.2.1 spec/transliteration_spec.rb
yaroslav-russian-0.2.0 spec/transliteration_spec.rb
yaroslav-russian-0.2.1 spec/transliteration_spec.rb
yaroslav-russian-0.2.2 spec/transliteration_spec.rb
russian-0.2.4 spec/transliteration_spec.rb
russian-0.2.3 spec/transliteration_spec.rb
russian-0.2.2 spec/transliteration_spec.rb
russian-0.2.1 spec/transliteration_spec.rb