Sha256: 874465efd587abe0255728c6a5db0f0ae49f54a88816eb812823d46a3e75b4b3

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

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

  let(:klass)  { Optimizer::Algebra::Rename::OrderOperand           }
  let(:base)   { Relation.new([ [ :id, Integer ] ], [ [ 1 ] ].each) }
  let(:object) { klass.new(relation)                                }

  before do
    object.operation.should be_kind_of(Algebra::Rename)
    object.operand.should be_kind_of(Relation::Operation::Order)
  end

  context 'when the operand is an order containing a rename operation' do
    let(:operand)  { base.rename(:id => :other_id).order }
    let(:relation) { operand.rename(:other_id => :id)    }

    it { should be_kind_of(Relation::Operation::Order) }

    its(:operand) { should equal(base) }

    its(:directions) { should == [ base[:id].asc ] }
  end

  context 'when the operand is an order not containing a rename operation' do
    let(:operand)  { base.order                       }
    let(:relation) { operand.rename(:id => :other_id) }

    it { should be_kind_of(Relation::Operation::Order) }

    its(:operand) { should eql(base.rename(:id => :other_id)) }

    its(:directions) { should == [ relation[:other_id].asc ] }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/unit/veritas/optimizer/algebra/rename/order_operand/optimize_spec.rb
veritas-0.0.1 spec/unit/veritas/optimizer/algebra/rename/order_operand/optimize_spec.rb