spec/leaf_spec.rb in compo-0.1.3 vs spec/leaf_spec.rb in compo-0.1.4

- old
+ new

@@ -9,6 +9,22 @@ 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 end