Sha256: 8c02cae3b96a8ecc3c16c82687ef571517ec5b520ef55f1493b760de9c0f44f1

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Algebra::Restriction, '#eql?' do
  subject { object.eql?(other) }

  let(:operand)   { Relation.new([ [ :id, Integer ] ], [ [ 1 ] ]) }
  let(:predicate) { proc { true }                                 }
  let(:object)    { described_class.new(operand, predicate)       }

  context 'with the same object' do
    let(:other) { object }

    it { should be(true) }

    it 'is symmetric' do
      should == other.eql?(object)
    end
  end

  context 'with an equivalent object' do
    let(:other) { object.dup }

    it { should be(true) }

    it 'is symmetric' do
      should == other.eql?(object)
    end
  end

  context 'with an equivalent object of a subclass' do
    let(:other) { Class.new(described_class).new(operand, predicate) }

    it { should be(false) }

    it 'is symmetric' do
      should == other.eql?(object)
    end
  end

  context 'with an object having a different operand' do
    let(:other_operand)   { Relation.new([ [ :id, Integer ] ], [ [ 2 ] ])       }
    let(:other_predicate) { predicate                                           }
    let(:other)           { described_class.new(other_operand, other_predicate) }

    it { should be(false) }

    it 'is symmetric' do
      should == other.eql?(object)
    end
  end

  context 'with an object having a different predicate' do
    let(:other_operand)   { operand                                             }
    let(:other_predicate) { proc { false }                                      }
    let(:other)           { described_class.new(other_operand, other_predicate) }

    it { should be(false) }

    it 'is symmetric' do
      should == other.eql?(object)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.4 spec/unit/veritas/algebra/restriction/eql_spec.rb