Skip to content

Commit a557af8

Browse files
committed
Test {{ site.archives }}
1 parent 1d0ba6d commit a557af8

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

test/helper.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ def fixture_site(config = {})
3030
end
3131

3232
def archive_exists?(site, path)
33-
site.pages.any? { |archive| archive.path == path }
33+
site.config["archives"].any? { |archive| archive.path == path }
3434
end
3535

3636
def read_file(path)
37-
File.read(File.join(DEST_DIR, path)).strip
37+
read_path = File.join(DEST_DIR, path)
38+
if File.exist? read_path
39+
File.read(read_path).strip
40+
else
41+
return false
42+
end
3843
end
3944
end

test/source/length.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
layout: null
3+
---
4+
{{ site.archives.size }}

test/test_jekyll_archives.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,26 @@ class TestJekyllArchives < Minitest::Test
6060
}
6161
}
6262
})
63-
@site.read
64-
@archives = Jekyll::Archives.new(@site.config)
63+
@site.process
6564
end
6665

6766
should "use the right permalink" do
68-
@site.process
6967
assert archive_exists? @site, "/2014/"
7068
assert archive_exists? @site, "/2013/"
7169
assert archive_exists? @site, "/tag-test.html"
7270
assert archive_exists? @site, "/tag-new.html"
7371
assert archive_exists? @site, "/category-plugins.html"
7472
end
7573
end
74+
75+
context "the archives" do
76+
setup do
77+
@site = fixture_site
78+
@site.process
79+
end
80+
81+
should "populate the {{ site.archives }} tag in Liquid" do
82+
assert_equal 6, read_file("/length.html").to_i
83+
end
84+
end
7685
end

0 commit comments

Comments
 (0)