Sha256: 682bf5a82bb044235d7a91ac5177abda90d980041d72202e27b659cfdef34cb7

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

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

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

  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) }

  context 'when the left and right are expressions' do
    let(:predicate) { PredicateSpecs::Object.new(attribute, attribute) }

    it 'renames the matching expressions' do
      should eql(PredicateSpecs::Object.new(other, other))
    end
  end

  context 'when the left is an expression, and the right is a value' do
    let(:predicate) { PredicateSpecs::Object.new(attribute, 1) }

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

  context 'when the right is an expression, and the left is a value' do
    let(:predicate) { PredicateSpecs::Object.new(1, attribute) }

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

  context 'when the left and right are constants' do
    let(:predicate) { PredicateSpecs::Object.new(1, 1) }

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

Version data entries

1 entries across 1 versions & 1 rubygems

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