Sha256: 7bb31dee22ebf77b2a3fab59f8cb6dab2900bcfdf8006fd289407213969393a9
Contents?: true
Size: 1.31 KB
Versions: 7
Compression:
Stored size: 1.31 KB
Contents
# frozen_string_literal: true RSpec.describe Equatable, 'subclass' do let(:name) { 'Value' } context 'when subclass' do let(:value) { 11 } let(:klass) { ::Class.new do include Equatable attr_reader :value def initialize(value) @value = value end end } let(:subclass) { ::Class.new(klass) } subject { subclass.new(value) } before { allow(klass).to receive(:name).and_return(name) } it { expect(subclass.superclass).to eq(klass) } it { is_expected.to respond_to(:value) } describe '#inspect' do it { expect(subject.inspect).to eql('#<Value value=11>') } end describe '#eql?' do context 'when objects are similar' do let(:other) { subject.dup } it { expect(subject.eql?(other)).to eql(true) } end context 'when objects are different' do let(:other) { double('other') } it { expect(subject.eql?(other)).to eql(false) } end end describe '#==' do context 'when objects are similar' do let(:other) { subject.dup } it { expect(subject == other).to eql(true) } end context 'when objects are different' do let(:other) { double('other') } it { expect(subject == other).to eql(false) } end end end end
Version data entries
7 entries across 7 versions & 2 rubygems