From 04e0b318c8d9395a4b780c0ff2671b4e51a22afe Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Fri, 19 Jul 2013 15:43:04 +0200 Subject: [PATCH 01/16] Remove duplicate comment --- lib/jekyll/excerpt.rb | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb index 16584963..ce0c3351 100644 --- a/lib/jekyll/excerpt.rb +++ b/lib/jekyll/excerpt.rb @@ -1,41 +1,5 @@ module Jekyll class Excerpt - - # Internal: Extract excerpt from the content - # - # By default excerpt is your first paragraph of a post: everything before - # the first two new lines: - # - # --- - # title: Example - # --- - # - # First paragraph with [link][1]. - # - # Second paragraph. - # - # [1]: http://example.com/ - # - # This is fairly good option for Markdown and Textile files. But might cause - # problems for HTML posts (which is quite unusual for Jekyll). If default - # excerpt delimiter is not good for you, you might want to set your own via - # configuration option `excerpt_separator`. For example, following is a good - # alternative for HTML posts: - # - # # file: _config.yml - # excerpt_separator: "" - # - # Notice that all markdown-style link references will be appended to the - # excerpt. So the example post above will have this excerpt source: - # - # First paragraph with [link][1]. - # - # [1]: http://example.com/ - # - # Excerpts are rendered same time as content is rendered. - # - # Returns excerpt String - include Convertible attr_accessor :post From 0e0e25b9ba75105295fb925751af83d6793fd83f Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Fri, 19 Jul 2013 15:43:26 +0200 Subject: [PATCH 02/16] start with Excerpt#output, otherwise call #to_s --- lib/jekyll/post.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 1b70e31e..387c2752 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -109,7 +109,7 @@ module Jekyll if self.data.has_key? 'excerpt' self.data['excerpt'] else - self.extracted_excerpt.to_s + self.extracted_excerpt.output || self.extracted_excerpt.to_s end end From f99c726085569fffcb65de0a28da93df1473369b Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Fri, 19 Jul 2013 15:44:01 +0200 Subject: [PATCH 03/16] Override Excerpt#render_all_layouts to just assign content to output --- lib/jekyll/excerpt.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb index ce0c3351..fb63f5cb 100644 --- a/lib/jekyll/excerpt.rb +++ b/lib/jekyll/excerpt.rb @@ -31,6 +31,10 @@ module Jekyll (output && output.include?(something)) || content.include?(something) end + def render_all_layouts(layouts, payload, info) + output = content + end + # The UID for this post (useful in feeds). # e.g. /2008/11/05/my-awesome-post # From c6a37a424b25b0ff73fa80cd80ebf5868a457ec1 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Fri, 19 Jul 2013 15:46:20 +0200 Subject: [PATCH 04/16] Debug statements - take them out later --- lib/jekyll/convertible.rb | 1 + lib/jekyll/excerpt.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index b247ac4e..1e5cfdeb 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -78,6 +78,7 @@ module Jekyll # # Returns the converted content def render_liquid(content, payload, info) + Jekyll.logger.debug "Rendering Liquid for #{self.path}", "" Liquid::Template.parse(content).render!(payload, info) rescue Exception => e Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{payload[:file]}" diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb index fb63f5cb..682bf135 100644 --- a/lib/jekyll/excerpt.rb +++ b/lib/jekyll/excerpt.rb @@ -33,6 +33,7 @@ module Jekyll def render_all_layouts(layouts, payload, info) output = content + Jekyll.logger.debug "Output of", "#{self.path} => '#{self.output}'" end # The UID for this post (useful in feeds). @@ -51,6 +52,7 @@ module Jekyll end def to_s + Jekyll.logger.debug "Excerpt#to_s:", "#{output} || #{content}" output || content end From e3594728706db09aae99401b317fdb64a9751b2e Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Mon, 22 Jul 2013 11:30:19 +0200 Subject: [PATCH 05/16] May as well add Stevenson#debug --- lib/jekyll/stevenson.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/jekyll/stevenson.rb b/lib/jekyll/stevenson.rb index 5be5f04c..12e65651 100644 --- a/lib/jekyll/stevenson.rb +++ b/lib/jekyll/stevenson.rb @@ -15,6 +15,16 @@ module Jekyll def initialize(level = INFO) @log_level = level end + + # Public: Print a jekyll debug message to stdout + # + # topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. + # message - the message detail + # + # Returns nothing + def debug(topic, message = nil) + $stdout.puts(message(topic, message)) if log_level <= DEBUG + end # Public: Print a jekyll message to stdout # From 26dc14881c444198f2c57d740d8ab126525a5b67 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Mon, 22 Jul 2013 11:31:15 +0200 Subject: [PATCH 06/16] Moving data around to make sure excerpts have no layouts but that they are still converted with liquid and the proper converter --- lib/jekyll/excerpt.rb | 43 +++++++++++++++++++++++++------------------ lib/jekyll/post.rb | 24 ++++++++++++++---------- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb index 682bf135..768acd97 100644 --- a/lib/jekyll/excerpt.rb +++ b/lib/jekyll/excerpt.rb @@ -13,27 +13,41 @@ module Jekyll # # Returns the new Post. def initialize(post) - @post = post - @content = extract_excerpt(post.content) + self.post = post + self.content = extract_excerpt(post.content) end - %w[site name data ext].each do |meth| + %w[site name ext].each do |meth| define_method(meth) do post.send(meth) end end + def to_liquid + post.to_liquid(Post::EXCERPT_ATTRIBUTES_FOR_LIQUID) + end + + # Fetch YAML front-matter data from related post, without layout key + # + # Returns Hash of post data + def data + @data ||= post.data.dup + @data.delete("layout") if @data.has_key?("layout") + @data + end + + # 'Path' of the excerpt. + # + # Returns the path for the post this excerpt belongs to with #excerpt appended def path File.join(post.path, "#excerpt") end + # Check if excerpt includes a string + # + # Returns true if the string passed in def include?(something) - (output && output.include?(something)) || content.include?(something) - end - - def render_all_layouts(layouts, payload, info) - output = content - Jekyll.logger.debug "Output of", "#{self.path} => '#{self.output}'" + (self.output && self.output.include?(something)) || self.content.include?(something) end # The UID for this post (useful in feeds). @@ -44,16 +58,9 @@ module Jekyll File.join(post.dir, post.slug, "#excerpt") end - # Convert this post into a Hash for use in Liquid templates. - # - # Returns the representative Hash. - def to_liquid - post.to_liquid - end - def to_s - Jekyll.logger.debug "Excerpt#to_s:", "#{output} || #{content}" - output || content + Jekyll.logger.debug "Excerpt#to_s:", "#{self.output} || #{content}" + self.output || self.content end # Returns the shorthand String identifier of this Post. diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 387c2752..693517a6 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -10,8 +10,7 @@ module Jekyll # Valid post name regex. MATCHER = /^(.+\/)*(\d+-\d+-\d+)-(.*)(\.[^.]+)$/ - # Attributes for Liquid templates - ATTRIBUTES_FOR_LIQUID = %w[ + EXCERPT_ATTRIBUTES_FOR_LIQUID = %w[ title url date @@ -20,11 +19,15 @@ module Jekyll next previous tags - content - excerpt path ] + # Attributes for Liquid templates + ATTRIBUTES_FOR_LIQUID = EXCERPT_ATTRIBUTES_FOR_LIQUID.concat(%w[ + content + excerpt + ]) + # Post name validator. Post filenames must be like: # 2008-11-05-my-awesome-post.textile # @@ -109,7 +112,7 @@ module Jekyll if self.data.has_key? 'excerpt' self.data['excerpt'] else - self.extracted_excerpt.output || self.extracted_excerpt.to_s + self.extracted_excerpt.to_s end end @@ -249,12 +252,13 @@ module Jekyll # construct payload payload = { "site" => { "related_posts" => related_posts(site_payload["site"]["posts"]) }, - "page" => self.to_liquid + "page" => self.to_liquid(EXCERPT_ATTRIBUTES_FOR_LIQUID) }.deep_merge(site_payload) - self.extracted_excerpt.do_layout(payload, layouts) + self.extracted_excerpt.do_layout(payload, {}) + Jekyll.logger.info("", "#{self.excerpt}".green) - do_layout(payload, layouts) + do_layout(payload.merge({"page" => self.to_liquid}), layouts) end # Obtain destination path. @@ -272,8 +276,8 @@ module Jekyll # Convert this post into a Hash for use in Liquid templates. # # Returns the representative Hash. - def to_liquid - further_data = Hash[ATTRIBUTES_FOR_LIQUID.map { |attribute| + def to_liquid(attrs = ATTRIBUTES_FOR_LIQUID) + further_data = Hash[attrs.map { |attribute| [attribute, send(attribute)] }] data.deep_merge(further_data) From f883acc6644bd60930aa88f2504af3b0e04a7f89 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Mon, 22 Jul 2013 11:33:19 +0200 Subject: [PATCH 07/16] Remove debug statements --- lib/jekyll/convertible.rb | 1 - lib/jekyll/excerpt.rb | 1 - lib/jekyll/post.rb | 1 - 3 files changed, 3 deletions(-) diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index 1e5cfdeb..b247ac4e 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -78,7 +78,6 @@ module Jekyll # # Returns the converted content def render_liquid(content, payload, info) - Jekyll.logger.debug "Rendering Liquid for #{self.path}", "" Liquid::Template.parse(content).render!(payload, info) rescue Exception => e Jekyll.logger.error "Liquid Exception:", "#{e.message} in #{payload[:file]}" diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb index 768acd97..a5382466 100644 --- a/lib/jekyll/excerpt.rb +++ b/lib/jekyll/excerpt.rb @@ -59,7 +59,6 @@ module Jekyll end def to_s - Jekyll.logger.debug "Excerpt#to_s:", "#{self.output} || #{content}" self.output || self.content end diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 693517a6..9ad25399 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -256,7 +256,6 @@ module Jekyll }.deep_merge(site_payload) self.extracted_excerpt.do_layout(payload, {}) - Jekyll.logger.info("", "#{self.excerpt}".green) do_layout(payload.merge({"page" => self.to_liquid}), layouts) end From 81a7b2267267d3712eaadf8e4bf8f0b14e66b72b Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Mon, 22 Jul 2013 12:22:47 +0200 Subject: [PATCH 08/16] Add a new post, bump @site.posts.size --- .../2013-07-22-post-excerpt-with-layout.markdown | 14 ++++++++++++++ test/test_generated_site.rb | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown diff --git a/test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown b/test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown new file mode 100644 index 00000000..3eb86140 --- /dev/null +++ b/test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown @@ -0,0 +1,14 @@ +--- +layout: post +title: Post Excerpt with Layout +--- + +First paragraph with [link ref][link]. + +Second paragraph + +--- + +Third paragraph + +[link]: http://www.jekyllrb.com/ diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index 35c451c5..dd24187f 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase end should "ensure post count is as expected" do - assert_equal 34, @site.posts.size + assert_equal 35, @site.posts.size end should "insert site.posts into the index" do From 1bbacbd396c812b2b840f392af0c086a37b9d864 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Mon, 22 Jul 2013 12:40:49 +0200 Subject: [PATCH 09/16] Dumb tests are helpful anyway --- test/test_excerpt.rb | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 test/test_excerpt.rb diff --git a/test/test_excerpt.rb b/test/test_excerpt.rb new file mode 100644 index 00000000..9c4b6a72 --- /dev/null +++ b/test/test_excerpt.rb @@ -0,0 +1,55 @@ +require 'helper' + +class TestExcerpt < Test::Unit::TestCase + def setup_post(file) + Post.new(@site, source_dir, '', file) + end + + def do_render(post) + layouts = { "default" => Layout.new(@site, source_dir('_layouts'), "simple.html")} + post.render(layouts, {"site" => {"posts" => []}}) + end + + context "An extracted excerpt" do + setup do + clear_dest + stub(Jekyll).configuration { Jekyll::Configuration::DEFAULTS } + @site = Site.new(Jekyll.configuration) + @post = setup_post("2013-07-22-post-excerpt-with-layout.markdown") + end + + context "#to_liquid" do + should "contain the proper page data to mimick the post liquid" do + assert_equal {}, @post.excerpt.to_liquid.to_s + end + end + + context "#content" do + + context "before render" do + should "be the first paragraph of the page" do + assert_equal "First paragraph with [link ref][link].\n\n[link]: http://www.jekyllrb.com/", @post.excerpt.to_s + end + + should "contain any refs at the bottom of the page" do + assert @post.excerpt.to_s.include?("[link]: http://www.jekyllrb.com/") + end + end + + context "after render" do + setup do + @rendered_post = @post.dup + do_render(@rendered_post) + end + + should "be the first paragraph of the page" do + assert_equal "

