Sha256: 55260e94b79d3ddc8bd28a8f8e977685a2c3a455d113e2a11aebbbd243024249

Contents?: true

Size: 1.46 KB

Versions: 11

Compression:

Stored size: 1.46 KB

Contents

require File.expand_path('spec/spec_helper')

describe Ruco::Screen do
  describe :curses_style do
    it "is 'normal' for nothing" do
      Ruco::Screen.curses_style(:normal).should == 256
    end

    it "is red for red" do
      pending
      Ruco::Screen.curses_style(:red).should == Curses::color_pair( Curses::COLOR_RED )
    end

    it "is reverse for reverse" do
      Ruco::Screen.curses_style(:reverse).should == 512
    end

    it "raises on unknown style" do
      lambda{
        Ruco::Screen.curses_style(:foo)
      }.should raise_error
    end

    describe 'without colors' do
      before do
        Ruco::Screen.class_eval '@@styles = {}' # clear cache
        $ruco_colors = false
      end

      after do
        $ruco_colors = true
      end

      it "is 'normal' for normal" do
        Ruco::Screen.curses_style(:normal).should == Curses::A_NORMAL
      end

      it "is reverse for reverse" do
        Ruco::Screen.curses_style(:reverse).should == Curses::A_REVERSE
      end

      it "is normal for unknown style" do
        Ruco::Screen.curses_style(:foo).should == Curses::A_NORMAL
      end
    end
  end

  describe :html_to_terminal_color do
    # http://www.mudpedia.org/wiki/Xterm_256_colors
    [
      ['#ff0000', 196],
      ['#00ff00', 46],
      ['#0000ff', 21],
      ['#ffffff', 231]
    ].each do |html,term|
      it "converts #{html} to #{term}" do
        Ruco::Screen.html_to_terminal_color(html).should == term
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ruco-0.2.0.beta12 spec/ruco/screen_spec.rb
ruco-0.2.0.beta11 spec/ruco/screen_spec.rb
ruco-0.2.0.beta10 spec/ruco/screen_spec.rb
ruco-0.2.0.beta9 spec/ruco/screen_spec.rb
ruco-0.2.0.beta8 spec/ruco/screen_spec.rb
ruco-0.2.0.beta7 spec/ruco/screen_spec.rb
ruco-0.2.0.beta6 spec/ruco/screen_spec.rb
ruco-0.2.0.beta5 spec/ruco/screen_spec.rb
ruco-0.2.0.beta4 spec/ruco/screen_spec.rb
ruco-0.2.0.beta3 spec/ruco/screen_spec.rb
ruco-0.2.0.beta spec/ruco/screen_spec.rb