Sha256: 08e6310c4e39d4edf07c6b82ae8124fcf6253a9de4ea52abb145d16b1e4e4a23

Contents?: true

Size: 1.87 KB

Versions: 4

Compression:

Stored size: 1.87 KB

Contents

# encoding: utf-8
require "spec_helper"

module Corrector
  describe Words do

    describe ".new" do

      specify { expect(Words.new %w(А1)).to eq %w(А1) }
      specify { expect(Words.new "АБ12").to eq %w(АБ 12) }
      specify { expect(Words.new "А Б1 2").to eq %w(А Б 1 2) }
      specify { expect(Words.new "А.Б.").to eq %w(А Б) }
      specify { expect(Words.new "А:Б").to eq %w(А Б) }
      specify { expect(Words.new "А;Б").to eq %w(А Б) }
      specify { expect(Words.new "А,Б").to eq %w(А Б) }
      specify { expect(Words.new "12.").to eq %w(12) }
      specify { expect(Words.new "1.2.1").to eq %w(1.2 1) }
      specify { expect(Words.new "1,2,1").to eq %w(1.2 1) }
      specify { expect(Words.new "А-Б1-2").to eq %w(А Б 1 2) }
      specify { expect(Words.new "А№Б").to eq %w(А № Б) }
      specify { expect(Words.new "А$Б").to eq %w(А $ Б) }
      specify { expect(Words.new "А^Б").to eq %w(А ^ Б) }
      specify { expect(Words.new "12%").to eq %w(12 %) }
      specify { expect(Words.new "А/1/2").to eq %w(А / 1 / 2) }
      specify { expect(Words.new "А|1").to eq %w(А / 1) }
    end

    describe "#source" do

      it "stores a source" do
        source = "abcd"
        expect(Words.new(source).source).to eq source
      end
    end

    describe "#map" do

      it "returns a Words object" do
        expect(Words.new("А1").map { |word| word }).to be_kind_of Words
      end
    end

    describe "#to_s" do

      it "joins words with spaces" do
        expect(Words.new(%w(А 1)).to_s).to eq "А 1"
      end

      it "strips words before joining" do
        expect(Words.new(["А  ", "Б "]).to_s).to eq "А Б"
      end

      it "removes spaces around /" do
        expect(Words.new(%w(А / 1)).to_s).to eq "А/1"
      end

      it "removes ^" do
        expect(Words.new(%w(А ^ 1)).to_s).to eq "А1"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
corrector-0.1.0 spec/services/corrector/words_spec.rb
corrector-0.0.3 spec/services/corrector/words_spec.rb
corrector-0.0.2 spec/services/corrector/words_spec.rb
corrector-0.0.1 spec/services/corrector/words_spec.rb