forked from jekyll/jekyll
-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_liquid_renderer.rb
58 lines (50 loc) · 1.72 KB
/
test_liquid_renderer.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
# frozen_string_literal: true
require "helper"
class TestLiquidRenderer < JekyllUnitTest
context "profiler" do
setup do
@site = Site.new(site_configuration)
@renderer = @site.liquid_renderer
end
should "return a table with profiling results" do
@site.process
output = @renderer.stats_table
# rubocop:disable Layout/LineLength
expected = [
%r!^\| Filename\s+|\s+Count\s+|\s+Bytes\s+|\s+Time$!,
%r!^\+(?:-+\+){4}$!,
%r!^\|_posts/2010-01-09-date-override\.markdown\s+|\s+\d+\s+|\s+\d+\.\d{2}K\s+|\s+\d+\.\d{3}$!,
]
# rubocop:enable Layout/LineLength
expected.each do |regexp|
assert_match regexp, output
end
end
should "normalize paths of rendered items" do
site = fixture_site("theme" => "test-theme")
MockRenderer = Class.new(Jekyll::LiquidRenderer) { public :normalize_path }
renderer = MockRenderer.new(site)
assert_equal "feed.xml", renderer.normalize_path("/feed.xml")
assert_equal(
"_layouts/post.html",
renderer.normalize_path(site.in_source_dir("_layouts", "post.html"))
)
assert_equal(
"test-theme/_layouts/page.html",
renderer.normalize_path(site.in_theme_dir("_layouts", "page.html"))
)
assert_equal(
"my_plugin-0.1.0/lib/my_plugin/layout.html",
renderer.normalize_path(
"/users/jo/blog/vendor/bundle/ruby/2.4.0/gems/my_plugin-0.1.0/lib/my_plugin/layout.html"
)
)
assert_equal(
"test_plugin-0.1.0/lib/test_plugin/layout.html",
renderer.normalize_path(
"C:/Ruby2.4/lib/ruby/gems/2.4.0/gems/test_plugin-0.1.0/lib/test_plugin/layout.html"
)
)
end
end
end