diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2018-04-21 14:19:18 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-21 14:19:18 -0600 |
| commit | 2b6a3767900d0a9fc9bcc7a05f72df6173942e26 (patch) | |
| tree | 63fc85523fd0eab0b8266fa966528cb03b6eaf39 /test/reader_test.rb | |
| parent | 4fbfe029590f3f5fe649301f559de15307be09a0 (diff) | |
resolves #2361 warn if a specified include tag is unclosed (PR #2696)
- warn if a tag specified in the include directive is unclosed in the include file
- add tests to verify warnings
- fix unclosed tags in test fixtures
- remove duplicate test
Diffstat (limited to 'test/reader_test.rb')
| -rw-r--r-- | test/reader_test.rb | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/test/reader_test.rb b/test/reader_test.rb index c8589a73..bb1eca90 100644 --- a/test/reader_test.rb +++ b/test/reader_test.rb @@ -956,18 +956,7 @@ include::fixtures/include-file.asciidoc[tag=snippetA] refute_match(/included content/, output) end - test 'should warn if tag specified in include directive is missing' do - input = <<-EOS -include::fixtures/include-file.asciidoc[tag=no-such-tag] - EOS - - using_memory_logger do |logger| - render_embedded_string input, :safe => :safe, :base_dir => DIRNAME - assert_message logger, :WARN, '~<stdin>: line 1: tag \'no-such-tag\' not found in include file', Hash - end - end - - test 'include directive supports selecting lines by multiple tags' do + test 'include directive supports selecting lines by tags' do input = <<-EOS include::fixtures/include-file.asciidoc[tags=snippetA;snippetB] EOS @@ -979,19 +968,6 @@ include::fixtures/include-file.asciidoc[tags=snippetA;snippetB] refute_match(/included content/, output) end - test 'should warn if tags specified in include directive are missing' do - input = <<-EOS -include::fixtures/include-file.asciidoc[tags=no-such-tag-b;no-such-tag-a] - EOS - - using_memory_logger do |logger| - render_embedded_string input, :safe => :safe, :base_dir => DIRNAME - # NOTE Ruby 1.8 swaps the order of the list for some silly reason - expected_tags = ::RUBY_MIN_VERSION_1_9 ? 'no-such-tag-b, no-such-tag-a' : 'no-such-tag-a, no-such-tag-b' - assert_message logger, :WARN, %(~<stdin>: line 1: tags '#{expected_tags}' not found in include file), Hash - end - end - test 'include directive supports selecting lines by tag in language that uses circumfix comments' do { 'include-file.xml' => '<snippet>content</snippet>', @@ -1157,14 +1133,41 @@ end) assert_includes output, expected end - test 'should warn if tag is not found in include file' do + test 'should warn if specified tag is not found in include file' do + input = <<-EOS +include::fixtures/include-file.asciidoc[tag=no-such-tag] + EOS + + using_memory_logger do |logger| + render_embedded_string input, :safe => :safe, :base_dir => DIRNAME + assert_message logger, :WARN, %(~<stdin>: line 1: tag 'no-such-tag' not found in include file), Hash + end + end + + test 'should warn if specified tags are not found in include file' do input = <<-EOS -include::fixtures/include-file.asciidoc[tag=snippetZ] +include::fixtures/include-file.asciidoc[tags=no-such-tag-b;no-such-tag-a] EOS using_memory_logger do |logger| render_embedded_string input, :safe => :safe, :base_dir => DIRNAME - assert_message logger, :WARN, '~<stdin>: line 1: tag \'snippetZ\' not found in include file', Hash + # NOTE Ruby 1.8 swaps the order of the list for some silly reason + expected_tags = ::RUBY_MIN_VERSION_1_9 ? 'no-such-tag-b, no-such-tag-a' : 'no-such-tag-a, no-such-tag-b' + assert_message logger, :WARN, %(~<stdin>: line 1: tags '#{expected_tags}' not found in include file), Hash + end + end + + test 'should warn if specified tag in include file is not closed' do + input = <<-EOS +++++ +include::fixtures/unclosed-tag.adoc[tag=a] +++++ + EOS + + using_memory_logger do |logger| + result = render_embedded_string input, :safe => :safe, :base_dir => DIRNAME + assert_equal 'a', result + assert_message logger, :WARN, %(~<stdin>: line 2: detected unclosed tag 'a' starting at line 2 of include file), Hash end end |
