Sha256: 03596409e6cef51aceb6c568e7d7f63de65179a7dc71d52fb02a513c811bc0bd

Contents?: true

Size: 779 Bytes

Versions: 17

Compression:

Stored size: 779 Bytes

Contents

# coding: UTF-8
$:.unshift(File.expand_path('../../lib', __FILE__))
Encoding.default_internal = 'UTF-8'

require 'test/unit'

require 'redcarpet'
require 'redcarpet/render_strip'
require 'redcarpet/render_man'

class Redcarpet::TestCase < Test::Unit::TestCase
  def assert_renders(html, markdown)
    assert_equal html, render(markdown)
  end

  def render(markdown, options = {})
    options = options.fetch(:with, {})

    if options.kind_of?(Array)
      options = Hash[options.map {|o| [o, true]}]
    end

    render = begin
      renderer.new(options)
    rescue ArgumentError
      renderer.new
    end

    parser = Redcarpet::Markdown.new(render, options)

    parser.render(markdown)
  end

  private

  def renderer
    @renderer ||= Redcarpet::Render::HTML
  end
end

Version data entries

17 entries across 17 versions & 5 rubygems

Version Path
mumukit-content-type-1.11.1 vendor/bundle/ruby/2.6.0/gems/redcarpet-3.3.4/test/test_helper.rb
tdiary-5.0.2 vendor/bundle/gems/redcarpet-3.3.4/test/test_helper.rb
tdiary-5.0.1 vendor/bundle/gems/redcarpet-3.3.4/test/test_helper.rb
redcarpet_yt-0.1.0 test/test_helper.rb
redcarpet_yt-0.0.10 test/test_helper.rb
redcarpet_yt-0.0.9 test/test_helper.rb
redcarpet_yt-0.0.8 test/test_helper.rb
redcarpet_yt-0.0.7 test/test_helper.rb
redcarpet_yt-0.0.6 test/test_helper.rb
redcarpet_yt-0.0.5 test/test_helper.rb
redcarpet_yt-0.0.4 test/test_helper.rb
redcarpet_yt-0.0.3 test/test_helper.rb
redcarpet_yt-0.0.2 test/test_helper.rb
redcarpet_yt-0.0.1 test/test_helper.rb
redcarpet-3.3.4 test/test_helper.rb
redcarpet-3.3.3 test/test_helper.rb
tight-redcarpet-3.3.2t test/test_helper.rb