Sha256: d77e4050d4bbebbf532729fa1317fcf79675e5f3db37a6eefa897efe0cb0583a

Contents?: true

Size: 1.63 KB

Versions: 11

Compression:

Stored size: 1.63 KB

Contents

require 'test_helper'

module Vedeu

  describe Style do

    let(:described) { Vedeu::Style }
    let(:instance)  { described.new(value) }
    let(:value)     { 'bold' }

    describe 'alias methods' do
      it { instance.must_respond_to(:escape_sequences) }
    end

    describe '#initialize' do
      it { instance.must_be_instance_of(described) }
      it { instance.instance_variable_get('@value').must_equal('bold') }
    end

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

      it { subject.must_be_instance_of(Hash) }

      it 'returns an attributes hash for this instance' do
        subject.must_equal({ style: 'bold' })
      end
    end

    describe '#to_s' do
      let(:value) {}

      subject { instance.to_s }

      it { subject.must_be_instance_of(String) }
      it { subject.must_equal('') }

      describe 'for a single style' do
        let(:value) { 'normal' }

        it 'returns an escape sequence' do
          subject.must_equal("\e[24m\e[22m\e[27m")
        end
      end

      describe 'for multiple styles' do
        let(:value) { ['normal', 'underline'] }

        it 'returns an escape sequence for multiple styles' do
          subject.must_equal("\e[24m\e[22m\e[27m\e[4m")
        end
      end

      describe 'for an unknown style' do
        let(:value) { 'unknown' }

        it 'returns an empty string for an unknown style' do
          subject.must_equal('')
        end
      end

      describe 'for an empty or nil' do
        let(:value) { '' }

        it 'returns an empty string for empty or nil' do
          subject.must_equal('')
        end
      end
    end

  end # Style

end # Vedeu

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
vedeu-0.4.13 test/lib/vedeu/output/style_test.rb
vedeu-0.4.12 test/lib/vedeu/output/style_test.rb
vedeu-0.4.11 test/lib/vedeu/output/style_test.rb
vedeu-0.4.10 test/lib/vedeu/output/style_test.rb
vedeu-0.4.9 test/lib/vedeu/output/style_test.rb
vedeu-0.4.8 test/lib/vedeu/output/style_test.rb
vedeu-0.4.7 test/lib/vedeu/output/style_test.rb
vedeu-0.4.6 test/lib/vedeu/output/style_test.rb
vedeu-0.4.5 test/lib/vedeu/output/style_test.rb
vedeu-0.4.4 test/lib/vedeu/output/style_test.rb
vedeu-0.4.3 test/lib/vedeu/output/style_test.rb