Sha256: a384c221029483175aa01183969fdeb76b7b9c23c16fd69b6fe3caf4d88f8db8

Contents?: true

Size: 1.86 KB

Versions: 19

Compression:

Stored size: 1.86 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
        expect(subject.heading).to 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
        expect(subject.name).to 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
        expect(subject.name).to 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
        expect(subject.name).to 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
        expect(subject.name).to 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
        expect(subject.name).to eq("{{a: intType}}")
      end
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
finitio-0.12.0 spec/type_factory/dsl/test_relation.rb
finitio-0.11.4 spec/type_factory/dsl/test_relation.rb
finitio-0.11.3 spec/type_factory/dsl/test_relation.rb
finitio-0.11.2 spec/type_factory/dsl/test_relation.rb
finitio-0.11.1 spec/type_factory/dsl/test_relation.rb
finitio-0.10.0 spec/type_factory/dsl/test_relation.rb
finitio-0.9.1 spec/type_factory/dsl/test_relation.rb
finitio-0.9.0 spec/type_factory/dsl/test_relation.rb
finitio-0.8.0 spec/type_factory/dsl/test_relation.rb
finitio-0.7.0 spec/type_factory/dsl/test_relation.rb
finitio-0.7.0.pre.rc4 spec/type_factory/dsl/test_relation.rb
finitio-0.7.0.pre.rc3 spec/type_factory/dsl/test_relation.rb
finitio-0.7.0.pre.rc2 spec/type_factory/dsl/test_relation.rb
finitio-0.7.0.pre.rc1 spec/type_factory/dsl/test_relation.rb
finitio-0.6.1 spec/type_factory/dsl/test_relation.rb
finitio-0.6.0 spec/type_factory/dsl/test_relation.rb
finitio-0.5.2 spec/type_factory/dsl/test_relation.rb
finitio-0.5.1 spec/type_factory/dsl/test_relation.rb
finitio-0.5.0 spec/type_factory/dsl/test_relation.rb