Sha256: 4d6260815ecb6b7a3621377f6556d5c9a53974a9ca6d50b16a3bccb62e7be183

Contents?: true

Size: 1.56 KB

Versions: 30

Compression:

Stored size: 1.56 KB

Contents

# -*- encoding: utf-8 -*-
#
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
#
# Copyright (C) 2013, Fletcher Nichol
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require_relative "../spec_helper"

require "kitchen/color"

describe Kitchen::Color do

  describe ".escape" do

    it "returns an empty string if name is nil" do
      Kitchen::Color.escape(nil).must_equal ""
    end

    it "returns an empty string if name is not in the ANSI hash" do
      Kitchen::Color.escape(:puce).must_equal ""
    end

    it "returns an ansi escape sequence string for cyan" do
      Kitchen::Color.escape(:cyan).must_equal "\e[36m"
    end

    it "returns an ansi escape sequence string for reset" do
      Kitchen::Color.escape(:reset).must_equal "\e[0m"
    end
  end

  describe ".colorize" do

    it "returns an ansi escaped string colored yellow" do
      Kitchen::Color.colorize("hello", :yellow).must_equal "\e[33mhello\e[0m"
    end

    it "returns an unescaped string if color is not in the ANSI hash" do
      Kitchen::Color.colorize("double", :rainbow).must_equal "double"
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
test-kitchen-1.14.1 spec/kitchen/color_spec.rb
test-kitchen-1.14.0 spec/kitchen/color_spec.rb
test-kitchen-1.13.2 spec/kitchen/color_spec.rb
test-kitchen-1.13.1 spec/kitchen/color_spec.rb
test-kitchen-1.13.0 spec/kitchen/color_spec.rb
test-kitchen-1.12.0 spec/kitchen/color_spec.rb
test-kitchen-1.11.1 spec/kitchen/color_spec.rb
test-kitchen-1.11.0 spec/kitchen/color_spec.rb
test-kitchen-1.10.2 spec/kitchen/color_spec.rb
test-kitchen-1.10.2.dev spec/kitchen/color_spec.rb
test-kitchen-1.10.0 spec/kitchen/color_spec.rb
test-kitchen-1.9.2 spec/kitchen/color_spec.rb
test-kitchen-1.9.1 spec/kitchen/color_spec.rb
test-kitchen-1.9.0 spec/kitchen/color_spec.rb
test-kitchen-1.8.0 spec/kitchen/color_spec.rb
test-kitchen-1.7.3 spec/kitchen/color_spec.rb
test-kitchen-1.7.2 spec/kitchen/color_spec.rb
test-kitchen-1.7.1 spec/kitchen/color_spec.rb
test-kitchen-1.7.1.dev spec/kitchen/color_spec.rb
test-kitchen-1.6.0 spec/kitchen/color_spec.rb