Sha256: 1f1d393912ed32e15276db62cc8ca349579d1adcbc72104df3c91aeca7730205

Contents?: true

Size: 1.73 KB

Versions: 13

Compression:

Stored size: 1.73 KB

Contents

require 'test_helper'

module WebConsole
  class ColorsTest < ActiveSupport::TestCase
    setup do
      @colors = Colors.new %w( #7f7f7f #ff0000 #00ff00 #ffff00 #5c5cff #ff00ff #00ffff #ffffff )
    end

    test '.[] is an alias for .themes#[]' do
      @colors.class.themes.expects(:[]).with(:light).once
      @colors.class[:light]
    end

    test '.register_theme creates Colors instance for the block' do
      @colors.class.register_theme(:test) { |c| assert c.is_a?(Colors) }
    end

    test '#background is the first color if not specified' do
      assert_equal '#7f7f7f', @colors.background
    end

    test '#background can be explicitly specified' do
      @colors.background '#00ff00'
      assert_equal '#00ff00', @colors.background
    end

    test '#background= is an alias of #background' do
      @colors.background = '#00ff00'
      assert_equal '#00ff00', @colors.background
    end

    test '#foreground is the last color if not specified' do
      assert_equal '#ffffff', @colors.foreground
    end

    test '#foreground can be explicitly specified' do
      @colors.foreground '#f0f0f0'
      assert_equal '#f0f0f0', @colors.foreground
    end

    test '#foreground= is an alias of #foreground' do
      @colors.foreground = '#f0f0f0'
      assert_equal '#f0f0f0', @colors.foreground
    end

    test '#to_json includes the background and the foreground' do
      @colors.background = '#00ff00'
      @colors.foreground = '#f0f0f0'

      expected_json = '["#7f7f7f","#ff0000","#00ff00","#ffff00","#5c5cff","#ff00ff","#00ffff","#ffffff","#00ff00","#f0f0f0"]'
      assert_equal expected_json, @colors.to_json
    end

    test '#default is :light' do
      assert_equal @colors.class.default, @colors.class.themes[:light]
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
web-console-2.0.0.beta4 test/web_console/colors_test.rb
web-console-2.0.0.beta3 test/web_console/colors_test.rb
web-console-rails3-1.0.4 test/web_console/colors_test.rb
web-console-1.0.4 test/web_console/colors_test.rb
web-console-rails3-1.0.3 test/web_console/colors_test.rb
web-console-1.0.3 test/web_console/colors_test.rb
web-console-1.0.2 test/web_console/colors_test.rb
web-console-rails3-1.0.1 test/web_console/colors_test.rb
web-console-1.0.1 test/web_console/colors_test.rb
web-console-rails3-1.0.0 test/web_console/colors_test.rb
web-console-1.0.0 test/web_console/colors_test.rb
web-console-rails3-0.4.1 test/web_console/colors_test.rb
web-console-0.4.0 test/web_console/colors_test.rb