Sha256: b9cc04012dc7076bbcd7a5d857c155e171912dcf2c07965eda948df6cdd7d749

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Algebra::Rename::RenameOperandAndEmptyAliases, '#optimizable?' do
  subject { object.optimizable? }

  let(:header)   { Relation::Header.new([ [ :id, Integer ], [ :name, String ] ]) }
  let(:base)     { Relation.new(header, [ [ 1, 'Dan Kubb' ] ].each)              }
  let(:relation) { operand.rename(aliases)                                       }
  let(:object)   { described_class.new(relation)                                 }

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

  context 'when the operand is a rename and there are aliases' do
    let(:aliases) { { :id => :other_id }              }
    let(:operand) { base.rename(:name => :other_name) }

    it { should be(false) }
  end

  context 'when the operand is a rename and there no aliases' do
    let(:aliases) { { :other_id => :id }          }
    let(:operand) { base.rename(:id => :other_id) }

    it { should be(true) }
  end

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

    it { should be(false) }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
veritas-optimizer-0.0.7 spec/unit/veritas/optimizer/algebra/rename/rename_operand_and_empty_aliases/optimizable_spec.rb
veritas-optimizer-0.0.6 spec/unit/veritas/optimizer/algebra/rename/rename_operand_and_empty_aliases/optimizable_spec.rb
veritas-optimizer-0.0.5 spec/unit/veritas/optimizer/algebra/rename/rename_operand_and_empty_aliases/optimizable_spec.rb
veritas-optimizer-0.0.4 spec/unit/veritas/optimizer/algebra/rename/rename_operand_and_empty_aliases/optimizable_spec.rb