Sha256: f2734ed362cd3d1d1aa5c2e7d8c28382cb7a56dc8a4d45f8eefc756fb0927e18

Contents?: true

Size: 1.05 KB

Versions: 20

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

describe PragmaticSegmenter::Languages do
  describe '.get_language_by_code' do
    context "when language code defined" do
      PragmaticSegmenter::Languages::LANGUAGE_CODES.each do |code, lang|
        it "returns '#{lang}' for '#{code}'" do
          expect(described_class.get_language_by_code(code)).to eql(lang)
        end
      end
    end

    context "when language code not defined" do
      it "returns 'PragmaticSegmenter::Languages::Common'" do
        expect(described_class.get_language_by_code('xxyyzz')).to eql(PragmaticSegmenter::Languages::Common)
      end
    end

    context "when language code empty string" do
      it "returns 'PragmaticSegmenter::Languages::Common'" do
        expect(described_class.get_language_by_code('')).to eql(PragmaticSegmenter::Languages::Common)
      end
    end

    context "when language code nil" do
      it "returns 'PragmaticSegmenter::Languages::Common'" do
        expect(described_class.get_language_by_code(nil)).to eql(PragmaticSegmenter::Languages::Common)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
pragmatic_segmenter-0.3.24 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.23 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.22 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.21 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.20 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.19 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.18 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.17 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.16 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.15 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.14 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.13 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.12 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.10 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.9 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.8 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.7 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.6 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.5 spec/pragmatic_segmenter/languages_spec.rb
pragmatic_segmenter-0.3.4 spec/pragmatic_segmenter/languages_spec.rb