Sha256: 636b3a5d54d16901e7c8aeaf97bc08952aa35d49a0e35771da775ab91558bf7d

Contents?: true

Size: 1.69 KB

Versions: 6

Compression:

Stored size: 1.69 KB

Contents

# encoding: utf-8

class Nanoc3::Filters::RedcarpetTest < MiniTest::Unit::TestCase

  include Nanoc3::TestHelpers

  def test_find
    if_have 'redcarpet' do
      refute Nanoc3::Filter.named(:redcarpet).nil?
    end
  end

  def test_filter
    if_have 'redcarpet' do
      # Create filter
      filter = ::Nanoc3::Filters::Redcarpet.new

      # Run filter
      result = filter.run("> Quote")
      assert_match(/<blockquote>\s*<p>Quote<\/p>\s*<\/blockquote>/, result)
    end
  end

  def test_with_extensions
    if_have 'redcarpet' do
      # Create filter
      filter = ::Nanoc3::Filters::Redcarpet.new

      # Run filter
      input           = "The quotation 'marks' sure make this look sarcastic!"
      output_expected = /The quotation &lsquo;marks&rsquo; sure make this look sarcastic!/
      output_actual   = filter.run(input, :options => [ :smart ])
      assert_match(output_expected, output_actual)
    end
  end

  def test_html_by_default
    if_have 'redcarpet' do
      # Create filter
      filter = ::Nanoc3::Filters::Redcarpet.new

      # Run filter
      input           = "![Alt](/path/to/img 'Title')"
      output_expected = %r{<img src="/path/to/img" alt="Alt" title="Title">}
      output_actual   = filter.run(input)
      assert_match(output_expected, output_actual)
    end
  end

  def test_xhtml_if_requested
    if_have 'redcarpet' do
      # Create filter
      filter = ::Nanoc3::Filters::Redcarpet.new

      # Run filter
      input           = "![Alt](/path/to/img 'Title')"
      output_expected = %r{<img src="/path/to/img" alt="Alt" title="Title"/>}
      output_actual   = filter.run(input, :options => [ :xhtml ])
      assert_match(output_expected, output_actual)
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nanoc3-3.2.4 test/filters/test_redcarpet.rb
nanoc3-3.2.3 test/filters/test_redcarpet.rb
nanoc3-3.2.2 test/filters/test_redcarpet.rb
nanoc3-3.2.1 test/filters/test_redcarpet.rb
nanoc3-3.2.0 test/filters/test_redcarpet.rb
nanoc3-3.2.0b3 test/filters/test_redcarpet.rb