test/test_post.rb in jekyll-1.5.1 vs test/test_post.rb in jekyll-2.0.0.alpha.1
- old
+ new
@@ -23,10 +23,38 @@
assert !Post.valid?("lol2008-09-09-foo-bar.textile")
assert !Post.valid?("blah")
end
+ should "make properties accessible through #[]" do
+ post = setup_post('2013-12-20-properties.text')
+
+ attrs = {
+ categories: %w(foo bar baz),
+ content: "All the properties.\n\nPlus an excerpt.\n",
+ date: Time.new(2013, 12, 20),
+ dir: "/foo/bar/baz/2013/12/20",
+ excerpt: "All the properties.\n\n",
+ foo: 'bar',
+ id: "/foo/bar/baz/2013/12/20/properties",
+ layout: 'default',
+ name: nil,
+ # path: "properties.html",
+ permalink: nil,
+ published: nil,
+ tags: %w(ay bee cee),
+ title: 'Properties Post',
+ url: "/foo/bar/baz/2013/12/20/properties.html"
+ }
+
+ attrs.each do |attr, val|
+ attr_str = attr.to_s
+ result = post[attr_str]
+ assert_equal val, result, "For <post[\"#{attr_str}\"]>:"
+ end
+ end
+
context "processing posts" do
setup do
@post = Post.allocate
@post.site = @site
@@ -73,21 +101,10 @@
assert_equal "my_category/permalinked-post", @post.permalink
assert_equal "/my_category", @post.dir
assert_equal "/my_category/permalinked-post", @post.url
end
- should "not be writable outside of destination" do
- unexpected = File.expand_path("../../../baddie.html", dest_dir)
- File.delete unexpected if File.exist?(unexpected)
- post = setup_post("2014-01-06-permalink-traversal.md")
- do_render(post)
- post.write(dest_dir)
-
- assert !File.exist?(unexpected)
- assert File.exist?(File.expand_path("baddie.html", dest_dir))
- end
-
context "with CRLF linebreaks" do
setup do
@real_file = "2009-05-24-yaml-linebreak.markdown"
@source = source_dir('win/_posts')
end
@@ -293,11 +310,11 @@
should "correctly resolve link references" do
assert @post.excerpt.include?("www.jekyllrb.com"), "contains referenced link URL"
end
should "return rendered HTML" do
- assert_equal "<p>First paragraph with <a href=\"http://www.jekyllrb.com/\">link ref</a>.</p>",
+ assert_equal "<p>First paragraph with <a href=\"http://www.jekyllrb.com/\">link ref</a>.</p>\n\n",
@post.excerpt
end
context "with excerpt_separator setting" do
setup do
@@ -368,16 +385,16 @@
end
context "initializing posts" do
should "publish when published yaml is no specified" do
post = setup_post("2008-02-02-published.textile")
- assert_equal true, post.published
+ assert_equal true, post.published?
end
should "not published when published yaml is false" do
post = setup_post("2008-02-02-not-published.textile")
- assert_equal false, post.published
+ assert_equal false, post.published?
end
should "recognize date in yaml" do
post = setup_post("2010-01-09-date-override.textile")
do_render(post)
@@ -513,10 +530,10 @@
should "include templates" do
post = setup_post("2008-12-13-include.markdown")
post.site.source = File.join(File.dirname(__FILE__), 'source')
do_render(post)
- assert_equal "<<< <hr />\n<p>Tom Preston-Werner github.com/mojombo</p>\n\n<p>This <em>is</em> cool</p> >>>", post.output
+ assert_equal "<<< <hr />\n<p>Tom Preston-Werner\ngithub.com/mojombo</p>\n\n<p>This <em>is</em> cool</p>\n >>>", post.output
end
should "render date specified in front matter properly" do
post = setup_post("2010-01-09-date-override.textile")
do_render(post)