Sha256: 3ba57207edb139de2620e296c172c3cd2ec115d84158322b86bc766bdfaeaa87

Contents?: true

Size: 1.95 KB

Versions: 25

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 /<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 /<p>OKAY &ndash; (&#39;|&lsquo;)Smarty Pants(&#39;|&rsquo;)<\/p>/,
        template.render
    end
  end
rescue LoadError => boom
  warn "Tilt::RedcarpetTemplate (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_redcarpettemplate_test.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
brakeman-3.4.1 bundle/ruby/2.3.0/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
brakeman-3.4.0 bundle/ruby/2.3.0/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
logstash-filter-delta-1.1.0 vendor/bundle/jruby/2.2.0/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
logstash-filter-delta-1.0.1 vendor/bundle/jruby/2.2.0/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
logstash-filter-base64-1.0.4 vendor/bundle/jruby/2.2.0/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
logstash-filter-base64-1.0.3 vendor/bundle/jruby/2.2.0/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
logstash-filter-delta-1.0.0 vendor/bundle/jruby/2.2.0/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
logstash-filter-base64-1.0.2 vendor/bundle/jruby/2.3.0/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
logstash-filter-base64-1.0.1 vendor/bundle/jruby/2.3.0/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
logstash-filter-base64-1.0.0 vendor/bundle/jruby/2.3.0/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
brakeman-3.3.5 bundle/ruby/2.3.0/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
brakeman-3.3.4 bundle/ruby/2.3.0/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
brakeman-3.3.3 bundle/ruby/2.3.0/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
brakeman-3.3.2 bundle/ruby/2.3.0/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
brakeman-3.3.1 bundle/ruby/2.3.0/gems/tilt-2.0.5/test/tilt_redcarpettemplate_test.rb
tilt-2.0.5 test/tilt_redcarpettemplate_test.rb