GUYS failing test for rendering

This commit is contained in:
Parker Moore 2014-04-02 00:53:43 -04:00
parent c1c5cc78a5
commit f082eca791
6 changed files with 58 additions and 4 deletions

View File

@ -0,0 +1,24 @@
Feature: Collections
As a hacker who likes to structure content
I want to be able to create collections of similar information
And render them
Scenario: Unrendered collection
Given I have an "index.html" page that contains "Collections: {{ site.collections }}"
And I have fixture collections
And I have a configuration file with "collections" set to "['methods']"
When I debug jekyll
Then the _site directory should exist
And I should see "Collections: {\"methods\"=>#<Jekyll::Collection @label=methods docs=\[#<Jekyll::Document _methods/configuration.md collection=methods>, #<Jekyll::Document _methods/sanitized_path.md collection=methods>, #<Jekyll::Document _methods/site/generate.md collection=methods>, #<Jekyll::Document _methods/site/initialize.md collection=methods>, #<Jekyll::Document _methods/um_hi.md collection=methods>\]>}" in "_site/index.html"
Scenario: Rendered collection
Given I have an "index.html" page that contains "Collections: {{ site.collections.methods.label }}"
And I have fixture collections
And I have a configuration file with:
| key | value |
| collections | ['methods'] |
| render | \n methods: /methods/:collection_name/:subdir/:title:extname |
When I run jekyll
Then the _site directory should exist
And I should see "Collections: methods" in "_site/index.html"
And I should see "Whatever: foo.bar" in "_site/methods/configuration.html"

View File

@ -16,15 +16,14 @@ def file_content_from_hash(input_hash)
EOF EOF
end end
Before do Before do
FileUtils.mkdir_p(TEST_DIR) unless File.exist?(TEST_DIR) FileUtils.mkdir_p(TEST_DIR) unless File.exist?(TEST_DIR)
Dir.chdir(TEST_DIR) Dir.chdir(TEST_DIR)
end end
After do After do
FileUtils.rm_rf(TEST_DIR) if File.exist?(TEST_DIR) FileUtils.rm_rf(TEST_DIR) if File.exists?(TEST_DIR)
FileUtils.rm(JEKYLL_COMMAND_OUTPUT_FILE) FileUtils.rm(JEKYLL_COMMAND_OUTPUT_FILE) if File.exists?(JEKYLL_COMMAND_OUTPUT_FILE)
end end
World(Test::Unit::Assertions) World(Test::Unit::Assertions)
@ -130,6 +129,16 @@ Given /^I have a configuration file with "([^\"]*)" set to:$/ do |key, table|
end end
end end
Given /^I have fixture collections$/ do
FileUtils.cp_r File.join(JEKYLL_SOURCE_DIR, "test", "source", "_methods"), source_dir
end
##################
#
# Changing stuff
#
##################
When /^I run jekyll(?: with "(.+)")?$/ do |opt| When /^I run jekyll(?: with "(.+)")?$/ do |opt|
run_jekyll_build(opt) run_jekyll_build(opt)
end end

View File

@ -6,10 +6,15 @@ require 'rr'
require 'test/unit' require 'test/unit'
require 'time' require 'time'
JEKYLL_SOURCE_DIR = File.dirname(File.dirname(File.dirname(__FILE__)))
TEST_DIR = File.expand_path(File.join('..', '..', 'tmp', 'jekyll'), File.dirname(__FILE__)) TEST_DIR = File.expand_path(File.join('..', '..', 'tmp', 'jekyll'), File.dirname(__FILE__))
JEKYLL_PATH = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'jekyll') JEKYLL_PATH = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'jekyll')
JEKYLL_COMMAND_OUTPUT_FILE = File.join(File.dirname(TEST_DIR), 'jekyll_output.txt') JEKYLL_COMMAND_OUTPUT_FILE = File.join(File.dirname(TEST_DIR), 'jekyll_output.txt')
def source_dir(*files)
File.join(TEST_DIR, *files)
end
def jekyll_output_file def jekyll_output_file
JEKYLL_COMMAND_OUTPUT_FILE JEKYLL_COMMAND_OUTPUT_FILE
end end

View File

@ -30,5 +30,16 @@ module Jekyll
!(site.safe && File.symlink?(path)) !(site.safe && File.symlink?(path))
end end
def inspect
"#<Jekyll::Collection @label=#{label} docs=#{docs}>"
end
def to_liquid
{
"label" => label,
"docs" => docs
}
end
end end
end end

View File

@ -89,6 +89,10 @@ module Jekyll
}) })
end end
def inspect
"#<Jekyll::Document #{relative_path} collection=#{collection.label}>"
end
def <=>(anotherDocument) def <=>(anotherDocument)
path <=> anotherDocument.path path <=> anotherDocument.path
end end

View File

@ -290,7 +290,8 @@ module Jekyll
"html_pages" => pages.reject { |page| !page.html? }, "html_pages" => pages.reject { |page| !page.html? },
"categories" => post_attr_hash('categories'), "categories" => post_attr_hash('categories'),
"tags" => post_attr_hash('tags'), "tags" => post_attr_hash('tags'),
"data" => site_data})} "data" => site_data,
"collections" => collections})}
end end
# Filter out any files/directories that are hidden or backup files (start # Filter out any files/directories that are hidden or backup files (start