test/test_post.rb in jekyll-2.0.0.alpha.2 vs test/test_post.rb in jekyll-2.0.0.alpha.3

- old
+ new

@@ -84,17 +84,24 @@ assert_raise Jekyll::FatalException do @post.process("2009-27-03-foo-bar.textile") end end - should "CGI escape urls" do + should "escape urls" do @post.categories = [] @post.process("2009-03-12-hash-#1.markdown") assert_equal "/2009/03/12/hash-%231.html", @post.url assert_equal "/2009/03/12/hash-#1", @post.id end + should "escape urls with non-alphabetic characters" do + @post.categories = [] + @post.process("2014-03-22-escape-+ %20[].markdown") + assert_equal "/2014/03/22/escape-+%20%2520%5B%5D.html", @post.url + assert_equal "/2014/03/22/escape-+ %20[]", @post.id + end + should "respect permalink in yaml front matter" do file = "2008-12-03-permalinked-post.textile" @post.process(file) @post.read_yaml(@source, file) @@ -125,10 +132,22 @@ assert_equal({"title" => "Test title", "layout" => "post", "tag" => "Ruby"}, @post.data) assert_equal "This is the content", @post.content end end + context "with three dots ending YAML header" do + setup do + @real_file = "2014-03-03-yaml-with-dots.md" + end + should "should read the YAML header" do + @post.read_yaml(@source, @real_file) + + assert_equal({"title" => "Test Post Where YAML Ends in Dots"}, + @post.data) + end + end + context "with embedded triple dash" do setup do @real_file = "2010-01-08-triple-dash.markdown" end should "consume the embedded dashes" do @@ -394,20 +413,10 @@ assert_equal(nil, @site.posts.last.next) end 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? - end - - should "not published when published yaml is false" do - post = setup_post("2008-02-02-not-published.textile") - assert_equal false, post.published? - end - should "recognize date in yaml" do post = setup_post("2010-01-09-date-override.textile") do_render(post) assert_equal Time, post.date.class assert_equal Time, post.to_liquid["date"].class @@ -516,20 +525,40 @@ post = setup_post("2008-10-18-foo-bar.textile") do_render(post) post.write(dest_dir) assert File.directory?(dest_dir) - assert File.exists?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html')) + assert File.exist?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html')) end + should "write properly when url has hash" do + post = setup_post("2009-03-12-hash-#1.markdown") + do_render(post) + post.write(dest_dir) + + assert File.directory?(dest_dir) + assert File.exist?(File.join(dest_dir, '2009', '03', '12', + 'hash-#1.html')) + end + + should "write properly when url has space" do + post = setup_post("2014-03-22-escape-+ %20[].markdown") + do_render(post) + post.write(dest_dir) + + assert File.directory?(dest_dir) + assert File.exist?(File.join(dest_dir, '2014', '03', '22', + 'escape-+ %20[].html')) + end + should "write properly without html extension" do post = setup_post("2008-10-18-foo-bar.textile") post.site.permalink_style = ":title" do_render(post) post.write(dest_dir) assert File.directory?(dest_dir) - assert File.exists?(File.join(dest_dir, 'foo-bar', 'index.html')) + assert File.exist?(File.join(dest_dir, 'foo-bar', 'index.html')) end should "insert data" do post = setup_post("2008-11-21-complex.textile") do_render(post)