Sha256: a0c662a531d8be3a377da7f6a5ac6374b7561d60d247a2bbf0b91d31d1285c2e

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

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

2 entries across 2 versions & 1 rubygems

Version Path
finitio-0.4.1 spec/unit/type_factory/dsl/test_set.rb
finitio-0.4.0 spec/unit/type_factory/dsl/test_set.rb