Sha256: 98aaa38fc217205501c2d292d95fe2d1dfc75de1993e9a1496bc6f9eb6879be4

Contents?: true

Size: 1.89 KB

Versions: 25

Compression:

Stored size: 1.89 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 => boom
  warn "Tilt::AsciidoctorTemplate (disabled)"
end

Version data entries

25 entries across 25 versions & 7 rubygems

Version Path
logstash-input-salesforce-3.0.0 vendor/jruby/1.9/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
brakeman-3.4.1 bundle/ruby/2.3.0/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
brakeman-3.4.0 bundle/ruby/2.3.0/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
logstash-filter-delta-1.1.0 vendor/bundle/jruby/2.2.0/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
logstash-filter-delta-1.0.1 vendor/bundle/jruby/2.2.0/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
logstash-filter-base64-1.0.4 vendor/bundle/jruby/2.2.0/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
logstash-filter-base64-1.0.3 vendor/bundle/jruby/2.2.0/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
logstash-filter-delta-1.0.0 vendor/bundle/jruby/2.2.0/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
logstash-filter-base64-1.0.2 vendor/bundle/jruby/2.3.0/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
logstash-filter-base64-1.0.1 vendor/bundle/jruby/2.3.0/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
logstash-filter-base64-1.0.0 vendor/bundle/jruby/2.3.0/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
brakeman-3.3.5 bundle/ruby/2.3.0/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
brakeman-3.3.4 bundle/ruby/2.3.0/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
brakeman-3.3.3 bundle/ruby/2.3.0/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
brakeman-3.3.2 bundle/ruby/2.3.0/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
brakeman-3.3.1 bundle/ruby/2.3.0/gems/tilt-2.0.5/test/tilt_asciidoctor_test.rb
tilt-2.0.5 test/tilt_asciidoctor_test.rb