Sha256: 9dd7c139b25419a58d399708bbafceb13707e52882533b9ed22058ca42903b7a

Contents?: true

Size: 905 Bytes

Versions: 4

Compression:

Stored size: 905 Bytes

Contents

require 'spec_helper'
module Alf
  describe Relation, '[]' do

    let(:rel){ Alf::Relation(sid: 'S1', sname: "Jones", city: "London") }

    context 'as a selection' do
      subject{ rel[:pid => :sid] }

      let(:expected){ Alf::Relation(pid: 'S1') }

      it{ should eq(expected) }
    end

    context 'as a selection mixing symbols and values' do
      subject{ rel[pid: :sid, test: ""] }

      let(:expected){ Alf::Relation(pid: 'S1', test: "") }

      it{ should eq(expected) }
    end

    context 'as a selection mixing list, then selection' do
      subject{ rel[:sid, pid: :sid, test: ""] }

      let(:expected){ Alf::Relation(sid: 'S1', pid: 'S1', test: "") }

      it{ should eq(expected) }
    end

    context 'as a projection' do
      subject{ rel[:sid, :city] }

      let(:expected){ Alf::Relation(sid: 'S1', city: "London") }

      it{ should eq(expected) }
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-relation/relation/test_sugar.rb
alf-core-0.14.0 spec/unit/alf-relation/relation/test_sugar.rb
alf-core-0.13.1 spec/unit/alf-relation/relation/test_sugar.rb
alf-core-0.13.0 spec/unit/alf-relation/relation/test_sugar.rb