Sha256: a634062463e1eaaeb2ff5f94dbcbb6438010b5a0014408ea45ac333d65380582

Contents?: true

Size: 1.95 KB

Versions: 76

Compression:

Stored size: 1.95 KB

Contents

require 'test_helper'
require 'tilt'

begin
  require 'tilt/redcarpet'

  class RedcarpetTemplateTest < Minitest::Test
    test "registered above BlueCloth" do
      %w[md mkd markdown].each do |ext|
        lazy = Tilt.lazy_map[ext]
        blue_idx = lazy.index { |klass, file| klass == 'Tilt::BlueClothTemplate' }
        redc_idx = lazy.index { |klass, file| klass == 'Tilt::RedcarpetTemplate' }
        assert redc_idx < blue_idx,
          "#{redc_idx} should be lower than #{blue_idx}"
      end
    end

    test "registered above RDiscount" do
      %w[md mkd markdown].each do |ext|
        lazy = Tilt.lazy_map[ext]
        rdis_idx = lazy.index { |klass, file| klass == 'Tilt::RDiscountTemplate' }
        redc_idx = lazy.index { |klass, file| klass == 'Tilt::RedcarpetTemplate' }
        assert redc_idx < rdis_idx,
          "#{redc_idx} should be lower than #{rdis_idx}"
      end
    end

    test "preparing and evaluating templates on #render" do
      template = Tilt::RedcarpetTemplate.new { |t| "# Hello World!" }
      assert_equal "<h1>Hello World!</h1>\n", template.render
    end

    test "can be rendered more than once" do
      template = Tilt::RedcarpetTemplate.new { |t| "# Hello World!" }
      3.times { assert_equal "<h1>Hello World!</h1>\n", template.render }
    end

    test "smartypants when :smart is set" do
      template = Tilt::RedcarpetTemplate.new(:smartypants => true) { |t|
        "OKAY -- 'Smarty Pants'" }
      assert_match %r!<p>OKAY &ndash; (&#39;|&lsquo;)Smarty Pants(&#39;|&rsquo;)<\/p>!,
        template.render
    end

    test "smartypants with a rendererer instance" do
      template = Tilt::RedcarpetTemplate.new(:renderer => Redcarpet::Render::HTML.new(:hard_wrap => true), :smartypants => true) { |t|
        "OKAY -- 'Smarty Pants'" }
      assert_match %r!<p>OKAY &ndash; (&#39;|&lsquo;)Smarty Pants(&#39;|&rsquo;)<\/p>!,
        template.render
    end
  end
rescue LoadError
  warn "Tilt::RedcarpetTemplate (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_redcarpettemplate_test.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_redcarpettemplate_test.rb