Sha256: 5833d56319fdb5b76c7ad1710b2160bc1b87d3c750a9564fb4b6425e90f4564f

Contents?: true

Size: 1.37 KB

Versions: 23

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

require 'test_helper'

module Vedeu

  module Coercers

    describe Style do

      let(:described) { Vedeu::Coercers::Style }
      let(:instance)  { described.new(_value) }
      let(:_value)    {}
      let(:klass)     { Vedeu::Presentation::Style }

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

      describe '.coerce' do
        it { described.must_respond_to(:coerce) }
      end

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

        context 'when the value is already the target class' do
          let(:_value) { klass.new }

          it { subject.must_be_instance_of(klass) }
          it { subject.must_equal(_value) }
        end

        context 'when the value is nil' do
          let(:_value) { nil }

          it { subject.must_be_instance_of(klass) }
        end

        context 'when the value is an Array' do
          let(:_value)  { [:bold, :blink] }

          it { subject.value.must_equal([:bold, :blink]) }
        end

        context 'when the value is a Hash' do
          let(:_value) {
            {
              style: [:bold, :blink]
            }
          }

          it { subject.value.must_equal([:bold, :blink]) }
        end
      end

    end # Style

  end # Coercers

end # Vedeu

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
vedeu-0.8.12 test/lib/vedeu/coercers/style_test.rb
vedeu-0.8.10 test/lib/vedeu/coercers/style_test.rb
vedeu-0.8.9 test/lib/vedeu/coercers/style_test.rb