spec/charwidth_spec.rb in charwidth-0.1.3 vs spec/charwidth_spec.rb in charwidth-0.1.4

- old
+ new

@@ -1,44 +1,88 @@ # encoding: UTF-8 require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Charwidth" do - it "should convert full-width alphabet to half-width" do - Charwidth.normalize("ABCabc").should == "ABCabc" - end - it "should convert full-width number to half-width" do - Charwidth.normalize("123").should == "123" - end - it "should convert full-width ASCII symbol before numbers to half-width" do - Charwidth.normalize("!"#").should == "!\"#" - end - it "should convert full-width ASCII symbol between numbers and upper-case to half-width" do - Charwidth.normalize(":;").should == ":;" - end - it "should convert full-width ASCII symbol between upper-case and lower-case to half-width" do - Charwidth.normalize("[\]").should == "[\\]" - end - it "should convert full-width ASCII symbol after lower-case to half-width" do - Charwidth.normalize("{|}").should == "{|}" - end + describe ".normalize" do + it "should convert full-width alphabet to half-width" do + expect(Charwidth.normalize("ABCabc")).to eq("ABCabc") + end + it "should convert full-width number to half-width" do + expect(Charwidth.normalize("123")).to eq("123") + end + it "should convert full-width ASCII symbol before numbers to half-width" do + expect(Charwidth.normalize("!"#")).to eq("!\"#") + end + it "should convert full-width ASCII symbol between numbers and upper-case to half-width" do + expect(Charwidth.normalize(":;")).to eq(":;") + end + it "should convert full-width ASCII symbol between upper-case and lower-case to half-width" do + expect(Charwidth.normalize("[\]")).to eq("[\\]") + end + it "should convert full-width ASCII symbol after lower-case to half-width" do + expect(Charwidth.normalize("{|}")).to eq("{|}") + end - it "should convert half-width CJK punctuation to full-width" do - Charwidth.normalize("、。「」").should == "、。「」" - end + it "should convert half-width CJK punctuation to full-width" do + expect(Charwidth.normalize("、。「」")).to eq("、。「」") + end - it "should convert half-width katakana to full-width" do - Charwidth.normalize("アカサタナハマヤラワヲンァャッー・").should == "アカサタナハマヤラワヲンァャッー・" - Charwidth.normalize("タチツテトナニヌネノ").should == "タチツテトナニヌネノ" - end + it "should convert half-width katakana to full-width" do + expect(Charwidth.normalize("アカサタナハマヤラワヲンァャッー・")).to eq("アカサタナハマヤラワヲンァャッー・") + expect(Charwidth.normalize("タチツテトナニヌネノ")).to eq("タチツテトナニヌネノ") + end - it "should unify half-width (semi) voiced katakana with dakuon to full-width" do - Charwidth.normalize("ガザダバパ").should == "ガザダバパ" - end + it "should unify half-width (semi) voiced katakana with dakuon to full-width" do + expect(Charwidth.normalize("ガザダバパ")).to eq("ガザダバパ") + end - it "should convert half-width hangul to full-width" do - Charwidth.normalize("アカサタナハマヤラワヲンァャッー・").should == "アカサタナハマヤラワヲンァャッー・" + it "should convert half-width hangul to full-width" do + expect(Charwidth.normalize("アカサタナハマヤラワヲンァャッー・")).to eq("アカサタナハマヤラワヲンァャッー・") + end + + it "should convert IDIOGRAPHIC-SPACE to SPACE" do + expect(Charwidth.normalize("\u3000")).to eq(" ") + end end - it "should convert IDIOGRAPHIC-SPACE to SPACE" do - Charwidth.normalize("\u3000").should == " " + describe ".to_full_width" do + it "should convert half-width alphabet to full-width" do + expect(Charwidth.to_full_width("ABCabc")).to eq("ABCabc") + end + it "should convert half-width number to full-width" do + expect(Charwidth.to_full_width("123")).to eq("123") + end + it "should convert half-width ASCII symbol before numbers to full-width" do + expect(Charwidth.to_full_width("!\"#")).to eq("!"#") + end + it "should convert half-width ASCII symbol between numbers and upper-case to full-width" do + expect(Charwidth.to_full_width(":;")).to eq(":;") + end + it "should convert half-width ASCII symbol between upper-case and lower-case to full-width" do + expect(Charwidth.to_full_width("[\\]")).to eq("[\]") + end + it "should convert half-width ASCII symbol after lower-case to full-width" do + expect(Charwidth.to_full_width("{|}")).to eq("{|}") + end + + it "should convert half-width CJK punctuation to full-width" do + expect(Charwidth.to_full_width("、。「」")).to eq("、。「」") + end + + it "should convert half-width katakana to full-width" do + expect(Charwidth.to_full_width("アカサタナハマヤラワヲンァャッー・")).to eq("アカサタナハマヤラワヲンァャッー・") + expect(Charwidth.to_full_width("タチツテトナニヌネノ")).to eq("タチツテトナニヌネノ") + end + + it "should unify half-width (semi) voiced katakana with dakuon to full-width" do + expect(Charwidth.to_full_width("ガザダバパ")).to eq("ガザダバパ") + end + + it "should convert half-width hangul to full-width" do + expect(Charwidth.to_full_width("アカサタナハマヤラワヲンァャッー・")).to eq("アカサタナハマヤラワヲンァャッー・") + end + + it "should convert SPACE to IDIOGRAPHIC-SPACE" do + expect(Charwidth.to_full_width(" ")).to eq("\u3000") + end end end