Sha256: 9ca057e4ed9608c6bb950437980a41310badd8d32454fa9ac52a9b392afdd014

Contents?: true

Size: 799 Bytes

Versions: 4

Compression:

Stored size: 799 Bytes

Contents

require 'spec_helper'
module Alf
  describe Heading, "coerce" do

    subject{ Heading.coerce(arg) }

    context 'with a Heading' do
      let(:arg){ Heading.new :foo => String }

      it{ should be(arg) }
    end

    context 'with a Hash' do
      let(:arg){ {:foo => String} }

      it{ should eq(Heading.new :foo => String) }
    end

    context 'with an empty Array' do
      let(:arg){ [] }

      it{ should eq(Heading::EMPTY) }
    end

    context 'with a non-empty Array' do
      let(:arg){ ["name", "String"] }

      it{ should eq(Heading.new :name => String) }
    end

    context 'with something unrecognized' do
      let(:arg){ true }

      specify{
        lambda{ subject }.should raise_error(TypeError, /Can't convert `true` into (.*?)Heading/)
      }
    end

  end 
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-types/heading/class/test_coerce.rb
alf-core-0.14.0 spec/unit/alf-types/heading/class/test_coerce.rb
alf-core-0.13.1 spec/unit/alf-types/heading/class/test_coerce.rb
alf-core-0.13.0 spec/unit/alf-types/heading/class/test_coerce.rb