Sha256: 347a1d2f4472282f323a810c7daaf07c5eff84887fe1e167c1f1bd4a38c5e8de

Contents?: true

Size: 888 Bytes

Versions: 1

Compression:

Stored size: 888 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:object) { described_class.new }

  let(:described_class) do
    Class.new do
      include Equalizer::Methods

      def cmp?(comparator, other)
        !!(comparator && other)
      end
    end
  end

  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 a subclass' do
    let(:other) { Class.new(described_class).new }

    it { should be(false) }

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
equalizer-0.0.7 spec/unit/equalizer/methods/eql_predicate_spec.rb