Sha256: 352094a57d7a06aeeb3138c30a23eaabb3784cb3921df771716505aa5a1fef8c

Contents?: true

Size: 1.59 KB

Versions: 112

Compression:

Stored size: 1.59 KB

Contents

#!/usr/local/bin/ruby -w

# tc_color_scheme.rb
#
#  Created by Jeremy Hinegardner on 2007-01-24.  
#  Copyright 2007 Jeremy Hinegardner. All rights reserved.
#
#  This is Free Software.  See LICENSE and COPYING for details.

require "test/unit"

require "highline"
require "stringio"

class TestColorScheme < Test::Unit::TestCase
  def setup
    @input    = StringIO.new
    @output   = StringIO.new
    @terminal = HighLine.new(@input, @output)
    
    @old_color_scheme = HighLine.color_scheme
  end
  
  def teardown
    HighLine.color_scheme = @old_color_scheme
  end

  def test_using_color_scheme
    assert_equal(false,HighLine.using_color_scheme?)

    HighLine.color_scheme = HighLine::ColorScheme.new
    assert_equal(true,HighLine.using_color_scheme?)
  end

  def test_scheme
    HighLine.color_scheme = HighLine::SampleColorScheme.new

    @terminal.say("This should be <%= color('warning yellow', :warning) %>.")
    assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string)
    @output.rewind
    
    @terminal.say("This should be <%= color('warning yellow', 'warning') %>.")
    assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string)
    @output.rewind

    @terminal.say("This should be <%= color('warning yellow', 'WarNing') %>.")
    assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string)
    @output.rewind

    # turn it back off, should raise an exception
    HighLine.color_scheme = @old_color_scheme
    assert_raises(NameError) {
      @terminal.say("This should be <%= color('nothing at all', :error) %>.")
    }
  end
end 

Version data entries

112 entries across 111 versions & 14 rubygems

Version Path
delano-rye-0.6.2 vendor/highline-1.5.1/test/tc_color_scheme.rb
delano-rye-0.6.3 vendor/highline-1.5.1/test/tc_color_scheme.rb
delano-rye-0.6.4 vendor/highline-1.5.1/test/tc_color_scheme.rb
malysz87-highline-1.5.10 test/tc_color_scheme.rb
malysz87-highline-1.5.11 test/tc_color_scheme.rb
malysz87-highline-1.5.4 test/tc_color_scheme.rb
malysz87-highline-1.5.5 test/tc_color_scheme.rb
solutious-rudy-0.6.0 vendor/highline-1.5.1/test/tc_color_scheme.rb
solutious-rudy-0.6.1 vendor/highline-1.5.1/test/tc_color_scheme.rb
solutious-rudy-0.6.2 vendor/highline-1.5.1/test/tc_color_scheme.rb
solutious-rudy-0.6.3 vendor/highline-1.5.1/test/tc_color_scheme.rb
solutious-rudy-0.6.4 vendor/highline-1.5.1/test/tc_color_scheme.rb
solutious-rudy-0.6.5 vendor/highline-1.5.1/test/tc_color_scheme.rb
solutious-rudy-0.6.6 vendor/highline-1.5.1/test/tc_color_scheme.rb
solutious-rudy-0.6.7 vendor/highline-1.5.1/test/tc_color_scheme.rb
solutious-rudy-0.6.8 vendor/highline-1.5.1/test/tc_color_scheme.rb
solutious-rudy-0.7.0 vendor/highline-1.5.1/test/tc_color_scheme.rb
solutious-rudy-0.7.1 vendor/highline-1.5.1/test/tc_color_scheme.rb
solutious-rudy-0.7.2 vendor/highline-1.5.1/test/tc_color_scheme.rb
solutious-rudy-0.7.3 vendor/highline-1.5.1/test/tc_color_scheme.rb