Sha256: 3e9515893671cd3800883b9288987eeaf7380279a57a757f69f3289c43e8ca6b

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require File.join(File.dirname(__FILE__), 'test_helper')

describe "Hirb::String" do

  describe "size" do
    it "should return the size of the string" do
      Hirb::String.size("cats").should == 4
    end

    describe "with a colorized string" do
      it "should return the size of the string without the color codes" do
        Hirb::String.size("\e[31mcats\e[0m").should == 4
      end
    end
  end

  describe "ljust" do
    it "should return a properly padded string" do
      Hirb::String.ljust("cats", 6).should == "cats  "
    end

    describe "with a colorized string" do
      it "should return a properly padded string" do
        Hirb::String.ljust("\e[31mcats\e[0m", 6).should == "\e[31mcats\e[0m  "
      end
    end
  end

  describe "rjust" do
    it "should return a properly padded string" do
      Hirb::String.rjust("cats", 6).should == "  cats"
    end

    describe "with a colorized string" do
      it "should return a properly padded string" do
        Hirb::String.rjust("\e[31mcats\e[0m", 6).should == "  \e[31mcats\e[0m"
      end
    end
  end

  describe "slice" do
    it "should return a properly sliced string" do
      Hirb::String.slice("kittycats", 0, 5).should == "kitty"
    end

    describe "with a colorized string" do
      it "should return a properly sliced string" do
        Hirb::String.slice("\e[31mk\e[30mi\e[29mttyc\e[28mats\e[0m", 0, 5).should == "\e[31mk\e[30mi\e[29mtty\e[28m\e[0m"
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hirb-colors-0.0.1 test/string_test.rb