Sha256: b779ee2fc58a11ff8ba1816d3c35bdc0fa3c00d6538a99db72d8f743f6ca2d86

Contents?: true

Size: 1.76 KB

Versions: 1

Compression:

Stored size: 1.76 KB

Contents

require 'spec_helper'

describe 'Veritas::Relation::Operation::Offset#eql?' do
  subject { object.eql?(other) }

  let(:klass)   { Relation::Operation::Offset                                       }
  let(:operand) { Relation.new([ [ :id, Integer ] ], [ [ 1 ], [ 2 ], [ 3 ] ]).order }
  let(:offset)  { 1                                                                 }
  let(:object)  { klass.new(operand, offset)                                        }

  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(klass).new(operand, offset) }

    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 ] ], [ [ 1 ], [ 2 ] ]).order }
    let(:other_offset)  { offset                                                     }
    let(:other)         { klass.new(other_operand, other_offset)                     }

    it { should be(false) }

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

  context 'with an object having a different offset' do
    let(:other_operand) { operand                                }
    let(:other_offset)  { 2                                      }
    let(:other)         { klass.new(other_operand, other_offset) }

    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.2 spec/unit/veritas/relation/operation/offset/eql_spec.rb