File: markdown_test.rb

package info (click to toggle)
ruby-markerb 1.1.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 196 kB
  • sloc: ruby: 202; makefile: 6
file content (30 lines) | stat: -rw-r--r-- 1,031 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require "test_helper"

class MarkdownTest < ActiveSupport::TestCase
  setup do
    @original_redcarpet = Redcarpet
    @original_kramdown = Kramdown
  end

  teardown do
    Object.const_set(:Redcarpet, @original_redcarpet) unless defined?(Redcarpet)
    Object.const_set(:Kramdown, @original_kramdown) unless defined?(Kramdown)
  end

  test 'with Redcarpet markdown processor' do
    Object.send(:remove_const, :Kramdown)
    assert_equal "<p>Dual templates <strong>rocks</strong>!</p>", Markerb::Markdown.to_html("Dual templates **rocks**!").strip
  end

  test 'with Kramdown markdown processor' do
    Object.send(:remove_const, :Redcarpet)
    assert_equal "<p>Dual templates <strong>rocks</strong>!</p>", Markerb::Markdown.to_html("Dual templates **rocks**!").strip
  end

  test 'when there is no known markdown processor available' do
    Object.send(:remove_const, :Redcarpet)
    Object.send(:remove_const, :Kramdown)

    assert_raise(StandardError) { Markerb::Markdown.to_html("Dual templates **rocks**!") }
  end
end