Sha256: d515b51a2c75e0e9a2b17b70f481f331f614f81be89f949992a28229a34dd66b

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

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

  let(:klass)      { Relation::Header      }
  let(:attributes) { [ [ :id, Integer ] ]  }
  let(:object)     { klass.new(attributes) }

  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 subclasses' do
    let(:other) { Class.new(klass).new(attributes) }

    it { should be(false) }

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

  context 'with an object having different attributes' do
    let(:other_attributes) { [ [ :name, String ] ]       }
    let(:other)            { klass.new(other_attributes) }

    it { should be(false) }

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

  context 'with an object having equivalent attributes in a different order' do
    let(:attribute1) { [ :id,   Integer ]                    }
    let(:attribute2) { [ :name, String  ]                    }
    let(:object)     { klass.new([ attribute1, attribute2 ]) }
    let(:other)      { klass.new([ attribute2, attribute1 ]) }

    it { should be(true) }

    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/header/eql_spec.rb