File: tilt_metadata_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 (35 lines) | stat: -rw-r--r-- 816 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
29
30
31
32
33
34
35
require_relative 'test_helper'

describe 'tilt metadata' do
  _MyTemplate = Class.new(Tilt::Template) do
    metadata[:global] = 1
    self.default_mime_type = 'text/html'

    def allows_script?
      true
    end
  end

  it "global metadata" do
    assert _MyTemplate.metadata
    assert_equal 1, _MyTemplate.metadata[:global]
  end

  it "instance metadata" do
    tmpl = _MyTemplate.new { '' }
    assert_equal 1, tmpl.metadata[:global]
  end

  it "gracefully handles default_mime_type" do
    assert_equal 'text/html', _MyTemplate.metadata[:mime_type]
  end

  it "still allows .default_mime_type" do
    assert_equal 'text/html', _MyTemplate.default_mime_type
  end

  it "gracefully handles allows_script?" do
    tmpl = _MyTemplate.new { '' }
    assert_equal true, tmpl.metadata[:allows_script]
  end
end