Sha256: df0db95f4e39dd73b5783a92f34b40f73fdbcd1435109fdebaf1707104251f56

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require_relative '../../test_helper'

module Vedeu
  describe Colour do
    let(:klass)      { Colour }
    let(:instance)   { klass.new }
    let(:pair)       { [] }

    it 'returns an instance of self' do
      instance.must_be_instance_of(Vedeu::Colour)
    end

    describe '.set' do
      subject { klass.set(pair) }

      context 'when both the foreground and background is specified' do
        let(:pair) { [:red, :yellow] }

        it 'returns the code for red on yellow' do
          subject.must_equal("\e[31;43m")
        end
      end

      context 'when a foreground is specified' do
        let(:pair) { [:blue] }

        it 'returns the code for blue on default' do
          subject.must_equal("\e[34;49m")
        end
      end

      context 'when a background is specified' do
        let(:pair) { [nil, :cyan] }

        it 'returns the code for default with cyan background' do
          subject.must_equal("\e[39;46m")
        end
      end

      context 'when an invalid foreground/background is specified' do
        let(:pair) { [:melon, :raspberry] }

        it 'returns the default code' do
          subject.must_equal("\e[39;49m")
        end
      end

      context 'when no foreground/background is specified' do
        let(:pair) { [] }

        it 'returns the reset code' do
          subject.must_equal("\e[0m")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.0.3 test/lib/vedeu/colour_test.rb