From dd5ae5afa6db95651eb67c19eaaeab4e368dc641 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Wed, 22 May 2013 03:20:30 -0600 Subject: resolves #335 fix bad variable name, add test for it --- lib/asciidoctor.rb | 2 +- test/document_test.rb | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) 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') -- cgit v1.2.3