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
53
54
55
56
57
58
59
60
61
62
63
64
65
|
require 'minitest/autorun'
require 'luigi-template'
class TemplateTest < MiniTest::Test
def test_new
t = Luigi::Template.new('foo%{bar}')
assert_instance_of Luigi::Template, t
end
def test_run
t = Luigi::Template.new('foo%{bar}')
r = t.run(bar: 'foo')
assert_equal 'foofoo', r
end
def test_run_with_string_key
t = Luigi::Template.new('foo%{bar}')
r = t.run('bar' => 'foo')
assert_equal 'foofoo', r
end
def test_self_run
r = Luigi::Template.run('foo%{bar}', bar: 'foo')
assert_equal 'foofoo', r
end
def test_multiple_keys
r = Luigi::Template.run('foo%{bar}%{baz}', {
bar: 'foo',
baz: 'bar',
})
assert_equal 'foofoobar', r
end
def test_whitespace
r = Luigi::Template.run('%{ bar}%{ bar }%{ bar}', {
bar: 'foo',
})
assert_equal 'foofoofoo', r
end
def test_newlines
r = Luigi::Template.run('%{
bar}%{
bar
}%{
bar}', {
bar: 'foo',
})
assert_equal 'foofoofoo', r
end
def test_to_s
want = '%{val | h}'
t = Luigi::Template.new(want)
assert_equal want, t.to_s
end
end
|