Sha256: 8056c007a839b47c2a7cc8a98646f5dc5ff8fcf677a30cbefc93c287d5e597b4

Contents?: true

Size: 1.39 KB

Versions: 11

Compression:

Stored size: 1.39 KB

Contents

require_relative "../lib/unicode/blocks"
require "minitest/autorun"

describe Unicode::Blocks do
  describe ".blocks (alias .of)" do
    it "will always return an Array" do
      assert_equal [], Unicode::Blocks.of("")
    end

    it "will return all blocks that characters in the string belong to" do
      assert_equal ["Basic Latin", "Cyrillic"], Unicode::Blocks.of("СC")
    end

    it "will return all blocks in sorted order" do
      assert_equal ["Basic Latin", "Cyrillic"], Unicode::Blocks.of("СA")
      assert_equal ["Basic Latin", "Cyrillic"], Unicode::Blocks.of("AС")
    end

    it "will call .block for every character" do
      mocked_method = MiniTest::Mock.new
      mocked_method.expect :call, "first block",  ["С"]
      mocked_method.expect :call, "second block", ["A"]
      Unicode::Blocks.stub :block, mocked_method do
        Unicode::Blocks.of("СA")
      end
      mocked_method.verify
    end
  end

  describe ".block" do
    it "will return block for that character" do
      assert_equal "Specials", Unicode::Blocks.block("�")
    end

    it "will return No_Block for characters not in any block" do
      assert_equal "No_Block", Unicode::Blocks.block("\u{10c50}")
    end
  end

  describe ".names" do
    it "will return a list of all block names" do
      assert_kind_of Array, Unicode::Blocks.names
      assert_includes Unicode::Blocks.names, "Ancient Symbols"
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
unicode-blocks-1.8.0 spec/unicode_blocks_spec.rb
unicode-blocks-1.7.0 spec/unicode_blocks_spec.rb
unicode-blocks-1.6.0 spec/unicode_blocks_spec.rb
unicode-blocks-1.5.0 spec/unicode_blocks_spec.rb
unicode-blocks-1.4.0 spec/unicode_blocks_spec.rb
unicode-blocks-1.3.0 spec/unicode_blocks_spec.rb
unicode-blocks-1.2.2 spec/unicode_blocks_spec.rb
unicode-blocks-1.2.1 spec/unicode_blocks_spec.rb
unicode-blocks-1.2.0 spec/unicode_blocks_spec.rb
unicode-blocks-1.1.0 spec/unicode_blocks_spec.rb
unicode-blocks-1.0.0 spec/unicode_blocks_spec.rb