Sha256: df60fc1b0fcf5cdc17b85ae8befc3d07db05cffb31f3aaab5d26a4ae98cc8274

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'
require File.expand_path('../fixtures/classes', __FILE__)

describe 'Veritas::Logic::Predicate#rename' do
  subject { object.rename(aliases) }

  let(:klass)     { PredicateSpecs::Object                                    }
  let(:attribute) { Attribute::Integer.new(:id)                               }
  let(:other)     { attribute.rename(:other_id)                               }
  let(:header)    { Relation::Header.new([ attribute ])                       }
  let(:aliases)   { Algebra::Rename::Aliases.coerce(header, :id => :other_id) }
  let(:left)      { attribute                                                 }
  let(:right)     { attribute                                                 }
  let(:object)    { klass.new(left, right)                                    }

  context 'when the left and right are expressions' do
    it 'renames the matching expressions' do
      should eql(klass.new(other, other))
    end
  end

  context 'when the left is an expression, and the right is a value' do
    let(:right) { 1 }

    it 'renames the matching expressions' do
      should eql(klass.new(other, 1))
    end
  end

  context 'when the right is an expression, and the left is a value' do
    let(:left)  { 1 }

    it 'renames the matching expressions' do
      should eql(klass.new(1, other))
    end
  end

  context 'when the left and right are constants' do
    let(:left)  { 1 }
    let(:right) { 1 }

    it 'does nothing' do
      should equal(object)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/unit/veritas/logic/predicate/rename_spec.rb