Sha256: 4c603311f41532c83861f6d591d4e4258d2278fc31de3e8516e53636e5c58d1b

Contents?: true

Size: 1.53 KB

Versions: 8

Compression:

Stored size: 1.53 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>"
    DOCBOOK_OUTPUT = "<section 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 templates on #render" do
      template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'docbook'}) { |t| "== Hello World!" } 
      assert_equal DOCBOOK_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

8 entries across 8 versions & 4 rubygems

Version Path
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/tilt-2.0.1/test/tilt_asciidoctor_test.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/tilt-2.0.1/test/tilt_asciidoctor_test.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/tilt-2.0.1/test/tilt_asciidoctor_test.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/tilt-2.0.1/test/tilt_asciidoctor_test.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/tilt-2.0.1/test/tilt_asciidoctor_test.rb
tilt-2.0.1 test/tilt_asciidoctor_test.rb
tilt-2.0.0 test/tilt_asciidoctor_test.rb
tilt-2.0.0.beta1 test/tilt_asciidoctor_test.rb