diff options
| author | Dan Allen <dallen@redhat.com> | 2013-06-29 14:48:40 -0600 |
|---|---|---|
| committer | Dan Allen <dallen@redhat.com> | 2013-06-29 14:48:40 -0600 |
| commit | 11e782f277dbf114ae33d2c2691d22353608b66c (patch) | |
| tree | 2dad54404b8b1a6c68e9e216e7a13c15901ff092 | |
| parent | 304b431cd4cf10f6eafcb3d2e2fc3557596e6999 (diff) | |
move default test options to separate method
| -rw-r--r-- | test/test_helper.rb | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb index de265439..bc255629 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -38,9 +38,7 @@ class Test::Unit::TestCase end def example_document(name, opts = {}) - opts[:header_footer] = true unless opts.has_key?(:header_footer) - #opts[:template_dir] = File.join(File.dirname(__FILE__), '..', '..', 'asciidoctor-backends', 'slim') - Asciidoctor::Document.new(File.readlines(sample_doc_path(name)), opts) + document_from_string File.read(sample_doc_path(name)), opts end def assert_difference(expression, difference = 1, message = nil, &block) @@ -129,15 +127,13 @@ class Test::Unit::TestCase end def document_from_string(src, opts = {}) - opts[:header_footer] = true unless opts.has_key?(:header_footer) - #opts[:template_dir] = File.join(File.dirname(__FILE__), '..', '..', 'asciidoctor-backends', 'slim') + assign_default_test_options opts Asciidoctor::Document.new(src.lines.entries, opts) end def block_from_string(src, opts = {}) opts[:header_footer] = false - #opts[:template_dir] = File.join(File.dirname(__FILE__), '..', '..', 'asciidoctor-backends', 'slim') - doc = Asciidoctor::Document.new(src.lines.entries, opts) + doc = document_from_string src, opts doc.blocks.first end @@ -155,6 +151,20 @@ class Test::Unit::TestCase [Asciidoctor::Lexer.parse_header_metadata(reader), reader] end + def assign_default_test_options(opts) + opts[:header_footer] = true unless opts.has_key?(:header_footer) + if opts[:header_footer] + # don't embed stylesheet unless test requests the default behavior + unless opts.has_key?(:linkcss_default) + opts[:attributes] ||= {} + opts[:attributes]['linkcss'] = nil + opts.delete(:linkcss_default) + end + end + #opts[:template_dir] = File.join(File.dirname(__FILE__), '..', '..', 'asciidoctor-backends', 'slim') + nil + end + # Expand the character for an entity such as — so # it can be used to match in an XPath expression def expand_entity(number) |
