Sha256: 5eeac554909b370c76c3168215a381c691148b6169471c51bb48dd7b3fbfb05d

Contents?: true

Size: 1.56 KB

Versions: 19

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

19 entries across 19 versions & 1 rubygems

Version Path
test-kitchen-1.2.1 spec/kitchen/color_spec.rb
test-kitchen-1.2.0 spec/kitchen/color_spec.rb
test-kitchen-1.1.1 spec/kitchen/color_spec.rb
test-kitchen-1.1.0 spec/kitchen/color_spec.rb
test-kitchen-1.0.0 spec/kitchen/color_spec.rb
test-kitchen-1.0.0.rc.2 spec/kitchen/color_spec.rb
test-kitchen-1.0.0.rc.1 spec/kitchen/color_spec.rb
test-kitchen-1.0.0.beta.4 spec/kitchen/color_spec.rb
test-kitchen-1.0.0.beta.3 spec/kitchen/color_spec.rb
test-kitchen-1.0.0.beta.2 spec/kitchen/color_spec.rb
test-kitchen-1.0.0.beta.1 spec/kitchen/color_spec.rb
test-kitchen-1.0.0.alpha.7 spec/kitchen/color_spec.rb
test-kitchen-1.0.0.alpha.6 spec/kitchen/color_spec.rb
test-kitchen-1.0.0.alpha.5 spec/kitchen/color_spec.rb
test-kitchen-1.0.0.alpha.4 spec/kitchen/color_spec.rb
test-kitchen-1.0.0.alpha.3 spec/kitchen/color_spec.rb
test-kitchen-1.0.0.alpha.2 spec/kitchen/color_spec.rb
test-kitchen-1.0.0.alpha.1 spec/kitchen/color_spec.rb
test-kitchen-1.0.0.alpha.0 spec/kitchen/color_spec.rb