spec/composite_spec.rb in compo-0.1.1 vs spec/composite_spec.rb in compo-0.1.2

- old
+ new

@@ -244,6 +244,26 @@ expect(children).to receive(:each).once subject.each end end + + describe '#get_child' do + before(:each) { allow(subject).to receive(:children).and_return(children) } + let(:children) { { in_children: child } } + + it 'calls #children' do + expect(subject).to receive(:children).once + subject.get_child(:in_children) + end + + context 'when the argument is in #children' do + it 'returns the child' do + expect(subject.get_child(:in_children)).to eq(child) + end + end + + context 'when the argument is in #children' do + specify { expect(subject.get_child(:not_in_children)).to be_nil } + end + end end