Sha256: 8a641dff93a5b173c174d4dddd836d60b196ccf885d37bad881c469cab7cd037

Contents?: true

Size: 1019 Bytes

Versions: 1

Compression:

Stored size: 1019 Bytes

Contents

require 'spec_helper'

describe 'Veritas::Optimizer::Algebra::Rename#aliases' do
  subject { object.aliases }

  let(:klass)     { Optimizer::Algebra::Rename           }
  let(:attribute) { Attribute::Integer.new(:id)          }
  let(:header)    { Relation::Header.new([ attribute ])  }
  let(:base)      { Relation.new(header, [ [ 1 ] ].each) }
  let(:aliases)   { { :id => :other_id }                 }
  let(:object)    { klass.new(relation)                  }

  before do
    object.operation.should be_kind_of(Algebra::Rename)
  end

  context 'when the operand is a rename' do
    let(:relation) { base.rename(aliases).rename(:other_id => :another_id) }

    it { should be_kind_of(Algebra::Rename::Aliases) }

    it { should == { attribute => attribute.rename(:another_id) } }
  end

  context 'when the operand is not a rename' do
    let(:relation) { base.rename(aliases) }

    it { should be_kind_of(Algebra::Rename::Aliases) }

    it { should == { attribute => attribute.rename(:other_id) } }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/unit/veritas/optimizer/algebra/rename/aliases_spec.rb