Sha256: eefdcdd4cd529803deb910ab63b6bc5269a0528eeac3745625461341de64dd13

Contents?: true

Size: 977 Bytes

Versions: 3

Compression:

Stored size: 977 Bytes

Contents

require 'spec_helper'
module Qrb
  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

3 entries across 3 versions & 1 rubygems

Version Path
qrb-0.3.0 spec/unit/type_factory/factory/test_tuple_type.rb
qrb-0.2.0 spec/unit/type_factory/factory/test_tuple_type.rb
qrb-0.1.0 spec/unit/type_factory/factory/test_tuple_type.rb