Sha256: 5720540699e0c80938f4226c173920ff1871d3e767588c888b6eac59cd4fec4f

Contents?: true

Size: 1.53 KB

Versions: 2

Compression:

Stored size: 1.53 KB

Contents

# encoding: utf-8

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

describe Function::Binary, '#rename' do
  subject { object.rename(aliases) }

  let(:described_class) { BinarySpecs::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(:object)          { described_class.new(left, right)                       }

  context 'left and right are renamed' do
    let(:left)  { attribute.eq(1) }
    let(:right) { attribute.eq(2) }

    it { should be_instance_of(described_class) }

    its(:left) { should == other.eq(1) }

    its(:right) { should == other.eq(2) }
  end

  context 'left is renamed' do
    let(:left)  { attribute.eq(1) }
    let(:right) { other.eq(2)     }

    it { should be_instance_of(described_class) }

    its(:left) { should == other.eq(1) }

    its(:right) { should be(right) }
  end

  context 'right is renamed' do
    let(:left)  { other.eq(1)     }
    let(:right) { attribute.eq(2) }

    it { should be_instance_of(described_class) }

    its(:left) { should be(left) }

    its(:right) { should == other.eq(2) }
  end

  context 'right and right are not renamed' do
    let(:left)  { other.eq(1) }
    let(:right) { other.eq(2) }

    it { should be(object) }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-0.2.0 spec/unit/axiom/function/binary/rename_spec.rb
axiom-0.1.1 spec/unit/axiom/function/binary/rename_spec.rb