test/extensions_test.rb in asciidoctor-1.5.6 vs test/extensions_test.rb in asciidoctor-1.5.6.1

- old
+ new

@@ -226,20 +226,31 @@ end end test 'should register extension block' do begin - Asciidoctor::Extensions.register(:sample) do + Asciidoctor::Extensions.register :sample do end refute_nil Asciidoctor::Extensions.groups assert_equal 1, Asciidoctor::Extensions.groups.size assert Asciidoctor::Extensions.groups[:sample].is_a? Proc ensure Asciidoctor::Extensions.unregister_all end end + test 'should coerce group name to symbol when registering' do + begin + Asciidoctor::Extensions.register 'sample', SampleExtensionGroup + refute_nil Asciidoctor::Extensions.groups + assert_equal 1, Asciidoctor::Extensions.groups.size + assert_equal SampleExtensionGroup, Asciidoctor::Extensions.groups[:sample] + ensure + Asciidoctor::Extensions.unregister_all + end + end + test 'should unregister extension group by symbol name' do begin Asciidoctor::Extensions.register :sample, SampleExtensionGroup refute_nil Asciidoctor::Extensions.groups assert_equal 1, Asciidoctor::Extensions.groups.size @@ -463,11 +474,11 @@ test 'should not match block processor for unsupported context' do registry = Asciidoctor::Extensions::Registry.new registry.block SampleBlock, :sample registry.activate Asciidoctor::Document.new - assert !(registry.registered_for_block? :sample, :sidebar) + refute registry.registered_for_block? :sample, :sidebar end test 'should instantiate block macro processor' do registry = Asciidoctor::Extensions::Registry.new registry.block_macro SampleBlockMacro, 'sample' @@ -931,21 +942,21 @@ test 'should not carry over attributes if block processor returns nil' do begin Asciidoctor::Extensions.register do block do - named :skip + named :skipme on_context :paragraph parses_content_as :raw process do |parent, reader, attrs| nil end end end input = <<-EOS .unused title -[skip] +[skipme] not rendered -- rendered -- @@ -956,10 +967,42 @@ ensure Asciidoctor::Extensions.unregister_all end end + test 'should not invoke process method or carry over attributes if block processor declares skip content model' do + begin + process_method_called = false + Asciidoctor::Extensions.register do + block do + named :ignore + on_context :paragraph + parses_content_as :skip + process do |parent, reader, attrs| + process_method_called = true + nil + end + end + end + input = <<-EOS +.unused title +[ignore] +not rendered + +-- +rendered +-- + EOS + doc = document_from_string input + refute process_method_called + assert_equal 1, doc.blocks.size + assert_nil doc.blocks[0].attributes['title'] + ensure + Asciidoctor::Extensions.unregister_all + end + end + test 'should pass attributes by value to block processor' do begin Asciidoctor::Extensions.register do block do named :foo @@ -1128,10 +1171,10 @@ output = Asciidoctor.convert_file sample_input_path, :to_file => false, :header_footer => true, :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docinfo' => ''} - assert !output.empty? + refute_empty output assert_css 'script[src="modernizr.js"]', output, 1 assert_css 'meta[name="robots"]', output, 1 assert_css 'meta[http-equiv="imagetoolbar"]', output, 0 ensure Asciidoctor::Extensions.unregister_all