summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2020-04-15 21:52:04 +0200
committerJakub Jirutka <jakub@jirutka.cz>2020-04-16 00:35:40 +0200
commit45c3b1eb9e028198bc91f8d02a8a07c0a676d69b (patch)
treefb190d737636e8bc03ae866258842712964246b6
parent8202ba2f3c34607a752ee9e68257fe1e70a05df0 (diff)
Add tests for xrefs inside nested documents
Related to #3
-rw-r--r--spec/fixtures/b/doc-b.adoc4
-rw-r--r--spec/integration_spec.rb23
2 files changed, 27 insertions, 0 deletions
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: []