Sha256: 7e627124acf709b16581d4bfaa45575a14404397c61d25d32e593fcdd262bea4

Contents?: true

Size: 981 Bytes

Versions: 2

Compression:

Stored size: 981 Bytes

Contents

require 'spec_helper'
module Finitio
  describe TypeFactory, "Factory#tuple" do

    let(:factory){ TypeFactory.new }

    let(:expected){ factory.tuple(r: Integer) }

    context 'when use with {r: Integer}' do
      subject{ factory.type(r: Integer) }

      it{ should eq(expected) }
    end

    context 'when use with {r: Integer} and a name' do
      subject{ factory.type({r: Integer}, "MyTuple") }

      it{ should eq(expected) }

      it 'should have the correct name' do
        subject.name.should eq("MyTuple")
      end
    end

    context 'when use with {r: 0..255} and a name' do
      subject{ factory.type({r: 0..255}, "MyTuple") }

      it{ should be_a(TupleType) }

      it 'should have the correct constraint on r' do
        subject.dress(r: 36)
        ->{
          subject.dress(r: 543)
        }.should raise_error(TypeError)
      end

      it 'should have the correct name' do
        subject.name.should eq("MyTuple")
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finitio-0.4.1 spec/unit/type_factory/factory/test_tuple_type.rb
finitio-0.4.0 spec/unit/type_factory/factory/test_tuple_type.rb