Sha256: 9140358505dbde27d8c597a8bbb6b618e1325560b287bab5d1dd4f91d990b635

Contents?: true

Size: 788 Bytes

Versions: 6

Compression:

Stored size: 788 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'spec_helper'

describe TTY::Terminal::Color, '#set' do
  let(:string) { 'string' }

  it 'applies green text to string' do
    subject.set(string, :green).should == "\e[32m#{string}\e[0m"
  end

  it 'applies red text background to string' do
    subject.set(string, :on_red).should == "\e[41m#{string}\e[0m"
  end

  it 'applies style and color to string' do
    text = subject.set(string, :bold, :green)
    text.should == "\e[1m\e[32m#{string}\e[0m"
  end

  it 'applies style, color and background to string' do
    text = subject.set(string, :bold, :green, :on_blue)
    text.should == "\e[1m\e[32m\e[44m#{string}\e[0m"
  end

  it 'errors for unkown color' do
    expect { subject.set(string, :crimson) }.to raise_error(ArgumentError)
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tty-0.0.11 spec/tty/terminal/color/set_spec.rb
tty-0.0.10 spec/tty/terminal/color/set_spec.rb
tty-0.0.9 spec/tty/terminal/color/set_spec.rb
tty-0.0.8 spec/tty/terminal/color/set_spec.rb
tty-0.0.7 spec/tty/terminal/color/set_spec.rb
tty-0.0.6 spec/tty/terminal/color/set_spec.rb