Sha256: 6638e3904fbd3a821891552a75597bb07ce53088f62f05dbaac056ca036854d1

Contents?: true

Size: 1.88 KB

Versions: 76

Compression:

Stored size: 1.88 KB

Contents

require 'test_helper'
require 'tilt'

begin
  require 'tilt/asciidoc'

  class AsciidoctorTemplateTest < Minitest::Test
    HTML5_OUTPUT = "<div class=\"sect1\"><h2 id=\"_hello_world\">Hello World!</h2><div class=\"sectionbody\"></div></div>"
    DOCBOOK45_OUTPUT = "<section id=\"_hello_world\"><title>Hello World!</title></section>"
    DOCBOOK5_OUTPUT = "<section xml:id=\"_hello_world\"><title>Hello World!</title></section>"

    def strip_space(str)
      str.gsub(/>\s+</, '><').strip
    end

    test "registered for '.ad' files" do
      assert_equal Tilt::AsciidoctorTemplate, Tilt['ad']
    end

    test "registered for '.adoc' files" do
      assert_equal Tilt::AsciidoctorTemplate, Tilt['adoc']
    end

    test "registered for '.asciidoc' files" do
      assert_equal Tilt::AsciidoctorTemplate, Tilt['asciidoc']
    end

    test "preparing and evaluating html5 templates on #render" do
      template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'html5'}) { |t| "== Hello World!" } 
      assert_equal HTML5_OUTPUT, strip_space(template.render)
    end

    test "preparing and evaluating docbook 4.5 templates on #render" do
      template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'docbook45'}) { |t| "== Hello World!" }
      assert_equal DOCBOOK45_OUTPUT, strip_space(template.render)
    end

    test "preparing and evaluating docbook 5 templates on #render" do
      template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'docbook5'}) { |t| "== Hello World!" }
      assert_equal DOCBOOK5_OUTPUT, strip_space(template.render)
    end

    test "can be rendered more than once" do
      template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'html5'}) { |t| "== Hello World!" } 
      3.times { assert_equal HTML5_OUTPUT, strip_space(template.render) }
    end
  end
rescue LoadError
  warn "Tilt::AsciidoctorTemplate (disabled)"
end

Version data entries

76 entries across 75 versions & 14 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_asciidoctor_test.rb