Sha256: e9fd572f05fb07e38ae98bfcec1caa141604c69e9189969dd600bc3ba2a32858

Contents?: true

Size: 975 Bytes

Versions: 1

Compression:

Stored size: 975 Bytes

Contents

require 'spec_helper'

describe 'Veritas::Optimizer::Algebra::Rename.union_aliases' do
  subject { object.union_aliases(aliases, operand) }

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

  context 'when the operand is a rename' do
    let(:operand)  { base.rename(:id => :other_id)            }
    let(:relation) { operand.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(:operand)  { base                             }
    let(:relation) { operand.rename(:id => :other_id) }

    it { should equal(aliases) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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