First paragraph with link ref.

", @rendered_post.excerpt.content + end + + should "link properly" do + assert @rendered_post.excerpt.to_s.include?("http://www.jekyllrb.com/") + end + end + end + end +end From 3418a9197a2878b55f4b1e31da08baeee0a2157f Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Mon, 22 Jul 2013 12:57:03 +0200 Subject: [PATCH 10/16] Add categories and tags and test #to_liquid --- ...2013-07-22-post-excerpt-with-layout.markdown | 9 +++++++++ test/test_excerpt.rb | 17 ++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown b/test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown index 3eb86140..9d149266 100644 --- a/test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown +++ b/test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown @@ -1,6 +1,15 @@ --- layout: post title: Post Excerpt with Layout +categories: +- jekyll +- excerpt +- blah +tags: +- first +- second +- third +- jekyllrb.com --- First paragraph with [link ref][link]. diff --git a/test/test_excerpt.rb b/test/test_excerpt.rb index 9c4b6a72..5bdc72e0 100644 --- a/test/test_excerpt.rb +++ b/test/test_excerpt.rb @@ -16,11 +16,17 @@ class TestExcerpt < Test::Unit::TestCase stub(Jekyll).configuration { Jekyll::Configuration::DEFAULTS } @site = Site.new(Jekyll.configuration) @post = setup_post("2013-07-22-post-excerpt-with-layout.markdown") + @excerpt = @post.send :extract_excerpt end context "#to_liquid" do should "contain the proper page data to mimick the post liquid" do - assert_equal {}, @post.excerpt.to_liquid.to_s + assert_equal "", @excerpt.to_liquid + assert_equal "Post Excerpt with Layout", @excerpt.to_liquid["title"] + assert_equal "/jekyll/excerpt/blah/2013/07/22/post-excerpt-with-layout.html", @excerpt.to_liquid["url"] + assert_equal Time.new(2013, 07, 22), @excerpt.to_liquid["date"] + assert_equal %w[jekyll excerpt blah], @excerpt.to_liquid["categories"] + assert_equal %w[first second third jekyllrb.com], @excerpt.to_liquid["tags"] end end @@ -28,11 +34,11 @@ class TestExcerpt < Test::Unit::TestCase context "before render" do should "be the first paragraph of the page" do - assert_equal "First paragraph with [link ref][link].\n\n[link]: http://www.jekyllrb.com/", @post.excerpt.to_s + assert_equal "First paragraph with [link ref][link].\n\n[link]: http://www.jekyllrb.com/", @excerpt.content end should "contain any refs at the bottom of the page" do - assert @post.excerpt.to_s.include?("[link]: http://www.jekyllrb.com/") + assert @excerpt.content.include?("[link]: http://www.jekyllrb.com/") end end @@ -40,14 +46,15 @@ class TestExcerpt < Test::Unit::TestCase setup do @rendered_post = @post.dup do_render(@rendered_post) + @extracted_excerpt = @rendered_post.send :extracted_excerpt end should "be the first paragraph of the page" do - assert_equal "

