Sha256: 6a0d93d6acd1bf0dc7dad267c747689de6a321719672379133f7d67236ab281d

Contents?: true

Size: 1.18 KB

Versions: 10

Compression:

Stored size: 1.18 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:object) { described_class.new(true) }

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

      attr_reader :boolean

      def initialize(boolean)
        @boolean = boolean
      end

      def cmp?(comparator, other)
        boolean.send(comparator, other.boolean)
      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(true) }

    it { should be(false) }

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

  context 'with a different object' do
    let(:other) { described_class.new(false) }

    it { should be(false) }

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

Version data entries

10 entries across 8 versions & 3 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/equalizer-0.0.11/spec/unit/equalizer/methods/eql_predicate_spec.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/equalizer-0.0.11/spec/unit/equalizer/methods/eql_predicate_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/equalizer-0.0.11/spec/unit/equalizer/methods/eql_predicate_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/equalizer-0.0.11/spec/unit/equalizer/methods/eql_predicate_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/equalizer-0.0.11/spec/unit/equalizer/methods/eql_predicate_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/equalizer-0.0.11/spec/unit/equalizer/methods/eql_predicate_spec.rb
equalizer-0.0.11 spec/unit/equalizer/methods/eql_predicate_spec.rb
equalizer-0.0.10 spec/unit/equalizer/methods/eql_predicate_spec.rb
equalizer-0.0.9 spec/unit/equalizer/methods/eql_predicate_spec.rb
equalizer-0.0.8 spec/unit/equalizer/methods/eql_predicate_spec.rb