Sha256: 1a71b5813a37011e7daed5273542ea3a678b07339a643cecf31f44080d58d88a

Contents?: true

Size: 1.56 KB

Versions: 17

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

17 entries across 17 versions & 1 rubygems

Version Path
test-kitchen-1.23.3 spec/kitchen/color_spec.rb
test-kitchen-1.23.2 spec/kitchen/color_spec.rb
test-kitchen-1.22.1 spec/kitchen/color_spec.rb
test-kitchen-1.23.0 spec/kitchen/color_spec.rb
test-kitchen-1.22.0 spec/kitchen/color_spec.rb
test-kitchen-1.21.2 spec/kitchen/color_spec.rb
test-kitchen-1.21.1 spec/kitchen/color_spec.rb
test-kitchen-1.21.0 spec/kitchen/color_spec.rb
test-kitchen-1.20.0 spec/kitchen/color_spec.rb
test-kitchen-1.19.2 spec/kitchen/color_spec.rb
test-kitchen-1.19.1 spec/kitchen/color_spec.rb
test-kitchen-1.19.0 spec/kitchen/color_spec.rb
test-kitchen-1.18.0 spec/kitchen/color_spec.rb
test-kitchen-1.17.0 spec/kitchen/color_spec.rb
test-kitchen-1.16.0 spec/kitchen/color_spec.rb
test-kitchen-1.15.0 spec/kitchen/color_spec.rb
test-kitchen-1.14.2 spec/kitchen/color_spec.rb