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

- old
+ new

@@ -1,30 +1,9 @@ require 'spec_helper' require 'compo' +require 'branch_shared_examples' +require 'null_composite_shared_examples' describe Compo::Leaf do - describe '#initialize' do - it 'initialises with no parent' do - expect(subject.parent).to be_nil - end - - it 'initialises with an ID function returning nil' do - expect(subject.id).to be_nil - end - end - - describe '#url' do - context 'when the Leaf has no parent' do - it 'returns the empty string' do - expect(subject.url).to eq('') - end - end - context 'when the Leaf is the child of a root' do - let(:parent) { Compo::HashBranch.new } - before(:each) { subject.move_to(parent, :id) } - - it 'returns /ID, where ID is the ID of the Leaf' do - expect(subject.url).to eq('/id') - end - end - end + it_behaves_like 'a branch' + it_behaves_like 'a null composite' end