spec/null_composite_spec.rb in compo-0.1.5 vs spec/null_composite_spec.rb in compo-0.2.0

- old
+ new

@@ -1,67 +1,7 @@ require 'spec_helper' require 'compo' +require 'null_composite_shared_examples' describe Compo::NullComposite do - let(:child1) { double(:child1) } - let(:child2) { double(:child2) } - let(:child3) { double(:child3) } - - describe '#add' do - it 'always returns nil' do - expect(subject.add(1, child1)).to be_nil - expect(subject.add(:a, child2)).to be_nil - expect(subject.add(nil, child3)).to be_nil - end - - it 'does not change the result of #children' do - expect(subject.children).to eq({}) - - subject.add(1, child1) - expect(subject.children).to eq({}) - - subject.add(:a, child2) - expect(subject.children).to eq({}) - - subject.add(:a, child3) - expect(subject.children).to eq({}) - end - end - - describe '#remove' do - specify { expect(subject.remove(child1)).to eq(nil) } - - it 'does not change the result of #children' do - expect(subject.children).to eq({}) - - subject.remove(child1) - expect(subject.children).to eq({}) - - subject.remove(child2) - expect(subject.children).to eq({}) - - subject.remove(child3) - expect(subject.children).to eq({}) - 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 + it_behaves_like 'a null composite' end