summaryrefslogtreecommitdiff
path: root/test/reader_test.rb
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2014-02-17 18:07:50 -0700
committerDan Allen <dan.j.allen@gmail.com>2014-02-17 18:09:36 -0700
commita92e2d31cde2ff8df446f3cb7d80fb1a3ff87a39 (patch)
treef9a7f4379dfac7c7761499143cb7d83a6951c0f8 /test/reader_test.rb
parentbd73800c541590052cc319cfd5faa22750812ef9 (diff)
use in-process web server for URI tests
Diffstat (limited to 'test/reader_test.rb')
-rw-r--r--test/reader_test.rb30
1 files changed, 17 insertions, 13 deletions
diff --git a/test/reader_test.rb b/test/reader_test.rb
index a7aceef6..ffc5cd3c 100644
--- a/test/reader_test.rb
+++ b/test/reader_test.rb
@@ -618,35 +618,39 @@ include::fixtures/no-such-file.ad[]
end
test 'include directive can retrieve data from uri' do
- # disable use of asciidoctor.org due to bug in Rubinius reading zlib compressed response
- #url = 'http://asciidoctor.org/humans.txt'
- #match = /Asciidoctor/
- url = 'http://echo.jsontest.com/name/asciidoctor'
- expect = /\{"name": "asciidoctor"\}/
-
+ #url = 'http://echo.jsontest.com/name/asciidoctor'
+ url = %(http://#{Socket.gethostname}:9876/name/asciidoctor)
input = <<-EOS
....
include::#{url}[]
....
EOS
-
- output = render_embedded_string input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
+ expect = /\{"name": "asciidoctor"\}/
+ output = using_test_webserver do
+ render_embedded_string input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
+ end
+
+ assert_not_nil output
assert_match(expect, output)
end
test 'inaccessible uri referenced by include directive does not crash processor' do
+ url = %(http://#{Socket.gethostname}:9876/no_such_file)
input = <<-EOS
....
-include::http://127.0.0.1:0[]
+include::#{url}[]
....
EOS
-
- begin
- output = render_embedded_string input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
- assert_match(/Unresolved directive/, output)
+
+ output = begin
+ using_test_webserver do
+ render_embedded_string input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
+ end
rescue
flunk 'include directive should not raise exception on inaccessible uri'
end
+ assert_not_nil output
+ assert_match(/Unresolved directive/, output)
end
test 'include directive supports line selection' do