Sha256: 412e3e639fb9d2c923e71a647ef8dd26286b79776a9b1f6d735e02906724e9c4
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
require 'url_referenceable_shared_examples' require 'movable_shared_examples' shared_examples 'a branch' do it_behaves_like 'a URL referenceable object' it_behaves_like 'a movable object' describe '#initialize' do it 'initialises with a Parentless as parent' do expect(subject.parent).to be_a(Compo::Parentless) end it 'initialises with an ID function returning nil' do expect(subject.id).to be_nil end end describe '#url' do context 'when the Branch has no parent' do it 'returns the empty string' do expect(subject.url).to eq('') end end context 'when the Branch 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 describe '#move_to' do context 'when the Branch has a parent' do context 'when the new parent is nil' do let(:parent) { Compo::HashBranch.new } before(:each) { subject.move_to(parent, :id) } it 'loses its previous parent' do expect(subject.move_to(nil, :id).parent).to be_a(Compo::Parentless) end it 'is no longer a child of its parent' do subject.move_to(nil, :id) expect(parent.children).to_not include(subject) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
compo-0.3.1 | spec/branch_shared_examples.rb |