Sha256: 0288c3d94032d0c367c25ce001ea1071a015011bb183870d0ca8bc20d1c37fce

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

require 'test_helper'

module Vedeu
  class TestStyle
    include Virtus.model

    attribute :style, Style
  end

  describe Style do
    describe '#style' do
      it 'returns an escape sequence for a single style' do
        model = TestStyle.new(style: 'normal')
        model.style.must_equal("\e[24m\e[21m\e[27m")
      end

      it 'returns an escape sequence for multiple styles' do
        model = TestStyle.new(style: ['normal', 'underline'])
        model.style.must_equal("\e[24m\e[21m\e[27m\e[4m")
      end

      it 'returns an empty string for an unknown style' do
        model = TestStyle.new(style: 'unknown')
        model.style.must_equal('')
      end

      it 'has a style attribute' do
        model = TestStyle.new(style: ['normal'])
        model.style.must_equal("\e[24m\e[21m\e[27m")
      end

      it 'returns an empty string for empty or nil' do
        model = TestStyle.new(style: '')
        model.style.must_equal('')
      end

      it 'returns an empty string for empty or nil' do
        model = TestStyle.new(style: nil)
        model.style.must_equal('')
      end

      it 'returns an empty string for empty or nil' do
        model = TestStyle.new(style: [])
        model.style.must_equal('')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.1.10 test/lib/vedeu/models/style_test.rb