Sha256: 2055d7e20a287bc14d7feddc2a25aaea10c1772e5756b61ad8a8b920a0558faf

Contents?: true

Size: 1.55 KB

Versions: 8

Compression:

Stored size: 1.55 KB

Contents

require_relative '../../../test_helper'

module Vedeu
  describe Foreground do
    let(:described_class)    { Foreground }
    let(:described_instance) { described_class.new(colour) }
    let(:colour)             {}

    it 'returns a Foreground instance' do
      described_instance.must_be_instance_of(Foreground)
    end

    describe '#escape_sequence' do
      let(:subject) { described_instance.escape_sequence }

      it 'returns a String' do
        subject.must_be_instance_of(String)
      end

      context 'with no colour' do
        it 'returns a String' do
          subject.must_be_instance_of(String)
        end

        it 'returns an escape sequence' do
          subject.must_equal("\e[38;2;39m")
        end
      end

      context 'with a named colour' do
        let(:colour) { :red }

        it 'returns a String' do
          subject.must_be_instance_of(String)
        end

        it 'returns an escape sequence' do
          subject.must_equal("\e[38;2;31m")
        end
      end

      context 'with a html colour' do
        let(:colour) { '#aadd00' }

        it 'returns a String' do
          subject.must_be_instance_of(String)
        end

        it 'returns an escape sequence' do
          subject.must_equal("\e[38;5;148m")
        end
      end

      context 'with a default colour' do
        let(:colour) { :undefined }

        it 'returns a String' do
          subject.must_be_instance_of(String)
        end

        it 'returns an escape sequence' do
          subject.must_equal("\e[38;2;39m")
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vedeu-0.0.25 test/lib/vedeu/output/foreground_test.rb
vedeu-0.0.24 test/lib/vedeu/output/foreground_test.rb
vedeu-0.0.23 test/lib/vedeu/output/foreground_test.rb
vedeu-0.0.22 test/lib/vedeu/output/foreground_test.rb
vedeu-0.0.21 test/lib/vedeu/output/foreground_test.rb
vedeu-0.0.20 test/lib/vedeu/output/foreground_test.rb
vedeu-0.0.19 test/lib/vedeu/output/foreground_test.rb
vedeu-0.0.18 test/lib/vedeu/output/foreground_test.rb