Sha256: 11d14fecce959558263ce1147beae6bd158bb15e3fbbe9cf1bd31833e3d2de8a

Contents?: true

Size: 814 Bytes

Versions: 3

Compression:

Stored size: 814 Bytes

Contents

require 'spec_helper'
module Qrb
  describe UnionType, "dress" do

    let(:type)      { UnionType.new([intType, floatType], "union") }

    subject{ type.dress(arg) }

    context 'with an Integer' do
      let(:arg){ 12 }

      it{ should be(arg) }
    end

    context 'with a Float' do
      let(:arg){ 12.0 }

      it{ should be(arg) }
    end

    context 'with a String' do
      let(:arg){ "foo" }

      subject{
        type.dress(arg) rescue $!
      }

      it 'should raise an Error' do
        subject.should be_a(TypeError)
        subject.message.should eq("Invalid value `foo` for union")
      end

      it 'should have no cause' do
        subject.cause.should be_nil
      end

      it 'should have an empty location' do
        subject.location.should eq('')
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qrb-0.3.0 spec/unit/type/union_type/test_dress.rb
qrb-0.2.0 spec/unit/type/union_type/test_dress.rb
qrb-0.1.0 spec/unit/type/union_type/test_dress.rb