First paragraph with link ref.

", @rendered_post.excerpt.content + assert_equal "

First paragraph with link ref.

", @extracted_excerpt.content end should "link properly" do - assert @rendered_post.excerpt.to_s.include?("http://www.jekyllrb.com/") + assert @extracted_excerpt.content.include?("http://www.jekyllrb.com/") end end end From 930aac3b79f41142a7123b3f897b2fed39a1ddfc Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Mon, 22 Jul 2013 13:03:48 +0200 Subject: [PATCH 11/16] Unit tests are simple --- test/test_excerpt.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_excerpt.rb b/test/test_excerpt.rb index 5bdc72e0..48588d4f 100644 --- a/test/test_excerpt.rb +++ b/test/test_excerpt.rb @@ -21,12 +21,12 @@ class TestExcerpt < Test::Unit::TestCase context "#to_liquid" do should "contain the proper page data to mimick the post liquid" do - assert_equal "", @excerpt.to_liquid assert_equal "Post Excerpt with Layout", @excerpt.to_liquid["title"] - assert_equal "/jekyll/excerpt/blah/2013/07/22/post-excerpt-with-layout.html", @excerpt.to_liquid["url"] + assert_equal "/bar/baz/z_category/2013/07/22/post-excerpt-with-layout.html", @excerpt.to_liquid["url"] assert_equal Time.new(2013, 07, 22), @excerpt.to_liquid["date"] - assert_equal %w[jekyll excerpt blah], @excerpt.to_liquid["categories"] + assert_equal %w[bar baz z_category], @excerpt.to_liquid["categories"] assert_equal %w[first second third jekyllrb.com], @excerpt.to_liquid["tags"] + assert_equal "_posts/2013-07-22-post-excerpt-with-layout.markdown", @excerpt.to_liquid["path"] end end From 95491eb7e7c111b20b86b18756a26a0f971c4595 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Mon, 22 Jul 2013 13:04:07 +0200 Subject: [PATCH 12/16] update categories on the new post to not fuck up old numbers --- .../_posts/2013-07-22-post-excerpt-with-layout.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown b/test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown index 9d149266..07b0e5f3 100644 --- a/test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown +++ b/test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown @@ -2,9 +2,9 @@ layout: post title: Post Excerpt with Layout categories: -- jekyll -- excerpt -- blah +- bar +- baz +- z_category tags: - first - second From 5d6b755d7d246a82f760b06bc6bfa27b01fbd6be Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Mon, 22 Jul 2013 13:42:40 +0200 Subject: [PATCH 13/16] feature maybe? --- features/post_excerpts.feature | 50 +++++++++++++++++++++++ features/step_definitions/jekyll_steps.rb | 6 +++ 2 files changed, 56 insertions(+) create mode 100644 features/post_excerpts.feature diff --git a/features/post_excerpts.feature b/features/post_excerpts.feature new file mode 100644 index 00000000..2254e29d --- /dev/null +++ b/features/post_excerpts.feature @@ -0,0 +1,50 @@ +Feature: Post excerpts + As a hacker who likes to blog + I want to be able to make a static sitej + In order to share my awesome ideas with the interwebs + But some people can only focus for a few moments + So just give them a taste + + Scenario: An excerpt without a layout + Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}" + And I have a _posts directory + And I have the following posts: + | title | date | layout | content | + | entry1 | 2007-12-31 | post | content for entry1. | + When I run jekyll + Then the _site directory should exist + And I should see exactly "

