Sha256: a46453ec6e144156046a5cd148c5517d3add16e6f5ac04947679528657e83876

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

require File.expand_path('../../unit_test_helper', __FILE__)

class RedcarpetTest < Test::Unit::TestCase

  def test_transform_strong
    result = auto_html("This is **my** text.") { redcarpet }
    assert_equal '<p>This is <strong>my</strong> text.</p>'+"\n", result
  end

  def test_transform_title
    result = auto_html("## This is a title ##") { redcarpet }
    assert_equal '<h2>This is a title</h2>'+"\n", result
  end

  def test_transform_link
    result = auto_html('[This is a link](http://example.org/)') { redcarpet }
    assert_equal '<p><a href="http://example.org/">This is a link</a></p>'+"\n", result
  end

  class LinksInNewWindow < ::Redcarpet::Render::HTML
    def link(link, title, content)
       "<a href=\"#{link}\" target=\"_blank\">#{content}</a>"
    end    
  end
  
  def test_transform_link_target_blank
    result = auto_html('[This is a link](http://example.org/)') { redcarpet(:renderer => LinksInNewWindow) }
    assert_equal '<p><a href="http://example.org/" target="_blank">This is a link</a></p>'+"\n", result
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
auto_html-1.5.1.1 test/unit/filters/redcarpet_test.rb
auto_html-1.5.3 test/unit/filters/redcarpet_test.rb
auto_html-1.5.2 test/unit/filters/redcarpet_test.rb
auto_html-1.5.1 test/unit/filters/redcarpet_test.rb
auto_html-1.5.0 test/unit/filters/redcarpet_test.rb