File: template_test.rb

package info (click to toggle)
ruby-mustache 1.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 480 kB
  • sloc: ruby: 2,267; makefile: 2
file content (52 lines) | stat: -rw-r--r-- 1,207 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require_relative 'helper'

class TemplateTest < Minitest::Test
  def test_compile
    assert_equal %("foo"), Mustache::Template.new("foo").compile
  end

  def test_compile_with_source
    assert_equal %("bar"), Mustache::Template.new("foo").compile("bar")
  end

  def test_token
    assert_equal [:multi, [:static, "foo"]], Mustache::Template.new("foo").tokens
  end

  def test_token_with_source
    assert_equal [:multi, [:static, "bar"]], Mustache::Template.new("foo").tokens("bar")
  end
end

class TemplateTest2 < Minitest::Test
  def setup
    @@template_text ||= File.read(File.dirname(__FILE__) + "/fixtures/simply_complicated.mustache")
    @template = Mustache::Template.new(@@template_text)
  end

  def test_tags
    assert_equal [
      "yourname",
      "HOME",
      "friend.name",
      "friend.morr.word",
      "friend.morr.up",
      "friend.morr.awesomesauce",
      "friend.morr.hiss",
      "friend.notinmorr",
      "friend.person",
      "love",
      "triplestash"
      ], @template.tags
  end

  def test_partials
    assert_equal ["partial1", "partial2"], @template.partials
  end

  def test_sections
    assert_equal ["friend", "friend.morr"], @template.sections
  end
end