content for entry1.

" in "_site/index.html" + + Scenario: An excerpt from a post with a layout + Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}" + And I have a _posts directory + And I have a _layouts directory + And I have a post layout that contains "{{ page.excerpt }}" + And I have the following posts: + | title | date | layout | content | + | entry1 | 2007-12-31 | post | content for entry1. | + When I run jekyll + Then the _site directory should exist + And the _site/2007 directory should exist + And the _site/2007/12 directory should exist + And the _site/2007/12/31 directory should exist + And the "_site/2007/12/31/entry1.html" file should exist + And I should see exactly "

content for entry1.

" in "_site/2007/12/31/entry1.html" + And I should see exactly "

content for entry1.

" in "_site/index.html" + + Scenario: An excerpt from a post with a layout which has context + Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}" + And I have a _posts directory + And I have a _layouts directory + And I have a post layout that contains "{{ page.excerpt }}" + And I have the following posts: + | title | date | layout | content | + | entry1 | 2007-12-31 | post | content for entry1. | + When I run jekyll + Then the _site directory should exist + And the _site/2007 directory should exist + And the _site/2007/12 directory should exist + And the _site/2007/12/31 directory should exist + And the "_site/2007/12/31/entry1.html" file should exist + And I should see exactly "

content for entry1.

" in "_site/index.html" + And I should see exactly "

