Sha256: 7a0082a01c6d1a255f2eca6306063efeed58a07478d4a7ac4e384229d7ea7daa

Contents?: true

Size: 888 Bytes

Versions: 2

Compression:

Stored size: 888 Bytes

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 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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
compo-0.3.0 spec/branch_shared_examples.rb
compo-0.2.0 spec/branch_shared_examples.rb