diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2018-04-09 01:51:16 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2018-04-09 01:51:16 -0600 |
| commit | 925dc11c78cea570241344af69780bfbb720aa61 (patch) | |
| tree | 87f471b0b534505621ba813b5dbb2ce8ba119d72 /test | |
| parent | 8f12831e50668c54a463c84f2ab3a9df04e3fc01 (diff) | |
delegate to test helper method to resolve test directory and fixture paths
Diffstat (limited to 'test')
| -rw-r--r-- | test/converter_test.rb | 48 | ||||
| -rw-r--r-- | test/extensions_test.rb | 2 | ||||
| -rw-r--r-- | test/invoker_test.rb | 68 | ||||
| -rw-r--r-- | test/reader_test.rb | 2 | ||||
| -rw-r--r-- | test/tables_test.rb | 2 | ||||
| -rw-r--r-- | test/test_helper.rb | 12 | ||||
| -rw-r--r-- | test/text_test.rb | 2 |
7 files changed, 65 insertions, 71 deletions
diff --git a/test/converter_test.rb b/test/converter_test.rb index 272f01bd..d39c7ed2 100644 --- a/test/converter_test.rb +++ b/test/converter_test.rb @@ -9,7 +9,7 @@ context 'Converter' do context 'View options' do test 'should set Haml format to html5 for html5 backend' do - doc = Asciidoctor::Document.new [], :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml'), :template_cache => false + doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter selected = doc.converter.find_converter('paragraph') assert_kind_of Asciidoctor::Converter::TemplateConverter, selected @@ -18,7 +18,7 @@ context 'Converter' do end test 'should set Haml format to xhtml for docbook backend' do - doc = Asciidoctor::Document.new [], :backend => 'docbook45', :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml'), :template_cache => false + doc = Asciidoctor::Document.new [], :backend => 'docbook45', :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter selected = doc.converter.find_converter('paragraph') assert_kind_of Asciidoctor::Converter::TemplateConverter, selected @@ -27,10 +27,7 @@ context 'Converter' do end test 'should configure Slim to resolve includes in specified template dirs' do - template_dirs = [ - File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim'), - File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim-overrides'), - ] + template_dirs = [(fixture_path 'custom-backends/slim'), (fixture_path 'custom-backends/slim-overrides')] doc = Asciidoctor::Document.new [], :template_dirs => template_dirs, :template_cache => false assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter selected = doc.converter.find_converter('paragraph') @@ -40,7 +37,7 @@ context 'Converter' do end test 'should coerce template_dirs option to an Array' do - template_dirs = File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim') + template_dirs = fixture_path 'custom-backends/slim' doc = Asciidoctor::Document.new [], :template_dirs => template_dirs, :template_cache => false assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter selected = doc.converter.find_converter('paragraph') @@ -49,7 +46,7 @@ context 'Converter' do end test 'should set Slim format to html for html5 backend' do - doc = Asciidoctor::Document.new [], :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim'), :template_cache => false + doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter selected = doc.converter.find_converter('paragraph') assert_kind_of Asciidoctor::Converter::TemplateConverter, selected @@ -58,7 +55,7 @@ context 'Converter' do end test 'should set Slim format to nil for docbook backend' do - doc = Asciidoctor::Document.new [], :backend => 'docbook45', :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim'), :template_cache => false + doc = Asciidoctor::Document.new [], :backend => 'docbook45', :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter selected = doc.converter.find_converter('paragraph') assert_kind_of Asciidoctor::Converter::TemplateConverter, selected @@ -67,7 +64,7 @@ context 'Converter' do end test 'should set safe mode of Slim AsciiDoc engine to match document safe mode when Slim >= 3' do - doc = Asciidoctor::Document.new [], :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim'), :template_cache => false, :safe => :unsafe + doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false, :safe => :unsafe assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter selected = doc.converter.find_converter('paragraph') assert_kind_of Asciidoctor::Converter::TemplateConverter, selected @@ -80,7 +77,7 @@ context 'Converter' do end test 'should support custom template engine options for known engine' do - doc = Asciidoctor::Document.new [], :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim'), :template_cache => false, :template_engine_options => { :slim => { :pretty => true } } + doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false, :template_engine_options => { :slim => { :pretty => true } } assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter selected = doc.converter.find_converter('paragraph') assert_kind_of Asciidoctor::Converter::TemplateConverter, selected @@ -89,7 +86,7 @@ context 'Converter' do end test 'should support custom template engine options' do - doc = Asciidoctor::Document.new [], :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim'), :template_cache => false, :template_engine_options => { :slim => { :pretty => true } } + doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false, :template_engine_options => { :slim => { :pretty => true } } assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter selected = doc.converter.find_converter('paragraph') assert_kind_of Asciidoctor::Converter::TemplateConverter, selected @@ -101,7 +98,7 @@ context 'Converter' do context 'Custom backends' do test 'should load Haml templates for default backend' do - doc = Asciidoctor::Document.new [], :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml'), :template_cache => false + doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter ['paragraph', 'sidebar'].each do |node_name| selected = doc.converter.find_converter node_name @@ -116,7 +113,7 @@ context 'Converter' do doc.convert assert_equal '.html', doc.attributes['outfilesuffix'] - doc = Asciidoctor.load 'content', :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml'), :template_cache => false + doc = Asciidoctor.load 'content', :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false doc.convert assert_equal '.html', doc.attributes['outfilesuffix'] end @@ -126,13 +123,13 @@ context 'Converter' do doc.convert assert_equal '.foo', doc.attributes['outfilesuffix'] - doc = Asciidoctor.load 'content', :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml'), :template_cache => false, :attributes => {'outfilesuffix' => '.foo'} + doc = Asciidoctor.load 'content', :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false, :attributes => {'outfilesuffix' => '.foo'} doc.convert assert_equal '.foo', doc.attributes['outfilesuffix'] end test 'should load Haml templates for docbook45 backend' do - doc = Asciidoctor::Document.new [], :backend => 'docbook45', :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml'), :template_cache => false + doc = Asciidoctor::Document.new [], :backend => 'docbook45', :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter ['paragraph'].each do |node_name| selected = doc.converter.find_converter node_name @@ -157,7 +154,7 @@ Sidebar content **** EOS - output = render_embedded_string input, :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml'), :template_cache => false + output = render_embedded_string input, :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false assert_xpath '/*[@class="sect1"]/*[@class="sectionbody"]/p', output, 1 assert_xpath '//aside', output, 1 assert_xpath '/*[@class="sect1"]/*[@class="sectionbody"]/p/following-sibling::aside', output, 1 @@ -170,7 +167,7 @@ Sidebar content # clear out any cache, just to be sure Asciidoctor::Converter::TemplateConverter.clear_caches if defined? Asciidoctor::Converter::TemplateConverter - template_dir = File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml') + template_dir = fixture_path 'custom-backends/haml' doc = Asciidoctor::Document.new [], :template_dir => template_dir doc.converter caches = Asciidoctor::Converter::TemplateConverter.caches @@ -203,7 +200,7 @@ Sidebar content end test 'should use custom cache to cache templates' do - template_dir = File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml') + template_dir = fixture_path 'custom-backends/haml' Asciidoctor::PathResolver.new.system_path(File.join(template_dir, 'html5', 'block_paragraph.html.haml'), nil) caches = { :scans => {}, :templates => {} } doc = Asciidoctor::Document.new [], :template_dir => template_dir, :template_cache => caches @@ -220,8 +217,7 @@ Sidebar content # clear out any cache, just to be sure Asciidoctor::Converter::TemplateConverter.clear_caches if defined? Asciidoctor::Converter::TemplateConverter - doc = Asciidoctor::Document.new [], :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'haml'), - :template_cache => false + doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/haml'), :template_cache => false doc.converter caches = Asciidoctor::Converter::TemplateConverter.caches assert caches.empty? || caches[:scans].empty? @@ -233,7 +229,7 @@ Sidebar content end test 'should load ERB templates using ERBTemplate if eruby is not set' do - doc = Asciidoctor::Document.new [], :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'erb'), :template_cache => false + doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/erb'), :template_cache => false assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter ['paragraph'].each do |node_name| selected = doc.converter.find_converter node_name @@ -247,7 +243,7 @@ Sidebar content end test 'should load ERB templates using ErubisTemplate if eruby is set to erubis' do - doc = Asciidoctor::Document.new [], :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'erb'), :template_cache => false, :eruby => 'erubis' + doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/erb'), :template_cache => false, :eruby => 'erubis' assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter ['paragraph'].each do |node_name| selected = doc.converter.find_converter node_name @@ -261,7 +257,7 @@ Sidebar content end test 'should load Slim templates for default backend' do - doc = Asciidoctor::Document.new [], :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim'), :template_cache => false + doc = Asciidoctor::Document.new [], :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter ['paragraph', 'sidebar'].each do |node_name| selected = doc.converter.find_converter node_name @@ -272,7 +268,7 @@ Sidebar content end test 'should load Slim templates for docbook45 backend' do - doc = Asciidoctor::Document.new [], :backend => 'docbook45', :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim'), :template_cache => false + doc = Asciidoctor::Document.new [], :backend => 'docbook45', :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter ['paragraph'].each do |node_name| selected = doc.converter.find_converter node_name @@ -297,7 +293,7 @@ Sidebar content **** EOS - output = render_embedded_string input, :template_dir => File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends', 'slim'), :template_cache => false + output = render_embedded_string input, :template_dir => (fixture_path 'custom-backends/slim'), :template_cache => false assert_xpath '/*[@class="sect1"]/*[@class="sectionbody"]/p', output, 1 assert_xpath '//aside', output, 1 assert_xpath '/*[@class="sect1"]/*[@class="sectionbody"]/p/following-sibling::aside', output, 1 diff --git a/test/extensions_test.rb b/test/extensions_test.rb index 2678d969..286722cf 100644 --- a/test/extensions_test.rb +++ b/test/extensions_test.rb @@ -691,7 +691,7 @@ last line end end # Safe Mode is not required here - document = empty_document :base_dir => File.expand_path(File.dirname(__FILE__)), :extension_registry => registry + document = empty_document :base_dir => testdir, :extension_registry => registry reader = Asciidoctor::PreprocessorReader.new document, input, nil, :normalize => true lines = [] lines << reader.read_line diff --git a/test/invoker_test.rb b/test/invoker_test.rb index 6c1c605b..4d66a6e8 100644 --- a/test/invoker_test.rb +++ b/test/invoker_test.rb @@ -33,8 +33,8 @@ context 'Invoker' do end test 'should set implicit doc info attributes' do - sample_filepath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.asciidoc')) - sample_filedir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures')) + sample_filepath = fixture_path 'sample.asciidoc' + sample_filedir = fixturedir invoker = invoke_cli_to_buffer %w(-o /dev/null), sample_filepath doc = invoker.document assert_equal 'sample', doc.attr('docname') @@ -48,7 +48,7 @@ context 'Invoker' do end test 'should allow docdate and doctime to be overridden' do - sample_filepath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.asciidoc')) + sample_filepath = fixture_path 'sample.asciidoc' invoker = invoke_cli_to_buffer %w(-o /dev/null -a docdate=2015-01-01 -a doctime=10:00:00-07:00), sample_filepath doc = invoker.document assert doc.attr?('docdate', '2015-01-01') @@ -86,7 +86,7 @@ context 'Invoker' do end test 'should accept document from stdin and write to output file' do - sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample-output.html')) + sample_outpath = fixture_path 'sample-output.html' begin invoker = invoke_cli(%W(-s -o #{sample_outpath}), '-') { 'content' } doc = invoker.document @@ -111,13 +111,13 @@ context 'Invoker' do end test 'should fail if input file matches specified output file' do - sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.asciidoc')) + sample_outpath = fixture_path 'sample.asciidoc' invoker = invoke_cli_to_buffer %W(-o #{sample_outpath}), 'sample.asciidoc' assert_match(/input file and output file cannot be the same/, invoker.read_error) end test 'should accept input from named pipe and output to stdout' do - sample_inpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample-pipe.adoc')) + sample_inpath = fixture_path 'sample-pipe.adoc' begin %x(mkfifo #{sample_inpath}) write_thread = Thread.new do @@ -133,7 +133,7 @@ context 'Invoker' do end if RUBY_MIN_VERSION_1_9 && !windows? test 'should allow docdir to be specified when input is a string' do - expected_docdir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures')) + expected_docdir = fixturedir invoker = invoke_cli_to_buffer(%w(-s --base-dir test/fixtures -o /dev/null), '-') { 'content' } doc = invoker.document assert_equal expected_docdir, doc.attr('docdir') @@ -203,7 +203,7 @@ context 'Invoker' do end test 'should output to file name based on input file name' do - sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.html')) + sample_outpath = fixture_path 'sample.html' begin invoker = invoke_cli doc = invoker.document @@ -222,8 +222,8 @@ context 'Invoker' do end test 'should output to file in destination directory if set' do - destination_path = File.expand_path(File.join(File.dirname(__FILE__), 'test_output')) - sample_outpath = File.join(destination_path, 'sample.html') + destination_path = File.join testdir, 'test_output' + sample_outpath = File.join destination_path, 'sample.html' begin FileUtils.mkdir_p(destination_path) # QUESTION should -D be relative to working directory or source directory? @@ -256,7 +256,7 @@ context 'Invoker' do end test 'should output to file specified' do - sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample-output.html')) + sample_outpath = fixture_path 'sample-output.html' begin invoker = invoke_cli %W(-o #{sample_outpath}) doc = invoker.document @@ -268,9 +268,9 @@ context 'Invoker' do end test 'should copy default stylesheet to target directory if linkcss is specified' do - sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample-output.html')) - asciidoctor_stylesheet = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'asciidoctor.css')) - coderay_stylesheet = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'coderay-asciidoctor.css')) + sample_outpath = fixture_path 'sample-output.html' + asciidoctor_stylesheet = fixture_path 'asciidoctor.css' + coderay_stylesheet = fixture_path 'coderay-asciidoctor.css' begin invoker = invoke_cli %W(-o #{sample_outpath} -a linkcss -a source-highlighter=coderay) invoker.document @@ -285,8 +285,8 @@ context 'Invoker' do end test 'should not copy default stylesheet to target directory if linkcss is set and copycss is unset' do - sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample-output.html')) - default_stylesheet = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'asciidoctor.css')) + sample_outpath = fixture_path 'sample-output.html' + default_stylesheet = fixture_path 'asciidoctor.css' begin invoker = invoke_cli %W(-o #{sample_outpath} -a linkcss -a copycss!) invoker.document @@ -299,7 +299,7 @@ context 'Invoker' do end test 'should copy custom stylesheet to target directory if stylesheet and linkcss is specified' do - destdir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'output')) + destdir = fixture_path 'output' sample_outpath = File.join destdir, 'sample-output.html' stylesdir = File.join destdir, 'styles' custom_stylesheet = File.join stylesdir, 'custom.css' @@ -317,7 +317,7 @@ context 'Invoker' do end test 'should not copy custom stylesheet to target directory if stylesheet and linkcss are set and copycss is unset' do - destdir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'output')) + destdir = fixture_path 'output' sample_outpath = File.join destdir, 'sample-output.html' stylesdir = File.join destdir, 'styles' custom_stylesheet = File.join stylesdir, 'custom.css' @@ -335,7 +335,7 @@ context 'Invoker' do end test 'should not copy custom stylesheet to target directory if stylesdir is a URI' do - destdir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'output')) + destdir = fixture_path 'output' sample_outpath = File.join destdir, 'sample-output.html' stylesdir = File.join destdir, 'http:' begin @@ -351,8 +351,8 @@ context 'Invoker' do end test 'should render all passed files' do - basic_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'basic.html')) - sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.html')) + basic_outpath = fixture_path 'basic.html' + sample_outpath = fixture_path 'sample.html' begin invoke_cli_with_filenames [], %w(basic.asciidoc sample.asciidoc) assert File.exist?(basic_outpath) @@ -364,9 +364,9 @@ context 'Invoker' do end test 'options should not be modified when processing multiple files' do - destination_path = File.expand_path(File.join(File.dirname(__FILE__), 'test_output')) - basic_outpath = File.join(destination_path, 'basic.htm') - sample_outpath = File.join(destination_path, 'sample.htm') + destination_path = File.join testdir, 'test_output' + basic_outpath = File.join destination_path, 'basic.htm' + sample_outpath = File.join destination_path, 'sample.htm' begin invoke_cli_with_filenames %w(-D test/test_output -a outfilesuffix=.htm), %w(basic.asciidoc sample.asciidoc) assert File.exist?(basic_outpath) @@ -379,7 +379,7 @@ context 'Invoker' do end test 'should render all files that matches a glob expression' do - basic_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'basic.html')) + basic_outpath = fixture_path 'basic.html' begin invoke_cli_to_buffer [], "ba*.asciidoc" assert File.exist?(basic_outpath) @@ -389,8 +389,8 @@ context 'Invoker' do end test 'should render all files that matches an absolute path glob expression' do - basic_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'basic.html')) - glob = File.join(File.expand_path(File.dirname(__FILE__)), 'fixtures', 'ba*.asciidoc') + basic_outpath = fixture_path 'basic.html' + glob = fixture_path 'ba*.asciidoc' # test Windows using backslash-style pathname if File::ALT_SEPARATOR == '\\' glob = glob.tr '/', '\\' @@ -412,7 +412,7 @@ context 'Invoker' do end test 'should write page for each alternate manname' do - outdir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures')) + outdir = fixturedir outfile_1 = File.join outdir, 'eve.1' outfile_2 = File.join outdir, 'islifeform.1' input = <<-EOS @@ -516,7 +516,7 @@ eve, islifeform - analyzes an image to determine if it's a picture of a life for end test 'should locate custom templates based on template dir, template engine and backend' do - custom_backend_root = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends')) + custom_backend_root = fixture_path 'custom-backends' invoker = invoke_cli_to_buffer %W(-E haml -T #{custom_backend_root} -o -) doc = invoker.document assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter @@ -526,8 +526,8 @@ eve, islifeform - analyzes an image to determine if it's a picture of a life for end test 'should load custom templates from multiple template directories' do - custom_backend_1 = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends/haml/html5')) - custom_backend_2 = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'custom-backends/haml/html5-tweaks')) + custom_backend_1 = fixture_path 'custom-backends/haml/html5' + custom_backend_2 = fixture_path 'custom-backends/haml/html5-tweaks' invoker = invoke_cli_to_buffer %W(-T #{custom_backend_1} -T #{custom_backend_2} -o - -s) output = invoker.read_output assert_css '.paragraph', output, 0 @@ -617,7 +617,7 @@ eve, islifeform - analyzes an image to determine if it's a picture of a life for end test 'should force default external encoding to UTF-8' do - executable = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'asciidoctor')) + executable = File.join ASCIIDOCTOR_PROJECT_DIR, 'bin', 'asciidoctor' input_path = fixture_path 'encoding.asciidoc' old_lang = ENV['LANG'] ENV['LANG'] = 'US-ASCII' @@ -660,7 +660,7 @@ eve, islifeform - analyzes an image to determine if it's a picture of a life for old_source_date_epoch = ENV.delete 'SOURCE_DATE_EPOCH' begin ENV['SOURCE_DATE_EPOCH'] = '1234123412' - sample_filepath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.asciidoc')) + sample_filepath = fixture_path 'sample.asciidoc' invoker = invoke_cli_to_buffer %w(-o /dev/null), sample_filepath doc = invoker.document assert_equal '2009-02-08', (doc.attr 'docdate') @@ -682,7 +682,7 @@ eve, islifeform - analyzes an image to determine if it's a picture of a life for old_source_date_epoch = ENV.delete 'SOURCE_DATE_EPOCH' begin ENV['SOURCE_DATE_EPOCH'] = 'aaaaaaaa' - sample_filepath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.asciidoc')) + sample_filepath = fixture_path 'sample.asciidoc' assert_equal 1, (invoke_cli_to_buffer %w(-o /dev/null), sample_filepath).code ensure if old_source_date_epoch diff --git a/test/reader_test.rb b/test/reader_test.rb index 80b65273..19d27e51 100644 --- a/test/reader_test.rb +++ b/test/reader_test.rb @@ -5,7 +5,7 @@ unless defined? ASCIIDOCTOR_PROJECT_DIR end class ReaderTest < Minitest::Test - DIRNAME = File.expand_path(File.dirname(__FILE__)) + DIRNAME = File.expand_path File.dirname __FILE__ SAMPLE_DATA = <<-EOS.chomp.split(::Asciidoctor::LF) first line diff --git a/test/tables_test.rb b/test/tables_test.rb index e2ec78e8..ac299d08 100644 --- a/test/tables_test.rb +++ b/test/tables_test.rb @@ -1090,7 +1090,7 @@ a|include::fixtures/include-file.asciidoc[] |=== EOS - output = render_embedded_string input, :safe => :safe, :base_dir => File.dirname(__FILE__) + output = render_embedded_string input, :safe => :safe, :base_dir => testdir assert_match(/included content/, output) end diff --git a/test/test_helper.rb b/test/test_helper.rb index e98f2416..fe260dc4 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -220,7 +220,6 @@ class Minitest::Test end if (template_dir = ENV['TEMPLATE_DIR']) opts[:template_dir] = template_dir unless opts.has_key? :template_dir - #opts[:template_dir] = File.join(File.dirname(__FILE__), '..', '..', 'asciidoctor-backends', 'erb') unless opts.has_key? :template_dir end nil end @@ -239,14 +238,13 @@ class Minitest::Test end def invoke_cli_with_filenames(argv = [], filenames = [], &block) - filepaths = Array.new - filenames.each { |filename| - if filenames.nil?|| ::Pathname.new(filename).absolute? - filepaths.push(filename) + filenames.each {|filename| + if filenames.nil? || ::Pathname.new(filename).absolute? + filepaths << filename else - filepaths.push(File.join(File.dirname(__FILE__), 'fixtures', filename)) + filepaths << (fixture_path filename) end } @@ -264,7 +262,7 @@ class Minitest::Test if filename.nil? || filename == '-' || ::Pathname.new(filename).absolute? filepath = filename else - filepath = File.join(File.dirname(__FILE__), 'fixtures', filename) + filepath = fixture_path filename end invoker = Asciidoctor::Cli::Invoker.new(argv + [filepath]) if buffers diff --git a/test/text_test.rb b/test/text_test.rb index c5328537..f1591447 100644 --- a/test/text_test.rb +++ b/test/text_test.rb @@ -44,7 +44,7 @@ context "Text" do input = <<-EOS include::fixtures/encoding.asciidoc[tags=romé] EOS - doc = empty_safe_document :base_dir => File.expand_path(File.dirname(__FILE__)) + doc = empty_safe_document :base_dir => testdir reader = Asciidoctor::PreprocessorReader.new doc, input, nil, :normalize => true block = Asciidoctor::Parser.next_block(reader, doc) output = block.convert |
