Sha256: 72851d8132a6a2de406aa42cdfe9a7f419704530b7306f8b4a3d843d6a4911a6

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:attributes) { [[:id, Integer]]                   }
  let(:object)     { described_class.coerce(attributes) }

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

    it { should be(true) }

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

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

    it { should be(true) }

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

  context 'with an equivalent object of subclasses' do
    let(:other) { Class.new(described_class).coerce(attributes) }

    it { should be(false) }

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

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

    it { should be(false) }

    it 'is symmetric' do
      should eql(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)     { described_class.coerce([attribute1, attribute2]) }
    let(:other)      { described_class.coerce([attribute2, attribute1]) }

    it { should be(true) }

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-0.2.0 spec/unit/axiom/relation/header/eql_spec.rb
axiom-0.1.1 spec/unit/axiom/relation/header/eql_spec.rb