Sha256: 423c6d2d9d7aeb52deb8ccbfc2aba4aa85a39d5e31ea32bf241c33d039f4751d

Contents?: true

Size: 983 Bytes

Versions: 2

Compression:

Stored size: 983 Bytes

Contents

require 'spec_helper'
module Alf
  describe Relation, '.type for recursive types' do

    shared_examples_for 'the expected recursive type' do
      it{ should be_a(Class) }

      it 'should have correct super class' do
        subject.superclass.should be(Relation)
      end

      it 'should have correct heading' do
        subject.heading.should eq(Heading[name: Integer, children: subject])
      end
    end

    context 'with a hash' do
      subject{
        Relation.type(name: Integer){|r| {children: r} }
      }

      it_should_behave_like 'the expected recursive type'
    end

    context 'with a heading' do
      subject{
        Relation.type(Heading[name: Integer]){|r| {children: r} }
      }

      it_should_behave_like 'the expected recursive type'
    end

    context 'with a tuple type' do
      subject{
        Relation.type(Tuple[name: Integer]){|r| {children: r} }
      }

      it_should_behave_like 'the expected recursive type'
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-relation/relation/class/test_recursive_type.rb
alf-core-0.14.0 spec/unit/alf-relation/relation/class/test_recursive_type.rb