Sha256: cd9cf6f24b46f60c8235acfb277e42ef4a5a41f09888c726792eb97eb85987bd

Contents?: true

Size: 1.84 KB

Versions: 2

Compression:

Stored size: 1.84 KB

Contents

require 'spec_helper'
module Finitio
  describe TypeFactory, "DSL#relation" do

    let(:factory){ TypeFactory.new }

    let(:heading){
      Heading.new([ Attribute.new(:a, intType) ])
    }

    shared_examples_for "The Relation[a: Int] type" do

      it{ should be_a(RelationType) }

      it 'should have the correct heading' do
        subject.heading.should eq(heading)
      end
    end

    before do
      subject
    end

    context 'when used with the standard signature' do
      subject{
        factory.relation(heading, "MyRelation")
      }

      it_should_behave_like "The Relation[a: Int] type"

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

    context 'when used with a tuple type' do
      subject{
        factory.relation(TupleType.new(heading), "MyRelation")
      }

      it_should_behave_like "The Relation[a: Int] type"

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

    context 'when used with a hash and ruby classes' do
      subject{
        factory.relation(a: Integer)
      }

      it_should_behave_like "The Relation[a: Int] type"

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

    context 'when used with a hash and a name' do
      subject{
        factory.relation({a: Integer}, "MyRelation")
      }

      it_should_behave_like "The Relation[a: Int] type"

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

    context 'when used with a hash and types' do
      subject{
        factory.relation(a: intType)
      }

      it_should_behave_like "The Relation[a: Int] type"

      it 'should have the correct name' do
        subject.name.should eq("{{a: intType}}")
      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_relation.rb
finitio-0.4.0 spec/unit/type_factory/dsl/test_relation.rb