summaryrefslogtreecommitdiff
path: root/test/reader_test.rb
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2019-02-10 04:17:55 -0700
committerDan Allen <dan.j.allen@gmail.com>2019-02-10 04:21:27 -0700
commit4c2ec06f840bf771bc23515e08e8c1d5a7f289c2 (patch)
treefacad00215cc6acacd10778fdebe8ddb31c90aa4 /test/reader_test.rb
parent26aea61999fdc915823b51651c5ded360cfc65ee (diff)
use indented (squiggly) heredoc strings in reader_test
Diffstat (limited to 'test/reader_test.rb')
-rw-r--r--test/reader_test.rb1057
1 files changed, 508 insertions, 549 deletions
diff --git a/test/reader_test.rb b/test/reader_test.rb
index 45fc7686..139dadad 100644
--- a/test/reader_test.rb
+++ b/test/reader_test.rb
@@ -4,10 +4,10 @@ require_relative 'test_helper'
class ReaderTest < Minitest::Test
DIRNAME = ASCIIDOCTOR_TEST_DIR
- SAMPLE_DATA = <<-EOS.chomp.split(::Asciidoctor::LF)
-first line
-second line
-third line
+ SAMPLE_DATA = <<~'EOS'.chomp.split(::Asciidoctor::LF)
+ first line
+ second line
+ third line
EOS
context 'Reader' do
@@ -287,10 +287,10 @@ third line
context 'Read lines until' do
test 'Read lines until until end' do
- lines = <<-EOS.lines
-This is one paragraph.
+ lines = <<~'EOS'.lines
+ This is one paragraph.
-This is another paragraph.
+ This is another paragraph.
EOS
reader = Asciidoctor::Reader.new lines, nil, normalize: true
@@ -302,10 +302,10 @@ This is another paragraph.
end
test 'Read lines until until blank line' do
- lines = <<-EOS.lines
-This is one paragraph.
+ lines = <<~'EOS'.lines
+ This is one paragraph.
-This is another paragraph.
+ This is another paragraph.
EOS
reader = Asciidoctor::Reader.new lines, nil, normalize: true
@@ -316,10 +316,10 @@ This is another paragraph.
end
test 'Read lines until until blank line preserving last line' do
- lines = <<-EOS.chomp.split(::Asciidoctor::LF)
-This is one paragraph.
+ lines = <<~'EOS'.chomp.split(::Asciidoctor::LF)
+ This is one paragraph.
-This is another paragraph.
+ This is another paragraph.
EOS
reader = Asciidoctor::Reader.new lines
@@ -330,14 +330,14 @@ This is another paragraph.
end
test 'Read lines until until condition is true' do
- lines = <<-EOS.chomp.split(::Asciidoctor::LF)
---
-This is one paragraph inside the block.
+ lines = <<~'EOS'.chomp.split(::Asciidoctor::LF)
+ --
+ This is one paragraph inside the block.
-This is another paragraph inside the block.
---
+ This is another paragraph inside the block.
+ --
-This is a paragraph outside the block.
+ This is a paragraph outside the block.
EOS
reader = Asciidoctor::Reader.new lines
@@ -349,14 +349,14 @@ This is a paragraph outside the block.
end
test 'Read lines until until condition is true, taking last line' do
- lines = <<-EOS.chomp.split(::Asciidoctor::LF)
---
-This is one paragraph inside the block.
+ lines = <<~'EOS'.chomp.split(::Asciidoctor::LF)
+ --
+ This is one paragraph inside the block.
-This is another paragraph inside the block.
---
+ This is another paragraph inside the block.
+ --
-This is a paragraph outside the block.
+ This is a paragraph outside the block.
EOS
reader = Asciidoctor::Reader.new lines
@@ -368,14 +368,14 @@ This is a paragraph outside the block.
end
test 'Read lines until until condition is true, taking and preserving last line' do
- lines = <<-EOS.chomp.split(::Asciidoctor::LF)
---
-This is one paragraph inside the block.
+ lines = <<~'EOS'.chomp.split(::Asciidoctor::LF)
+ --
+ This is one paragraph inside the block.
-This is another paragraph inside the block.
---
+ This is another paragraph inside the block.
+ --
-This is a paragraph outside the block.
+ This is a paragraph outside the block.
EOS
reader = Asciidoctor::Reader.new lines
@@ -387,14 +387,14 @@ This is a paragraph outside the block.
end
test 'read lines until terminator' do
- lines = <<-EOS.lines
-****
-captured
+ lines = <<~'EOS'.lines
+ ****
+ captured
-also captured
-****
+ also captured
+ ****
-not captured
+ not captured
EOS
expected = ['captured', '', 'also captured']
@@ -408,13 +408,13 @@ not captured
end
test 'should flag reader as unterminated if reader reaches end of source without finding terminator' do
- lines = <<-EOS.lines
-****
-captured
+ lines = <<~'EOS'.lines
+ ****
+ captured
-also captured
+ also captured
-captured yet again
+ captured yet again
EOS
expected = lines[1..-1].map {|l| l.chomp }
@@ -468,12 +468,12 @@ captured yet again
end
test 'should clean CRLF from end of lines' do
- input = <<-EOS
-source\r
-with\r
-CRLF\r
-line endings\r
- EOS
+ input = <<~EOS
+ source\r
+ with\r
+ CRLF\r
+ line endings\r
+ EOS
[input, input.lines, input.split(::Asciidoctor::LF), input.split(::Asciidoctor::LF).join(::Asciidoctor::LF)].each do |lines|
doc = Asciidoctor::Document.new lines
@@ -487,17 +487,17 @@ line endings\r
end
test 'should not skip front matter by default' do
- input = <<-EOS
----
-layout: post
-title: Document Title
-author: username
-tags: [ first, second ]
----
-= Document Title
-Author Name
+ input = <<~'EOS'
+ ---
+ layout: post
+ title: Document Title
+ author: username
+ tags: [ first, second ]
+ ---
+ = Document Title
+ Author Name
-preamble
+ preamble
EOS
doc = Asciidoctor::Document.new input
@@ -507,18 +507,21 @@ preamble
end
test 'should skip front matter if specified by skip-front-matter attribute' do
- front_matter = %(layout: post
-title: Document Title
-author: username
-tags: [ first, second ])
- input = <<-EOS
----
-#{front_matter}
----
-= Document Title
-Author Name
+ front_matter = <<~'EOS'.chomp
+ layout: post
+ title: Document Title
+ author: username
+ tags: [ first, second ]
+ EOS
+
+ input = <<~EOS
+ ---
+ #{front_matter}
+ ---
+ = Document Title
+ Author Name
-preamble
+ preamble
EOS
doc = Asciidoctor::Document.new input, attributes: { 'skip-front-matter' => '' }
@@ -600,19 +603,14 @@ preamble
context 'Include Directive' do
test 'include directive is disabled by default and becomes a link' do
- input = <<-EOS
-include::include-file.adoc[]
- EOS
+ input = 'include::include-file.adoc[]'
doc = Asciidoctor::Document.new input
reader = doc.reader
assert_equal 'link:include-file.adoc[]', reader.read_line
end
test 'include directive is enabled when safe mode is less than SECURE' do
- input = <<-EOS
-include::fixtures/include-file.adoc[]
- EOS
-
+ input = 'include::fixtures/include-file.adoc[]'
doc = document_from_string input, safe: :safe, header_footer: false, base_dir: DIRNAME
output = doc.convert
assert_match(/included content/, output)
@@ -620,10 +618,10 @@ include::fixtures/include-file.adoc[]
end
test 'should not track include in catalog for non-AsciiDoc include files' do
- input = <<-EOS
-----
-include::fixtures/circle.svg[]
-----
+ input = <<~'EOS'
+ ----
+ include::fixtures/circle.svg[]
+ ----
EOS
doc = document_from_string input, safe: :safe, header_footer: false, base_dir: DIRNAME
@@ -631,10 +629,7 @@ include::fixtures/circle.svg[]
end
test 'include directive should resolve file with spaces in name' do
- input = <<-EOS
-include::fixtures/include file.adoc[]
- EOS
-
+ input = 'include::fixtures/include file.adoc[]'
include_file = File.join DIRNAME, 'fixtures', 'include-file.adoc'
include_file_with_sp = File.join DIRNAME, 'fixtures', 'include file.adoc'
begin
@@ -648,10 +643,7 @@ include::fixtures/include file.adoc[]
end
test 'include directive should resolve file with {sp} in name' do
- input = <<-EOS
-include::fixtures/include{sp}file.adoc[]
- EOS
-
+ input = 'include::fixtures/include{sp}file.adoc[]'
include_file = File.join DIRNAME, 'fixtures', 'include-file.adoc'
include_file_with_sp = File.join DIRNAME, 'fixtures', 'include file.adoc'
begin
@@ -665,10 +657,7 @@ include::fixtures/include{sp}file.adoc[]
end
test 'include directive should resolve file relative to current include' do
- input = <<-EOS
-include::fixtures/parent-include.adoc[]
- EOS
-
+ input = 'include::fixtures/parent-include.adoc[]'
pseudo_docfile = File.join DIRNAME, 'include-master.adoc'
fixtures_dir = File.join DIRNAME, 'fixtures'
parent_include_docfile = File.join fixtures_dir, 'parent-include.adoc'
@@ -726,10 +715,7 @@ include::fixtures/parent-include.adoc[]
end
test 'include directive should process lines when file extension of target is .asciidoc' do
- input = <<-EOS
-include::fixtures/include-alt-extension.asciidoc[]
- EOS
-
+ input = 'include::fixtures/include-alt-extension.asciidoc[]'
doc = document_from_string input, safe: :safe, base_dir: DIRNAME
assert_equal 3, doc.blocks.size
assert_equal ['first line'], doc.blocks[0].lines
@@ -738,10 +724,10 @@ include::fixtures/include-alt-extension.asciidoc[]
end
test 'missing file referenced by include directive is skipped when optional option is set' do
- input = <<-EOS
-include::fixtures/no-such-file.adoc[opts=optional]
+ input = <<~'EOS'
+ include::fixtures/no-such-file.adoc[opts=optional]
-trailing content
+ trailing content
EOS
begin
@@ -757,10 +743,10 @@ trailing content
end
test 'missing file referenced by include directive is replaced by warning' do
- input = <<-EOS
-include::fixtures/no-such-file.adoc[]
+ input = <<~'EOS'
+ include::fixtures/no-such-file.adoc[]
-trailing content
+ trailing content
EOS
begin
@@ -779,10 +765,10 @@ trailing content
test 'unreadable file referenced by include directive is replaced by warning' do
include_file = File.join DIRNAME, 'fixtures', 'chapter-a.adoc'
FileUtils.chmod 0000, include_file
- input = <<-EOS
-include::fixtures/chapter-a.adoc[]
+ input = <<~'EOS'
+ include::fixtures/chapter-a.adoc[]
-trailing content
+ trailing content
EOS
begin
@@ -803,8 +789,8 @@ trailing content
# IMPORTANT this test needs to be run on Windows to verify proper behavior in Windows
test 'can resolve include directive with absolute path' do
include_path = ::File.join DIRNAME, 'fixtures', 'chapter-a.adoc'
- input = <<-EOS
-include::#{include_path}[]
+ input = <<~EOS
+ include::#{include_path}[]
EOS
result = document_from_string input, safe: :safe
assert_equal 'Chapter A', result.doctitle
@@ -815,10 +801,10 @@ include::#{include_path}[]
test 'include directive can retrieve data from uri' do
url = %(http://#{resolve_localhost}:9876/name/asciidoctor)
- input = <<-EOS
-....
-include::#{url}[]
-....
+ input = <<~EOS
+ ....
+ include::#{url}[]
+ ....
EOS
expect = /\{"name": "asciidoctor"\}/
output = using_test_webserver do
@@ -830,59 +816,63 @@ include::#{url}[]
end
test 'nested include directives are resolved relative to current file' do
- input = <<-EOS
-....
-include::fixtures/outer-include.adoc[]
-....
+ input = <<~'EOS'
+ ....
+ include::fixtures/outer-include.adoc[]
+ ....
EOS
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
- expected = 'first line of outer
+ expected = <<~'EOS'.chomp
+ first line of outer
-first line of middle
+ first line of middle
-first line of inner
+ first line of inner
-last line of inner
+ last line of inner
-last line of middle
+ last line of middle
-last line of outer'
+ last line of outer
+ EOS
assert_includes output, expected
end
test 'nested remote include directive is resolved relative to uri of current file' do
url = %(http://#{resolve_localhost}:9876/fixtures/outer-include.adoc)
- input = <<-EOS
-....
-include::#{url}[]
-....
+ input = <<~EOS
+ ....
+ include::#{url}[]
+ ....
EOS
output = using_test_webserver do
convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' }
end
- expected = 'first line of outer
+ expected = <<~'EOS'.chomp
+ first line of outer
-first line of middle
+ first line of middle
-first line of inner
+ first line of inner
-last line of inner
+ last line of inner
-last line of middle
+ last line of middle
-last line of outer'
+ last line of outer
+ EOS
assert_includes output, expected
end
test 'nested remote include directive that cannot be resolved does not crash processor' do
include_url = %(http://#{resolve_localhost}:9876/fixtures/file-with-missing-include.adoc)
nested_include_url = 'no-such-file.adoc'
- input = <<-EOS
-....
-include::#{include_url}[]
-....
+ input = <<~EOS
+ ....
+ include::#{include_url}[]
+ ....
EOS
begin
using_memory_logger do |logger|
@@ -899,28 +889,30 @@ include::#{include_url}[]
test 'tag filtering is supported for remote includes' do
url = %(http://#{resolve_localhost}:9876/fixtures/tagged-class.rb)
- input = <<-EOS
-[source,ruby]
-----
-include::#{url}[tag=init,indent=0]
-----
+ input = <<~EOS
+ [source,ruby]
+ ----
+ include::#{url}[tag=init,indent=0]
+ ----
EOS
output = using_test_webserver do
convert_string_to_embedded input, safe: :safe, attributes: { 'allow-uri-read' => '' }
end
- expected = '<code class="language-ruby" data-lang="ruby">def initialize breed
- @breed = breed
-end</code>'
+ expected = <<~EOS.chomp
+ <code class="language-ruby" data-lang="ruby">def initialize breed
+ @breed = breed
+ end</code>
+ EOS
assert_includes output, expected
end
test 'inaccessible uri referenced by include directive does not crash processor' do
url = %(http://#{resolve_localhost}:9876/no_such_file)
- input = <<-EOS
-....
-include::#{url}[]
-....
+ input = <<~EOS
+ ....
+ include::#{url}[]
+ ....
EOS
begin
@@ -938,10 +930,7 @@ include::#{url}[]
end
test 'include directive supports selecting lines by line number' do
- input = <<-EOS
-include::fixtures/include-file.adoc[lines=1;3..4;6..-1]
- EOS
-
+ input = 'include::fixtures/include-file.adoc[lines=1;3..4;6..-1]'
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_match(/first line/, output)
refute_match(/second line/, output)
@@ -955,10 +944,7 @@ include::fixtures/include-file.adoc[lines=1;3..4;6..-1]
end
test 'include directive supports line ranges specified in quoted attribute value' do
- input = <<-EOS
-include::fixtures/include-file.adoc[lines="1, 3..4 , 6 .. -1"]
- EOS
-
+ input = 'include::fixtures/include-file.adoc[lines="1, 3..4 , 6 .. -1"]'
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_match(/first line/, output)
refute_match(/second line/, output)
@@ -972,10 +958,7 @@ include::fixtures/include-file.adoc[lines="1, 3..4 , 6 .. -1"]
end
test 'include directive supports implicit endless range' do
- input = <<-EOS
-include::fixtures/include-file.adoc[lines=6..]
- EOS
-
+ input = 'include::fixtures/include-file.adoc[lines=6..]'
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
refute_match(/first line/, output)
refute_match(/second line/, output)
@@ -989,10 +972,10 @@ include::fixtures/include-file.adoc[lines=6..]
end
test 'include directive ignores empty lines attribute' do
- input = <<-EOS
-++++
-include::fixtures/include-file.adoc[lines=]
-++++
+ input = <<~'EOS'
+ ++++
+ include::fixtures/include-file.adoc[lines=]
+ ++++
EOS
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
@@ -1001,10 +984,7 @@ include::fixtures/include-file.adoc[lines=]
end
test 'include directive supports selecting lines by tag' do
- input = <<-EOS
-include::fixtures/include-file.adoc[tag=snippetA]
- EOS
-
+ input = 'include::fixtures/include-file.adoc[tag=snippetA]'
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_match(/snippetA content/, output)
refute_match(/snippetB content/, output)
@@ -1013,10 +993,7 @@ include::fixtures/include-file.adoc[tag=snippetA]
end
test 'include directive supports selecting lines by tags' do
- input = <<-EOS
-include::fixtures/include-file.adoc[tags=snippetA;snippetB]
- EOS
-
+ input = 'include::fixtures/include-file.adoc[tags=snippetA;snippetB]'
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_match(/snippetA content/, output)
assert_match(/snippetB content/, output)
@@ -1030,11 +1007,11 @@ include::fixtures/include-file.adoc[tags=snippetA;snippetB]
'include-file.ml' => 'let s = SS.empty;;',
'include-file.jsx' => '<p>Welcome to the club.</p>',
}.each do |filename, expect|
- input = <<-EOS
-[source,xml]
-----
-include::fixtures/#{filename}[tag=snippet,indent=0]
-----
+ input = <<~EOS
+ [source,xml]
+ ----
+ include::fixtures/#{filename}[tag=snippet,indent=0]
+ ----
EOS
doc = document_from_string input, safe: :safe, base_dir: DIRNAME
@@ -1048,8 +1025,8 @@ include::fixtures/#{filename}[tag=snippet,indent=0]
tmp_include_dir, tmp_include_path = File.split tmp_include.path
tmp_include.write %(do not include\r\ntag::include-me[]\r\nincluded line\r\nend::include-me[]\r\ndo not include\r\n)
tmp_include.close
- input = <<-EOS
-include::#{tmp_include_path}[tag=include-me]
+ input = <<~EOS
+ include::#{tmp_include_path}[tag=include-me]
EOS
output = convert_string_to_embedded input, safe: :safe, base_dir: tmp_include_dir
assert_includes output, 'included line'
@@ -1065,8 +1042,8 @@ include::#{tmp_include_path}[tag=include-me]
tmp_include_dir, tmp_include_path = File.split tmp_include.path
tmp_include.write %(line not included\ntag::include-me[]\nline included\nend::include-me[])
tmp_include.close
- input = <<-EOS
-include::#{tmp_include_path}[tag=include-me]
+ input = <<~EOS
+ include::#{tmp_include_path}[tag=include-me]
EOS
using_memory_logger do |logger|
output = convert_string_to_embedded input, safe: :safe, base_dir: tmp_include_dir
@@ -1080,157 +1057,167 @@ include::#{tmp_include_path}[tag=include-me]
end
test 'include directive does not select lines with tag directives within selected tag region' do
- input = <<-EOS
-++++
-include::fixtures/include-file.adoc[tags=snippet]
-++++
+ input = <<~'EOS'
+ ++++
+ include::fixtures/include-file.adoc[tags=snippet]
+ ++++
EOS
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
- expect = %(snippetA content
+ expect = <<~'EOS'.chomp
+ snippetA content
-non-tagged content
+ non-tagged content
-snippetB content)
+ snippetB content
+ EOS
assert_equal expect, output
end
test 'include directive skips lines marked with negated tags' do
- input = <<-EOS
-----
-include::fixtures/tagged-class-enclosed.rb[tags=all;!bark]
-----
+ input = <<~'EOS'
+ ----
+ include::fixtures/tagged-class-enclosed.rb[tags=all;!bark]
+ ----
EOS
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
- expected = %(class Dog
- def initialize breed
- @breed = breed
- end
-end)
+ expected = <<~EOS.chomp
+ class Dog
+ def initialize breed
+ @breed = breed
+ end
+ end
+ EOS
assert_includes output, expected
end
test 'include directive takes all lines without tag directives when value is double asterisk' do
- input = <<-EOS
-----
-include::fixtures/tagged-class.rb[tags=**]
-----
+ input = <<~'EOS'
+ ----
+ include::fixtures/tagged-class.rb[tags=**]
+ ----
EOS
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
- expected = %(class Dog
- def initialize breed
- @breed = breed
- end
+ expected = <<~EOS.chomp
+ class Dog
+ def initialize breed
+ @breed = breed
+ end
- def bark
- if @breed == 'beagle'
- 'woof woof woof woof woof'
- else
- 'woof woof'
- end
- end
-end)
+ def bark
+ if @breed == 'beagle'
+ 'woof woof woof woof woof'
+ else
+ 'woof woof'
+ end
+ end
+ end
+ EOS
assert_includes output, expected
end
test 'include directive takes all lines except negated tags when value contains double asterisk' do
- input = <<-EOS
-----
-include::fixtures/tagged-class.rb[tags=**;!bark]
-----
+ input = <<~'EOS'
+ ----
+ include::fixtures/tagged-class.rb[tags=**;!bark]
+ ----
EOS
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
- expected = %(class Dog
- def initialize breed
- @breed = breed
- end
-end)
+ expected = <<~EOS.chomp
+ class Dog
+ def initialize breed
+ @breed = breed
+ end
+ end
+ EOS
assert_includes output, expected
end
test 'include directive selects lines for all tags when value of tags attribute is wildcard' do
- input = <<-EOS
-----
-include::fixtures/tagged-class-enclosed.rb[tags=*]
-----
+ input = <<~'EOS'
+ ----
+ include::fixtures/tagged-class-enclosed.rb[tags=*]
+ ----
EOS
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
- expected = %(class Dog
- def initialize breed
- @breed = breed
- end
+ expected = <<~EOS.chomp
+ class Dog
+ def initialize breed
+ @breed = breed
+ end
- def bark
- if @breed == 'beagle'
- 'woof woof woof woof woof'
- else
- 'woof woof'
- end
- end
-end)
+ def bark
+ if @breed == 'beagle'
+ 'woof woof woof woof woof'
+ else
+ 'woof woof'
+ end
+ end
+ end
+ EOS
assert_includes output, expected
end
test 'include directive selects lines for all tags except exclusions when value of tags attribute is wildcard' do
- input = <<-EOS
-----
-include::fixtures/tagged-class-enclosed.rb[tags=*;!init]
-----
+ input = <<~'EOS'
+ ----
+ include::fixtures/tagged-class-enclosed.rb[tags=*;!init]
+ ----
EOS
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
- expected = %(class Dog
-
- def bark
- if @breed == 'beagle'
- 'woof woof woof woof woof'
- else
- 'woof woof'
- end
- end
-end)
+ expected = <<~EOS.chomp
+ class Dog
+
+ def bark
+ if @breed == 'beagle'
+ 'woof woof woof woof woof'
+ else
+ 'woof woof'
+ end
+ end
+ end
+ EOS
assert_includes output, expected
end
test 'include directive skips lines all tagged lines when value of tags attribute is negated wildcard' do
- input = <<-EOS
-----
-include::fixtures/tagged-class.rb[tags=!*]
-----
+ input = <<~'EOS'
+ ----
+ include::fixtures/tagged-class.rb[tags=!*]
+ ----
EOS
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
- expected = %(class Dog
-end)
+ expected = %(class Dog\nend)
assert_includes output, expected
end
test 'include directive selects specified tagged lines and ignores the other tag directives' do
- input = <<-EOS
-[indent=0]
-----
-include::fixtures/tagged-class.rb[tags=bark;!bark-other]
-----
+ input = <<~'EOS'
+ [indent=0]
+ ----
+ include::fixtures/tagged-class.rb[tags=bark;!bark-other]
+ ----
EOS
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
- expected = %(def bark
- if @breed == 'beagle'
- 'woof woof woof woof woof'
- end
-end)
+ expected = <<~EOS.chomp
+ def bark
+ if @breed == 'beagle'
+ 'woof woof woof woof woof'
+ end
+ end
+ EOS
assert_includes output, expected
end
test 'should warn if specified tag is not found in include file' do
- input = <<-EOS
-include::fixtures/include-file.adoc[tag=no-such-tag]
- EOS
-
+ input = 'include::fixtures/include-file.adoc[tag=no-such-tag]'
using_memory_logger do |logger|
convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_message logger, :WARN, %(~<stdin>: line 1: tag 'no-such-tag' not found in include file), Hash
@@ -1238,10 +1225,10 @@ include::fixtures/include-file.adoc[tag=no-such-tag]
end
test 'should warn if specified tags are not found in include file' do
- input = <<-EOS
-++++
-include::fixtures/include-file.adoc[tags=no-such-tag-b;no-such-tag-a]
-++++
+ input = <<~'EOS'
+ ++++
+ include::fixtures/include-file.adoc[tags=no-such-tag-b;no-such-tag-a]
+ ++++
EOS
using_memory_logger do |logger|
@@ -1252,10 +1239,10 @@ include::fixtures/include-file.adoc[tags=no-such-tag-b;no-such-tag-a]
end
test 'should warn if specified tag in include file is not closed' do
- input = <<-EOS
-++++
-include::fixtures/unclosed-tag.adoc[tag=a]
-++++
+ input = <<~'EOS'
+ ++++
+ include::fixtures/unclosed-tag.adoc[tag=a]
+ ++++
EOS
using_memory_logger do |logger|
@@ -1267,10 +1254,10 @@ include::fixtures/unclosed-tag.adoc[tag=a]
end
test 'should warn if end tag in included file is mismatched' do
- input = <<-EOS
-++++
-include::fixtures/mismatched-end-tag.adoc[tags=a;b]
-++++
+ input = <<~'EOS'
+ ++++
+ include::fixtures/mismatched-end-tag.adoc[tags=a;b]
+ ++++
EOS
inc_path = File.join DIRNAME, 'fixtures/mismatched-end-tag.adoc'
@@ -1283,10 +1270,10 @@ include::fixtures/mismatched-end-tag.adoc[tags=a;b]
end
test 'should warn if unexpected end tag is found in included file' do
- input = <<-EOS
-++++
-include::fixtures/unexpected-end-tag.adoc[tags=a]
-++++
+ input = <<~'EOS'
+ ++++
+ include::fixtures/unexpected-end-tag.adoc[tags=a]
+ ++++
EOS
inc_path = File.join DIRNAME, 'fixtures/unexpected-end-tag.adoc'
@@ -1300,10 +1287,10 @@ include::fixtures/unexpected-end-tag.adoc[tags=a]
test 'include directive ignores tags attribute when empty' do
['tag', 'tags'].each do |attr_name|
- input = <<-EOS
-++++
-include::fixtures/include-file.xml[#{attr_name}=]
-++++
+ input = <<~EOS
+ ++++
+ include::fixtures/include-file.xml[#{attr_name}=]
+ ++++
EOS
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
@@ -1312,10 +1299,7 @@ include::fixtures/include-file.xml[#{attr_name}=]
end
test 'lines attribute takes precedence over tags attribute in include directive' do
- input = <<-EOS
-include::fixtures/include-file.adoc[lines=1, tags=snippetA;snippetB]
- EOS
-
+ input = 'include::fixtures/include-file.adoc[lines=1, tags=snippetA;snippetB]'
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
assert_match(/first line of included content/, output)
refute_match(/snippetA content/, output)
@@ -1323,11 +1307,11 @@ include::fixtures/include-file.adoc[lines=1, tags=snippetA;snippetB]
end
test 'indent of included file can be reset to size of indent attribute' do
- input = <<-EOS
-[source, xml]
-----
-include::fixtures/basic-docinfo.xml[lines=2..3, indent=0]
-----
+ input = <<~'EOS'
+ [source, xml]
+ ----
+ include::fixtures/basic-docinfo.xml[lines=2..3, indent=0]
+ ----
EOS
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
@@ -1336,9 +1320,9 @@ include::fixtures/basic-docinfo.xml[lines=2..3, indent=0]
end
test 'should substitute attribute references in attrlist' do
- input = <<-EOS
-:name-of-tag: snippetA
-include::fixtures/include-file.adoc[tag={name-of-tag}]
+ input = <<~'EOS'
+ :name-of-tag: snippetA
+ include::fixtures/include-file.adoc[tag={name-of-tag}]
EOS
output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME
@@ -1349,10 +1333,7 @@ include::fixtures/include-file.adoc[tag={name-of-tag}]
end
test 'should fall back to built-in include directive behavior when not handled by include processor' do
- input = <<-EOS
-include::fixtures/include-file.adoc[]
- EOS
-
+ input = 'include::fixtures/include-file.adoc[]'
include_processor = Class.new do
def initialize document
end
@@ -1375,22 +1356,19 @@ include::fixtures/include-file.adoc[]
end
test 'leveloffset attribute entries should be added to content if leveloffset attribute is specified' do
- input = <<-EOS
-include::fixtures/master.adoc[]
- EOS
-
- expected = <<-EOS.chomp.split(::Asciidoctor::LF)
-= Master Document
+ input = 'include::fixtures/master.adoc[]'
+ expected = <<~'EOS'.chomp.split(::Asciidoctor::LF)
+ = Master Document
-preamble
+ preamble
-:leveloffset: +1
+ :leveloffset: +1
-= Chapter A
+ = Chapter A
-content
+ content
-:leveloffset!:
+ :leveloffset!:
EOS
document = Asciidoctor.load input, safe: :safe, base_dir: DIRNAME, parse: false
@@ -1398,11 +1376,11 @@ content
end
test 'attributes are substituted in target of include directive' do
- input = <<-EOS
-:fixturesdir: fixtures
-:ext: adoc
+ input = <<~'EOS'
+ :fixturesdir: fixtures
+ :ext: adoc
-include::{fixturesdir}/include-file.{ext}[]
+ include::{fixturesdir}/include-file.{ext}[]
EOS
doc = document_from_string input, safe: :safe, base_dir: DIRNAME
@@ -1411,10 +1389,7 @@ include::{fixturesdir}/include-file.{ext}[]
end
test 'line is skipped by default if target of include directive resolves to empty' do
- input = <<-EOS
-include::{foodir}/include-file.adoc[]
- EOS
-
+ input = 'include::{foodir}/include-file.adoc[]'
using_memory_logger do |logger|
doc = empty_safe_document base_dir: DIRNAME
reader = Asciidoctor::PreprocessorReader.new doc, input, nil, normalize: true
@@ -1425,10 +1400,7 @@ include::{foodir}/include-file.adoc[]
end
test 'line is dropped if target of include directive resolves to empty and attribute-missing attribute is not skip' do
- input = <<-EOS
-include::{foodir}/include-file.adoc[]
- EOS
-
+ input = 'include::{foodir}/include-file.adoc[]'
using_memory_logger do |logger|
doc = empty_safe_document base_dir: DIRNAME, attributes: { 'attribute-missing' => 'drop' }
reader = Asciidoctor::PreprocessorReader.new doc, input, nil, normalize: true
@@ -1439,9 +1411,9 @@ include::{foodir}/include-file.adoc[]
end
test 'line following dropped include is not dropped' do
- input = <<-EOS
-include::{foodir}/include-file.adoc[]
-yo
+ input = <<~'EOS'
+ include::{foodir}/include-file.adoc[]
+ yo
EOS
using_memory_logger do |logger|
@@ -1454,9 +1426,9 @@ yo
end
test 'escaped include directive is left unprocessed' do
- input = <<-EOS
-\\include::fixtures/include-file.adoc[]
-\\escape preserved here
+ input = <<~'EOS'
+ \include::fixtures/include-file.adoc[]
+ \escape preserved here
EOS
doc = empty_safe_document base_dir: DIRNAME
reader = Asciidoctor::PreprocessorReader.new doc, input, nil, normalize: true
@@ -1469,9 +1441,7 @@ yo
end
test 'include directive not at start of line is ignored' do
- input = <<-EOS
- include::include-file.adoc[]
- EOS
+ input = ' include::include-file.adoc[]'
para = block_from_string input
assert_equal 1, para.lines.size
# NOTE the space gets stripped because the line is treated as an inline literal
@@ -1480,19 +1450,17 @@ yo
end
test 'include directive is disabled when max-include-depth attribute is 0' do
- input = <<-EOS
-include::include-file.adoc[]
- EOS
+ input = 'include::include-file.adoc[]'
para = block_from_string input, safe: :safe, attributes: { 'max-include-depth' => 0 }
assert_equal 1, para.lines.size
assert_equal 'include::include-file.adoc[]', para.source
end
test 'max-include-depth cannot be set by document' do
- input = <<-EOS
-:max-include-depth: 1
+ input = <<~'EOS'
+ :max-include-depth: 1
-include::include-file.adoc[]
+ include::include-file.adoc[]
EOS
para = block_from_string input, safe: :safe, attributes: { 'max-include-depth' => 0 }
assert_equal 1, para.lines.size
@@ -1500,10 +1468,7 @@ include::include-file.adoc[]
end
test 'include directive should be disabled if max include depth has been exceeded' do
- input = <<-EOS
-include::fixtures/parent-include.adoc[depth=1]
- EOS
-
+ input = 'include::fixtures/parent-include.adoc[depth=1]'
using_memory_logger do |logger|
pseudo_docfile = File.join DIRNAME, 'include-master.adoc'
doc = empty_safe_document base_dir: DIRNAME
@@ -1515,10 +1480,7 @@ include::fixtures/parent-include.adoc[depth=1]
end
test 'include directive should be disabled if max include depth set in nested context has been exceeded' do
- input = <<-EOS
-include::fixtures/parent-include-restricted.adoc[depth=3]
- EOS
-
+ input = 'include::fixtures/parent-include-restricted.adoc[depth=3]'
using_memory_logger do |logger|
pseudo_docfile = File.join DIRNAME, 'include-master.adoc'
doc = empty_safe_document base_dir: DIRNAME
@@ -1531,10 +1493,10 @@ include::fixtures/parent-include-restricted.adoc[depth=3]
end
test 'read_lines_until should not process lines if process option is false' do
- lines = <<-EOS.lines
-////
-include::fixtures/no-such-file.adoc[]
-////
+ lines = <<~'EOS'.lines
+ ////
+ include::fixtures/no-such-file.adoc[]
+ ////
EOS
doc = empty_safe_document base_dir: DIRNAME
@@ -1545,10 +1507,10 @@ include::fixtures/no-such-file.adoc[]
end
test 'skip_comment_lines should not process lines read' do
- lines = <<-EOS.lines
-////
-include::fixtures/no-such-file.adoc[]
-////
+ lines = <<~'EOS'.lines
+ ////
+ include::fixtures/no-such-file.adoc[]
+ ////
EOS
using_memory_logger do |logger|
@@ -1563,10 +1525,10 @@ include::fixtures/no-such-file.adoc[]
context 'Conditional Inclusions' do
test 'process_line returns nil if cursor advanced' do
- input = <<-EOS
-ifdef::asciidoctor[]
-Asciidoctor!
-endif::asciidoctor[]
+ input = <<~'EOS'
+ ifdef::asciidoctor[]
+ Asciidoctor!
+ endif::asciidoctor[]
EOS
doc = Asciidoctor::Document.new input
@@ -1575,10 +1537,10 @@ endif::asciidoctor[]
end
test 'peek_line advances cursor to next conditional line of content' do
- input = <<-EOS
-ifdef::asciidoctor[]
-Asciidoctor!
-endif::asciidoctor[]
+ input = <<~'EOS'
+ ifdef::asciidoctor[]
+ Asciidoctor!
+ endif::asciidoctor[]
EOS
doc = Asciidoctor::Document.new input
@@ -1589,9 +1551,9 @@ endif::asciidoctor[]
end
test 'peek_lines should preprocess lines if direct is false' do
- input = <<-EOS
-The Asciidoctor
-ifdef::asciidoctor[is in.]
+ input = <<~'EOS'
+ The Asciidoctor
+ ifdef::asciidoctor[is in.]
EOS
doc = Asciidoctor::Document.new input
reader = doc.reader
@@ -1600,9 +1562,9 @@ ifdef::asciidoctor[is in.]
end
test 'peek_lines should not preprocess lines if direct is true' do
- input = <<-EOS
-The Asciidoctor
-ifdef::asciidoctor[is in.]
+ input = <<~'EOS'
+ The Asciidoctor
+ ifdef::asciidoctor[is in.]
EOS
doc = Asciidoctor::Document.new input
reader = doc.reader
@@ -1611,9 +1573,9 @@ ifdef::asciidoctor[is in.]
end
test 'peek_lines should not prevent subsequent preprocessing of peeked lines' do
- input = <<-EOS
-The Asciidoctor
-ifdef::asciidoctor[is in.]
+ input = <<~'EOS'
+ The Asciidoctor
+ ifdef::asciidoctor[is in.]
EOS
doc = Asciidoctor::Document.new input
reader = doc.reader
@@ -1623,11 +1585,11 @@ ifdef::asciidoctor[is in.]
end
test 'process_line returns line if cursor not advanced' do
- input = <<-EOS
-content
-ifdef::asciidoctor[]
-Asciidoctor!
-endif::asciidoctor[]
+ input = <<~'EOS'
+ content
+ ifdef::asciidoctor[]
+ Asciidoctor!
+ endif::asciidoctor[]
EOS
doc = Asciidoctor::Document.new input
@@ -1636,11 +1598,11 @@ endif::asciidoctor[]
end
test 'peek_line does not advance cursor when on a regular content line' do
- input = <<-EOS
-content
-ifdef::asciidoctor[]
-Asciidoctor!
-endif::asciidoctor[]
+ input = <<~'EOS'
+ content
+ ifdef::asciidoctor[]
+ Asciidoctor!
+ endif::asciidoctor[]
EOS
doc = Asciidoctor::Document.new input
@@ -1651,10 +1613,10 @@ endif::asciidoctor[]
end
test 'peek_line returns nil if cursor advances past end of source' do
- input = <<-EOS
-ifdef::foobar[]
-swallowed content
-endif::foobar[]
+ input = <<~'EOS'
+ ifdef::foobar[]
+ swallowed content
+ endif::foobar[]
EOS
doc = Asciidoctor::Document.new input
@@ -1665,10 +1627,10 @@ endif::foobar[]
end
test 'ifdef with defined attribute includes content' do
- input = <<-EOS
-ifdef::holygrail[]
-There is a holy grail!
-endif::holygrail[]
+ input = <<~'EOS'
+ ifdef::holygrail[]
+ There is a holy grail!
+ endif::holygrail[]
EOS
doc = Asciidoctor::Document.new input, attributes: { 'holygrail' => '' }
@@ -1681,10 +1643,10 @@ endif::holygrail[]
end
test 'ifdef with defined attribute includes text in brackets' do
- input = <<-EOS
-On our quest we go...
-ifdef::holygrail[There is a holy grail!]
-There was much rejoicing.
+ input = <<~'EOS'
+ On our quest we go...
+ ifdef::holygrail[There is a holy grail!]
+ There was much rejoicing.
EOS
doc = Asciidoctor::Document.new input, attributes: { 'holygrail' => '' }
@@ -1697,10 +1659,7 @@ There was much rejoicing.
end
test 'ifdef with defined attribute processes include directive in brackets' do
- input = <<-EOS
-ifdef::asciidoctor-version[include::fixtures/include-file.adoc[tag=snippetA]]
- EOS
-
+ input = 'ifdef::asciidoctor-version[include::fixtures/include-file.adoc[tag=snippetA]]'
doc = Asciidoctor::Document.new input, safe: :safe, base_dir: DIRNAME
reader = doc.reader
lines = []
@@ -1711,10 +1670,10 @@ ifdef::asciidoctor-version[include::fixtures/include-file.adoc[tag=snippetA]]
end
test 'ifdef attribute name is not case sensitive' do
- input = <<-EOS
-ifdef::showScript[]
-The script is shown!
-endif::showScript[]
+ input = <<~'EOS'
+ ifdef::showScript[]
+ The script is shown!
+ endif::showScript[]
EOS
doc = Asciidoctor::Document.new input, attributes: { 'showscript' => '' }
@@ -1723,10 +1682,10 @@ endif::showScript[]
end
test 'ifndef with defined attribute does not include text in brackets' do
- input = <<-EOS
-On our quest we go...
-ifndef::hardships[There is a holy grail!]
-There was no rejoicing.
+ input = <<~'EOS'
+ On our quest we go...
+ ifndef::hardships[There is a holy grail!]
+ There was no rejoicing.
EOS
doc = Asciidoctor::Document.new input, attributes: { 'hardships' => '' }
@@ -1739,14 +1698,14 @@ There was no rejoicing.
end
test 'include with non-matching nested exclude' do
- input = <<-EOS
-ifdef::grail[]
-holy
-ifdef::swallow[]
-swallow
-endif::swallow[]
-grail
-endif::grail[]
+ input = <<~'EOS'
+ ifdef::grail[]
+ holy
+ ifdef::swallow[]
+ swallow
+ endif::swallow[]
+ grail
+ endif::grail[]
EOS
doc = Asciidoctor::Document.new input, attributes: { 'grail' => '' }
@@ -1759,12 +1718,12 @@ endif::grail[]
end
test 'nested excludes with same condition' do
- input = <<-EOS
-ifndef::grail[]
-ifndef::grail[]
-not here
-endif::grail[]
-endif::grail[]
+ input = <<~'EOS'
+ ifndef::grail[]
+ ifndef::grail[]
+ not here
+ endif::grail[]
+ endif::grail[]
EOS
doc = Asciidoctor::Document.new input, attributes: { 'grail' => '' }
@@ -1777,14 +1736,14 @@ endif::grail[]
end
test 'include with nested exclude of inverted condition' do
- input = <<-EOS
-ifdef::grail[]
-holy
-ifndef::grail[]
-not here
-endif::grail[]
-grail
-endif::grail[]
+ input = <<~'EOS'
+ ifdef::grail[]
+ holy
+ ifndef::grail[]
+ not here
+ endif::grail[]
+ grail
+ endif::grail[]
EOS
doc = Asciidoctor::Document.new input, attributes: { 'grail' => '' }
@@ -1797,16 +1756,16 @@ endif::grail[]
end
test 'exclude with matching nested exclude' do
- input = <<-EOS
-poof
-ifdef::swallow[]
-no
-ifdef::swallow[]
-swallow
-endif::swallow[]
-here
-endif::swallow[]
-gone
+ input = <<~'EOS'
+ poof
+ ifdef::swallow[]
+ no
+ ifdef::swallow[]
+ swallow
+ endif::swallow[]
+ here
+ endif::swallow[]
+ gone
EOS
doc = Asciidoctor::Document.new input, attributes: { 'grail' => '' }
@@ -1819,16 +1778,16 @@ gone
end
test 'exclude with nested include using shorthand end' do
- input = <<-EOS
-poof
-ifndef::grail[]
-no grail
-ifndef::swallow[]
-or swallow
-endif::[]
-in here
-endif::[]
-gone
+ input = <<~'EOS'
+ poof
+ ifndef::grail[]
+ no grail
+ ifndef::swallow[]
+ or swallow
+ endif::[]
+ in here
+ endif::[]
+ gone
EOS
doc = Asciidoctor::Document.new input, attributes: { 'grail' => '' }
@@ -1841,10 +1800,10 @@ gone
end
test 'ifdef with one alternative attribute set includes content' do
- input = <<-EOS
-ifdef::holygrail,swallow[]
-Our quest is complete!
-endif::holygrail,swallow[]
+ input = <<~'EOS'
+ ifdef::holygrail,swallow[]
+ Our quest is complete!
+ endif::holygrail,swallow[]
EOS
doc = Asciidoctor::Document.new input, attributes: { 'swallow' => '' }
@@ -1857,10 +1816,10 @@ endif::holygrail,swallow[]
end
test 'ifdef with no alternative attributes set does not include content' do
- input = <<-EOS
-ifdef::holygrail,swallow[]
-Our quest is complete!
-endif::holygrail,swallow[]
+ input = <<~'EOS'
+ ifdef::holygrail,swallow[]
+ Our quest is complete!
+ endif::holygrail,swallow[]
EOS
doc = Asciidoctor::Document.new input
@@ -1873,10 +1832,10 @@ endif::holygrail,swallow[]
end
test 'ifdef with all required attributes set includes content' do
- input = <<-EOS
-ifdef::holygrail+swallow[]
-Our quest is complete!
-endif::holygrail+swallow[]
+ input = <<~'EOS'
+ ifdef::holygrail+swallow[]
+ Our quest is complete!
+ endif::holygrail+swallow[]
EOS
doc = Asciidoctor::Document.new input, attributes: { 'holygrail' => '', 'swallow' => '' }
@@ -1889,10 +1848,10 @@ endif::holygrail+swallow[]
end
test 'ifdef with missing required attributes does not include content' do
- input = <<-EOS
-ifdef::holygrail+swallow[]
-Our quest is complete!
-endif::holygrail+swallow[]
+ input = <<~'EOS'
+ ifdef::holygrail+swallow[]
+ Our quest is complete!
+ endif::holygrail+swallow[]
EOS
doc = Asciidoctor::Document.new input, attributes: { 'holygrail' => '' }
@@ -1913,20 +1872,20 @@ endif::holygrail+swallow[]
'asciidoctor,,asciidoctor-version' => 'content',
'asciidoctor++asciidoctor-version' => '',
}.each do |condition, expected|
- input = <<-EOS
-ifdef::#{condition}[]
-content
-endif::[]
+ input = <<~EOS
+ ifdef::#{condition}[]
+ content
+ endif::[]
EOS
assert_equal expected, (document_from_string input, parse: false).reader.read
end
end
test 'ifndef with undefined attribute includes block' do
- input = <<-EOS
-ifndef::holygrail[]
-Our quest continues to find the holy grail!
-endif::holygrail[]
+ input = <<~'EOS'
+ ifndef::holygrail[]
+ Our quest continues to find the holy grail!
+ endif::holygrail[]
EOS
doc = Asciidoctor::Document.new input
@@ -1939,10 +1898,10 @@ endif::holygrail[]
end
test 'ifndef with one alternative attribute set does not include content' do
- input = <<-EOS
-ifndef::holygrail,swallow[]
-Our quest is complete!
-endif::holygrail,swallow[]
+ input = <<~'EOS'
+ ifndef::holygrail,swallow[]
+ Our quest is complete!
+ endif::holygrail,swallow[]
EOS
result = (Asciidoctor::Document.new input, attributes: { 'swallow' => '' }).reader.read
@@ -1950,10 +1909,10 @@ endif::holygrail,swallow[]
end
test 'ifndef with both alternative attributes set does not include content' do
- input = <<-EOS
-ifndef::holygrail,swallow[]
-Our quest is complete!
-endif::holygrail,swallow[]
+ input = <<~'EOS'
+ ifndef::holygrail,swallow[]
+ Our quest is complete!
+ endif::holygrail,swallow[]
EOS
result = (Asciidoctor::Document.new input, attributes: { 'swallow' => '', 'holygrail' => '' }).reader.read
@@ -1961,10 +1920,10 @@ endif::holygrail,swallow[]
end
test 'ifndef with no alternative attributes set includes content' do
- input = <<-EOS
-ifndef::holygrail,swallow[]
-Our quest is complete!
-endif::holygrail,swallow[]
+ input = <<~'EOS'
+ ifndef::holygrail,swallow[]
+ Our quest is complete!
+ endif::holygrail,swallow[]
EOS
result = (Asciidoctor::Document.new input).reader.read
@@ -1972,10 +1931,10 @@ endif::holygrail,swallow[]
end
test 'ifndef with no required attributes set includes content' do
- input = <<-EOS
-ifndef::holygrail+swallow[]
-Our quest is complete!
-endif::holygrail+swallow[]
+ input = <<~'EOS'
+ ifndef::holygrail+swallow[]
+ Our quest is complete!
+ endif::holygrail+swallow[]
EOS
result = (Asciidoctor::Document.new input).reader.read
@@ -1983,10 +1942,10 @@ endif::holygrail+swallow[]
end
test 'ifndef with all required attributes set does not include content' do
- input = <<-EOS
-ifndef::holygrail+swallow[]
-Our quest is complete!
-endif::holygrail+swallow[]
+ input = <<~'EOS'
+ ifndef::holygrail+swallow[]
+ Our quest is complete!
+ endif::holygrail+swallow[]
EOS
result = (Asciidoctor::Document.new input, attributes: { 'swallow' => '', 'holygrail' => '' }).reader.read
@@ -1994,10 +1953,10 @@ endif::holygrail+swallow[]
end
test 'ifndef with at least one required attributes set does not include content' do
- input = <<-EOS
-ifndef::holygrail+swallow[]
-Our quest is complete!
-endif::holygrail+swallow[]
+ input = <<~'EOS'
+ ifndef::holygrail+swallow[]
+ Our quest is complete!
+ endif::holygrail+swallow[]
EOS
result = (Asciidoctor::Document.new input, attributes: { 'swallow' => '' }).reader.read
@@ -2005,10 +1964,10 @@ endif::holygrail+swallow[]
end
test 'escaped ifdef is unescaped and ignored' do
- input = <<-EOS
-\\ifdef::holygrail[]
-content
-\\endif::holygrail[]
+ input = <<~'EOS'
+ \ifdef::holygrail[]
+ content
+ \endif::holygrail[]
EOS
doc = Asciidoctor::Document.new input
@@ -2021,10 +1980,10 @@ content
end
test 'ifeval comparing missing attribute to nil includes content' do
- input = <<-EOS
-ifeval::['{foo}' == '']
-No foo for you!
-endif::[]
+ input = <<~'EOS'
+ ifeval::['{foo}' == '']
+ No foo for you!
+ endif::[]
EOS
doc = Asciidoctor::Document.new input
@@ -2037,10 +1996,10 @@ endif::[]
end
test 'ifeval comparing missing attribute to 0 drops content' do
- input = <<-EOS
-ifeval::[{leveloffset} == 0]
-I didn't make the cut!
-endif::[]
+ input = <<~'EOS'
+ ifeval::[{leveloffset} == 0]
+ I didn't make the cut!
+ endif::[]
EOS
doc = Asciidoctor::Document.new input
@@ -2053,10 +2012,10 @@ endif::[]
end
test 'ifeval comparing double-quoted attribute to matching string includes content' do
- input = <<-EOS
-ifeval::["{gem}" == "asciidoctor"]
-Asciidoctor it is!
-endif::[]
+ input = <<~'EOS'
+ ifeval::["{gem}" == "asciidoctor"]
+ Asciidoctor it is!
+ endif::[]
EOS
doc = Asciidoctor::Document.new input, attributes: { 'gem' => 'asciidoctor' }
@@ -2069,10 +2028,10 @@ endif::[]
end
test 'ifeval comparing single-quoted attribute to matching string includes content' do
- input = <<-EOS
-ifeval::['{gem}' == 'asciidoctor']
-Asciidoctor it is!
-endif::[]
+ input = <<~'EOS'
+ ifeval::['{gem}' == 'asciidoctor']
+ Asciidoctor it is!
+ endif::[]
EOS
doc = Asciidoctor::Document.new input, attributes: { 'gem' => 'asciidoctor' }
@@ -2085,10 +2044,10 @@ endif::[]
end
test 'ifeval comparing quoted attribute to non-matching string drops content' do
- input = <<-EOS
-ifeval::['{gem}' == 'asciidoctor']
-Asciidoctor it is!
-endif::[]
+ input = <<~'EOS'
+ ifeval::['{gem}' == 'asciidoctor']
+ Asciidoctor it is!
+ endif::[]
EOS
doc = Asciidoctor::Document.new input, attributes: { 'gem' => 'tilt' }
@@ -2101,10 +2060,10 @@ endif::[]
end
test 'ifeval comparing attribute to lower version number includes content' do
- input = <<-EOS
-ifeval::['{asciidoctor-version}' >= '0.1.0']
-That version will do!
-endif::[]
+ input = <<~'EOS'
+ ifeval::['{asciidoctor-version}' >= '0.1.0']
+ That version will do!
+ endif::[]
EOS
doc = Asciidoctor::Document.new input
@@ -2117,10 +2076,10 @@ endif::[]
end
test 'ifeval comparing attribute to self includes content' do
- input = <<-EOS
-ifeval::['{asciidoctor-version}' == '{asciidoctor-version}']
-Of course it's the same!
-endif::[]
+ input = <<~'EOS'
+ ifeval::['{asciidoctor-version}' == '{asciidoctor-version}']
+ Of course it's the same!
+ endif::[]
EOS
doc = Asciidoctor::Document.new input
@@ -2133,10 +2092,10 @@ endif::[]
end
test 'ifeval arguments can be transposed' do
- input = <<-EOS
-ifeval::['0.1.0' <= '{asciidoctor-version}']
-That version will do!
-endif::[]
+ input = <<~'EOS'
+ ifeval::['0.1.0' <= '{asciidoctor-version}']
+ That version will do!
+ endif::[]
EOS
doc = Asciidoctor::Document.new input
@@ -2149,10 +2108,10 @@ endif::[]
end
test 'ifeval matching numeric equality includes content' do
- input = <<-EOS
-ifeval::[{rings} == 1]
-One ring to rule them all!
-endif::[]
+ input = <<~'EOS'
+ ifeval::[{rings} == 1]
+ One ring to rule them all!
+ endif::[]
EOS
doc = Asciidoctor::Document.new input, attributes: { 'rings' => '1' }
@@ -2165,10 +2124,10 @@ endif::[]
end
test 'ifeval matching numeric inequality includes content' do
- input = <<-EOS
-ifeval::[{rings} != 0]
-One ring to rule them all!
-endif::[]
+ input = <<~'EOS'
+ ifeval::[{rings} != 0]
+ One ring to rule them all!
+ endif::[]
EOS
doc = Asciidoctor::Document.new input, attributes: { 'rings' => '1' }
@@ -2181,9 +2140,9 @@ endif::[]
end
test 'ifdef with no target is ignored' do
- input = <<-EOS
-ifdef::[]
-content
+ input = <<~'EOS'
+ ifdef::[]
+ content
EOS
doc = Asciidoctor::Document.new input