Sha256: b72f08bbf3e935bf6d0c3c339fc57d947908a3be54298d154eb5db015844930c

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'
module Alf
  module Algebra
    describe Operator, "with_operands" do

      let(:operand_1) { an_operand.with_heading(:id => Integer).with_keys([:id])    }
      let(:operand_2) { an_operand.with_heading(:name => String).with_keys([:name]) }

      let(:operator) { a_lispy.project(operand_1, [:foo], :allbut => true) }

      subject{ operator.with_operands(operand_2) }

      it{ should be_a(Project) }

      before do
        operator.heading
        operator.keys
      end

      it "replaces the operands but keeps params unchanged" do
        subject.operands.first.should be(operand_2)
        subject.attributes.should eq(AttrList[:foo])
        subject.allbut.should be_true
      end

      it "keeps the original unchanged" do
        operator.operands.first.should be(operand_1)
        subject.attributes.should eq(AttrList[:foo])
        subject.allbut.should be_true
      end

      it 'does not keep computed heading from the original' do
        subject.heading.should eq(Heading.coerce(:name => String))
      end

      it 'does not keep computed keys from the original' do
        subject.keys.should eq(Keys[ [:name] ])
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-algebra/operator/commons/test_with_operands.rb
alf-core-0.14.0 spec/unit/alf-algebra/operator/commons/test_with_operands.rb
alf-core-0.13.1 spec/unit/alf-algebra/operator/commons/test_with_operands.rb
alf-core-0.13.0 spec/unit/alf-algebra/operator/commons/test_with_operands.rb