Sha256: 6c412d2b9874abef30bda6426771bd875db039dd4120fcdde20c028c5c42a2ce

Contents?: true

Size: 893 Bytes

Versions: 4

Compression:

Stored size: 893 Bytes

Contents

require 'spec_helper'
module Alf
  describe Relvar, 'to_relation' do
    include Relvar

    subject{ to_relation }

    let(:expected_value){ Relation(sid: 1, name: "Smith") }

    def to_cog
      [{sid: 1, name: "Smith"}]
    end

    context 'when the heading is supported' do

      def heading(*)
        Heading.new(sid: Integer, name: String)
      end

      it 'trusts the heading' do
        subject.class.heading[:sid].should eq(Integer)
      end

      it 'gets the tuples from the cog' do
        subject.should eq(expected_value)
      end
    end

    context 'when the heading is not supported' do

      def heading(*)
        raise NotSupportedError
      end

      it 'infers the heading' do
        subject.class.heading[:sid].should eq(Fixnum)
      end

      it 'gets the tuples from the cog' do
        subject.should eq(expected_value)
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-relvar/shared/test_to_relation.rb
alf-core-0.14.0 spec/unit/alf-relvar/shared/test_to_relation.rb
alf-core-0.13.1 spec/unit/alf-relvar/shared/test_to_relation.rb
alf-core-0.13.0 spec/unit/alf-relvar/shared/test_to_relation.rb