From 45c3b1eb9e028198bc91f8d02a8a07c0a676d69b Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Wed, 15 Apr 2020 21:52:04 +0200 Subject: Add tests for xrefs inside nested documents Related to #3 --- spec/fixtures/b/doc-b.adoc | 4 ++++ spec/integration_spec.rb | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/spec/fixtures/b/doc-b.adoc b/spec/fixtures/b/doc-b.adoc index 4f24989..3c4167c 100644 --- a/spec/fixtures/b/doc-b.adoc +++ b/spec/fixtures/b/doc-b.adoc @@ -1,3 +1,7 @@ = Document B xref:c/doc-c.adoc#[] + +|=== +a| xref:../doc-a.adoc#[] +|=== diff --git a/spec/integration_spec.rb b/spec/integration_spec.rb index 19655bf..ede62ed 100644 --- a/spec/integration_spec.rb +++ b/spec/integration_spec.rb @@ -64,6 +64,29 @@ describe 'Intengration Tests' do end end + # Issue #3 + context 'when xref is inside a nested document' do + it 'renders title of the referenced document as reftext' do + given <<~ADOC + |=== + a| xref:doc-a.adoc#[] + |=== + ADOC + should have_anchor href: 'doc-a.html', text: 'Document A' + end + + context 'with relative path' do + subject(:output) do + opts = options.except(:base_dir).merge(safe: :unsafe) + Asciidoctor.load_file("#{FIXTURES_DIR}/b/doc-b.adoc", opts).convert + end + + it 'resolves path relative to the current document' do + should have_anchor href: '../doc-a.html', text: 'Document A' + end + end + end + context 'when extension is not active' do specify 'renders path of the referenced document as reftext' do given 'xref:doc-a.adoc#[]', extensions: [] -- cgit v1.2.3