Sha256: 85215090171240b4f661876a7ac981c12167da297dff4c1795db82ce5820ebca
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
require 'composite_shared_examples' RSpec.shared_examples 'a leaf composite' do it_behaves_like 'a composite' let(:c1) { double(:child1) } let(:c2) { double(:child2) } let(:c3) { double(:child3) } describe '#add' do it 'always returns nil' do expect(subject.add(1, c1)).to be_nil expect(subject.add(:a, c2)).to be_nil expect(subject.add(nil, c3)).to be_nil end it 'does not change the result of #children' do expect { subject.add(1, c1) }.to_not change { subject.children }.from({}) expect { subject.add(:a, c2) }.to_not change { subject.children }.from({}) expect { subject.add(:a, c3) }.to_not change { subject.children }.from({}) end end describe '#remove' do specify { expect(subject.remove(c1)).to eq(nil) } it 'does not change the result of #children' do expect { subject.remove(c1) }.to_not change { subject.children }.from({}) expect { subject.remove(c2) }.to_not change { subject.children }.from({}) expect { subject.remove(c3) }.to_not change { subject.children }.from({}) end end describe '#remove_id' do specify { expect(subject.remove_id(:a)).to eq(nil) } it 'does not change the result of #children' do expect(subject.children).to eq({}) subject.remove_id(0) expect(subject.children).to eq({}) subject.remove_id(:a) expect(subject.children).to eq({}) subject.remove_id(nil) expect(subject.children).to eq({}) end end describe '#children' do specify { expect(subject.children).to eq({}) } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
compo-0.5.1 | spec/leaf_composite_shared_examples.rb |
compo-0.5.0 | spec/leaf_composite_shared_examples.rb |