Sha256: 32c4a3a9596a305113621e07a32d6c181b11529975c6d62867ec7d0cfca14308

Contents?: true

Size: 895 Bytes

Versions: 19

Compression:

Stored size: 895 Bytes

Contents

require 'spec_helper'
module Finitio
  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
        expect(subject).to be_a(TypeError)
        expect(subject.message).to eq("Invalid union `foo`")
      end

      it 'should have a cause' do
        expect(subject.cause).to be_a(TypeError)
        expect(subject.cause.message).to eq("Invalid intType `foo`")
      end

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

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
finitio-0.12.0 spec/type/union_type/test_dress.rb
finitio-0.11.4 spec/type/union_type/test_dress.rb
finitio-0.11.3 spec/type/union_type/test_dress.rb
finitio-0.11.2 spec/type/union_type/test_dress.rb
finitio-0.11.1 spec/type/union_type/test_dress.rb
finitio-0.10.0 spec/type/union_type/test_dress.rb
finitio-0.9.1 spec/type/union_type/test_dress.rb
finitio-0.9.0 spec/type/union_type/test_dress.rb
finitio-0.8.0 spec/type/union_type/test_dress.rb
finitio-0.7.0 spec/type/union_type/test_dress.rb
finitio-0.7.0.pre.rc4 spec/type/union_type/test_dress.rb
finitio-0.7.0.pre.rc3 spec/type/union_type/test_dress.rb
finitio-0.7.0.pre.rc2 spec/type/union_type/test_dress.rb
finitio-0.7.0.pre.rc1 spec/type/union_type/test_dress.rb
finitio-0.6.1 spec/type/union_type/test_dress.rb
finitio-0.6.0 spec/type/union_type/test_dress.rb
finitio-0.5.2 spec/type/union_type/test_dress.rb
finitio-0.5.1 spec/type/union_type/test_dress.rb
finitio-0.5.0 spec/type/union_type/test_dress.rb