spec/rpub/chapter_spec.rb in rpub-0.1.0 vs spec/rpub/chapter_spec.rb in rpub-0.2.0
- old
+ new
@@ -19,15 +19,35 @@
it 'should change when content changes' do
subject.uid.should_not == described_class.new('foo', 2, 'bar').uid
end
end
- describe '#id' do
- its(:id) { should == 'chapter-1' }
+ describe '#xml_id' do
+ its(:xml_id) { should == 'chapter-1' }
end
describe '#filename' do
its(:filename) { should == 'chapter-1-untitled.html' }
+ end
+
+ describe '#outline' do
+ context 'when there are no headings' do
+ let(:subject) { described_class.new('foo', 1, 'document') }
+ its(:outline) { should have(0).elements }
+ its(:outline) { should be_empty }
+ end
+
+ context 'when there are headings' do
+ let(:subject) { described_class.new('# foo', 1, 'document') }
+ its(:outline) { should have(1).elements }
+
+ context 'a single heading entry' do
+ let(:subject) { described_class.new('# foo', 1, 'document').outline.first }
+ its(:level) { should == 1 }
+ its(:text) { should == 'foo' }
+ its(:html_id) { should == 'foo' }
+ end
+ end
end
describe '#title' do
context 'without a suitable markdown title' do
its(:title) { should == 'untitled' }