summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dallen@redhat.com>2013-05-22 03:20:30 -0600
committerDan Allen <dallen@redhat.com>2013-05-22 03:20:30 -0600
commitdd5ae5afa6db95651eb67c19eaaeab4e368dc641 (patch)
tree28fded3344e8cde4ef866e34cbb39437865a14bb
parent23121b0f92b27086704f2d29efa25f478e2e1db7 (diff)
resolves #335 fix bad variable name, add test for it
-rwxr-xr-xlib/asciidoctor.rb2
-rw-r--r--test/document_test.rb21
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/asciidoctor.rb b/lib/asciidoctor.rb
index e7850272..1a1cf6af 100755
--- a/lib/asciidoctor.rb
+++ b/lib/asciidoctor.rb
@@ -823,7 +823,7 @@ module Asciidoctor
elsif write_in_place
to_file = File.join(File.dirname(input.path), "#{doc.attributes['docname']}#{doc.attributes['outfilesuffix']}")
elsif !stream_output && write_to_target
- working_dir = options.has_key?(:base_dir) ? File.expand_path(opts[:base_dir]) : File.expand_path(Dir.pwd)
+ working_dir = options.has_key?(:base_dir) ? File.expand_path(options[:base_dir]) : File.expand_path(Dir.pwd)
# QUESTION should the jail be the working_dir or doc.base_dir???
jail = doc.safe >= SafeMode::SAFE ? working_dir : nil
if to_dir
diff --git a/test/document_test.rb b/test/document_test.rb
index 27d84259..943b9a71 100644
--- a/test/document_test.rb
+++ b/test/document_test.rb
@@ -404,6 +404,27 @@ text
end
end
+ test 'wip should render document to file when base dir is set' do
+ sample_input_path = fixture_path('sample.asciidoc')
+ sample_output_path = fixture_path('result.html')
+ fixture_dir = fixture_path('')
+ begin
+ Asciidoctor.render_file(sample_input_path, :to_file => 'result.html', :base_dir => fixture_dir)
+ assert File.exist?(sample_output_path)
+ output = File.read(sample_output_path)
+ assert !output.empty?
+ assert_xpath '/html', output, 1
+ assert_xpath '/html/head', output, 1
+ assert_xpath '/html/body', output, 1
+ assert_xpath '/html/head/title[text() = "Document Title"]', output, 1
+ assert_xpath '/html/body/*[@id="header"]/h1[text() = "Document Title"]', output, 1
+ rescue => e
+ flunk e.message
+ ensure
+ FileUtils::rm(sample_output_path, :force => true)
+ end
+ end
+
test 'in_place option must not be used with to_file option' do
sample_input_path = fixture_path('sample.asciidoc')
sample_output_path = fixture_path('result.html')