Sha256: d87098aa0640d94d492ecd420227bfbfda09beb63adcedcc51b69fe592c694a5

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'
module Qrb
  describe TypeFactory, "DSL#set" do

    let(:factory){ TypeFactory.new }

    shared_examples_for "The Set[Int] type" do

      it{ should be_a(SetType) }

      it 'should have the correct element type' do
        subject.elm_type.should eq(intType)
      end
    end

    before do
      subject
    end

    context 'when used with a ruby class' do
      subject{
        factory.set(Integer)
      }

      it_should_behave_like "The Set[Int] type"

      it 'should have the correct name' do
        subject.name.should eq("{Integer}")
      end
    end

    context 'when used with a type' do
      subject{
        factory.set(intType)
      }

      it_should_behave_like "The Set[Int] type"

      it 'should have the correct name' do
        subject.name.should eq("{intType}")
      end
    end

    context 'when used with an explicit name' do
      subject{
        factory.set(intType, "MySet")
      }

      it_should_behave_like "The Set[Int] type"

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

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qrb-0.3.0 spec/unit/type_factory/dsl/test_set.rb
qrb-0.2.0 spec/unit/type_factory/dsl/test_set.rb
qrb-0.1.0 spec/unit/type_factory/dsl/test_set.rb