content for entry1.

" in "_site/2007/12/31/entry1.html" diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 9208c4ec..136f048d 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -4,6 +4,8 @@ Before do Dir.chdir(TEST_DIR) end +World(Test::Unit::Assertions) + Given /^I have a blank site in "(.*)"$/ do |path| FileUtils.mkdir(path) end @@ -143,6 +145,10 @@ Then /^I should see "(.*)" in "(.*)"$/ do |text, file| assert Regexp.new(text).match(File.open(file).readlines.join) end +Then /^I should see exactly "(.*)" in "(.*)"$/ do |text, file| + assert_equal text, File.open(file).readlines.join.strip +end + Then /^I should not see "(.*)" in "(.*)"$/ do |text, file| assert_no_match Regexp.new(text), File.read(file) end From 1e7dbcaaff7769b7a6df816ca005205824469683 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Mon, 22 Jul 2013 14:37:51 +0200 Subject: [PATCH 14/16] 1.8.7 doesn't support Time.new(*args), so use Time.parse instead --- test/test_excerpt.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_excerpt.rb b/test/test_excerpt.rb index 48588d4f..a72d1bd2 100644 --- a/test/test_excerpt.rb +++ b/test/test_excerpt.rb @@ -23,7 +23,7 @@ class TestExcerpt < Test::Unit::TestCase should "contain the proper page data to mimick the post liquid" do assert_equal "Post Excerpt with Layout", @excerpt.to_liquid["title"] assert_equal "/bar/baz/z_category/2013/07/22/post-excerpt-with-layout.html", @excerpt.to_liquid["url"] - assert_equal Time.new(2013, 07, 22), @excerpt.to_liquid["date"] + assert_equal Time.parse("2013-07-22"), @excerpt.to_liquid["date"] assert_equal %w[bar baz z_category], @excerpt.to_liquid["categories"] assert_equal %w[first second third jekyllrb.com], @excerpt.to_liquid["tags"] assert_equal "_posts/2013-07-22-post-excerpt-with-layout.markdown", @excerpt.to_liquid["path"] From a62d868c748670502029f3203a1d6b1c26f3131e Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Mon, 22 Jul 2013 14:57:44 +0200 Subject: [PATCH 15/16] s/sitej/site/ props @benbalter --- features/post_excerpts.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/post_excerpts.feature b/features/post_excerpts.feature index 2254e29d..09e41338 100644 --- a/features/post_excerpts.feature +++ b/features/post_excerpts.feature @@ -1,6 +1,6 @@ Feature: Post excerpts As a hacker who likes to blog - I want to be able to make a static sitej + I want to be able to make a static site In order to share my awesome ideas with the interwebs But some people can only focus for a few moments So just give them a taste From 0bb2af8dee0c7d12a9a49c9a825871cfff7d7248 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Tue, 23 Jul 2013 20:04:39 +0200 Subject: [PATCH 16/16] Remove superfluous conditional, props @mattr- --- lib/jekyll/excerpt.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/excerpt.rb b/lib/jekyll/excerpt.rb index a5382466..a02272b5 100644 --- a/lib/jekyll/excerpt.rb +++ b/lib/jekyll/excerpt.rb @@ -32,7 +32,7 @@ module Jekyll # Returns Hash of post data def data @data ||= post.data.dup - @data.delete("layout") if @data.has_key?("layout") + @data.delete("layout") @data end