forked from rails/rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate_path_test.rb
78 lines (66 loc) · 2.24 KB
/
template_path_test.rb
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
66
67
68
69
70
71
72
73
74
75
76
77
78
# frozen_string_literal: true
require "abstract_unit"
class TemplatePathTest < ActiveSupport::TestCase
def test_build_returns_path_object
path = ActionView::TemplatePath.build("bar", "foo", true)
assert_equal "foo/_bar", path.virtual
assert_equal "foo", path.prefix
assert_equal "bar", path.name
assert path.partial?
end
def test_virtual
assert_equal "foo/bar", ActionView::TemplatePath.virtual("bar", "foo", false)
assert_equal "foo/_bar", ActionView::TemplatePath.virtual("bar", "foo", true)
assert_equal "bar", ActionView::TemplatePath.virtual("bar", "", false)
assert_equal "_bar", ActionView::TemplatePath.virtual("bar", "", true)
assert_equal "foo/bar/baz", ActionView::TemplatePath.virtual("baz", "foo/bar", false)
end
def test_parse_root_template
path = ActionView::TemplatePath.parse("foo")
assert_equal "", path.prefix
assert_equal "foo", path.name
assert_not path.partial?
end
def test_parse_root_template_with_slash
path = ActionView::TemplatePath.parse("/foo")
assert_equal "", path.prefix
assert_equal "foo", path.name
assert_not path.partial?
end
def test_parse_root_partial
path = ActionView::TemplatePath.parse("_foo")
assert_equal "", path.prefix
assert_equal "foo", path.name
assert path.partial?
end
def test_parse_root_partial_with_slash
path = ActionView::TemplatePath.parse("/_foo")
assert_equal "", path.prefix
assert_equal "foo", path.name
assert path.partial?
end
def test_parse_template
path = ActionView::TemplatePath.parse("foo/bar")
assert_equal "foo", path.prefix
assert_equal "bar", path.name
assert_not path.partial?
end
def test_parse_partial
path = ActionView::TemplatePath.parse("foo/_bar")
assert_equal "foo", path.prefix
assert_equal "bar", path.name
assert path.partial?
end
def test_parse_deep_partial
path = ActionView::TemplatePath.parse("foo/bar/_baz")
assert_equal "foo/bar", path.prefix
assert_equal "baz", path.name
assert path.partial?
end
def test_parse_deep_partial_with_slash
path = ActionView::TemplatePath.parse("/foo/bar/_baz")
assert_equal "foo/bar", path.prefix
assert_equal "baz", path.name
assert path.partial?
end
end