Sha256: 9e690af529b29d5f429a94bdb8373c6bec167f80e294327a622f35e99767d7a8

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

require 'test_helper'

module Vedeu

  describe Translator do

    let(:described) { Vedeu::Translator }
    let(:instance)  { described.new(colour) }
    let(:colour)    { '#ff0000' }

    describe '#initialize' do
      it { instance.must_be_instance_of(Translator) }
      it { instance.instance_variable_get('@colour').must_equal(colour) }
    end

    describe '#escape_sequence' do
      subject { instance.escape_sequence }

      context 'when no colour is given' do
        let(:colour) {}

        it { subject.must_equal('') }
      end

      context 'when the colour is a terminal named colour; e.g. :red' do
        let(:colour) { :red }

        it 'raises an exception since the subclasses Background and ' \
           'Foreground handle this' do
          proc { subject }.must_raise(NotImplemented)
        end
      end

      context 'when the colour is a terminal numbered colour; e.g. 122' do
        let(:colour) { 122 }

        it 'raises an exception since the subclasses Background and ' \
           'Foreground handle this' do
          proc { subject }.must_raise(NotImplemented)
        end
      end

      context 'when the colour is a HTML/CSS colour (RGB specified)' do
        let(:colour) { '#ff0000' }

        it 'raises an exception since the subclasses Background and ' \
           'Foreground handle this' do
          proc { subject }.must_raise(NotImplemented)
        end
      end

      context 'when the colour is not supported' do
        let(:colour) { [:not_supported] }

        it { subject.must_equal('') }
      end
    end

  end # Translator

end # Vedeu

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.3.4 test/lib/vedeu/presentation/translator_test.rb