File: tilt_rstpandoctemplate_test.rb

package info (click to toggle)
ruby-tilt 2.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 648 kB
  • sloc: ruby: 4,998; makefile: 7
file content (28 lines) | stat: -rw-r--r-- 1,033 bytes parent folder | download | duplicates (2)
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
require_relative 'test_helper'

checked_describe 'tilt/rst-pandoc' do
  it "is registered for '.rst' files" do
    assert_equal Tilt::RstPandocTemplate, Tilt['test.rst']
  end

  it "compiles and evaluates the template on #render" do
    template = Tilt::RstPandocTemplate.new { |t| "Hello World!\n============" }
    assert_equal "<h1 id=\"hello-world\">Hello World!</h1>", template.render
  end

  it "can be rendered more than once" do
    template = Tilt::RstPandocTemplate.new { |t| "Hello World!\n============" }
    3.times do
      assert_equal "<h1 id=\"hello-world\">Hello World!</h1>", template.render
    end
  end

  it "supports :escape_html option" do
    template = Tilt::RstPandocTemplate.new(:escape_html => true) { |t| "HELLO <blink>WORLD</blink>" }
    assert_equal "<p>HELLO &lt;blink&gt;WORLD&lt;/blink&gt;</p>", template.render
  end

  it "sets allows_script metadata set to false" do
    assert_equal false, Tilt::RstPandocTemplate.new { |t| "Hello World!\n============" }.metadata[:allows_script]
  end
end