Sha256: bd8d33a9ef9cfa6b70028db24fc5d8d4346ab79f28bff71a0709bb1544e5ba4b
Contents?: true
Size: 959 Bytes
Versions: 7
Compression:
Stored size: 959 Bytes
Contents
# frozen_string_literal: true RSpec.describe Equatable, '#eql?' do let(:name) { 'Value' } let(:value) { 11 } let(:klass) { ::Class.new do include Equatable attr_reader :value def initialize(value) @value = value end end } let(:object) { klass.new(value) } subject { object.eql?(other) } context 'with the same object' do let(:other) { object } it { is_expected.to eql(true) } it 'is symmetric' do is_expected.to eql(other.eql?(object)) end end context 'with an equivalent object' do let(:other) { object.dup } it { is_expected.to eql(true) } it 'is symmetric' do is_expected.to eql(other.eql?(object)) end end context 'with an equivalent object of a subclass' do let(:other) { ::Class.new(klass).new(value) } it { is_expected.to eql(false) } it 'is symmetric' do is_expected.to eql(other.eql?(object)) end end end
Version data entries
7 entries across 7 versions & 2 rubygems