diff --git a/features/collections.feature b/features/collections.feature new file mode 100644 index 00000000..209232e3 --- /dev/null +++ b/features/collections.feature @@ -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\"=>#, #, #, #, #\]>}" 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" \ No newline at end of file diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 93de5c10..45210630 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -16,15 +16,14 @@ def file_content_from_hash(input_hash) EOF end - Before do FileUtils.mkdir_p(TEST_DIR) unless File.exist?(TEST_DIR) Dir.chdir(TEST_DIR) end After do - FileUtils.rm_rf(TEST_DIR) if File.exist?(TEST_DIR) - FileUtils.rm(JEKYLL_COMMAND_OUTPUT_FILE) + FileUtils.rm_rf(TEST_DIR) if File.exists?(TEST_DIR) + FileUtils.rm(JEKYLL_COMMAND_OUTPUT_FILE) if File.exists?(JEKYLL_COMMAND_OUTPUT_FILE) end World(Test::Unit::Assertions) @@ -130,6 +129,16 @@ Given /^I have a configuration file with "([^\"]*)" set to:$/ do |key, table| 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| run_jekyll_build(opt) end diff --git a/features/support/env.rb b/features/support/env.rb index ad3bb38a..593e1304 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -6,10 +6,15 @@ require 'rr' require 'test/unit' require 'time' +JEKYLL_SOURCE_DIR = File.dirname(File.dirname(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_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 JEKYLL_COMMAND_OUTPUT_FILE end diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index 21351374..6a12fd65 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -30,5 +30,16 @@ module Jekyll !(site.safe && File.symlink?(path)) end + def inspect + "#" + end + + def to_liquid + { + "label" => label, + "docs" => docs + } + end + end end diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 23ee437e..f137e988 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -89,6 +89,10 @@ module Jekyll }) end + def inspect + "#" + end + def <=>(anotherDocument) path <=> anotherDocument.path end diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 8fe10776..204d0bbd 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -290,7 +290,8 @@ module Jekyll "html_pages" => pages.reject { |page| !page.html? }, "categories" => post_attr_hash('categories'), "tags" => post_attr_hash('tags'), - "data" => site_data})} + "data" => site_data, + "collections" => collections})} end # Filter out any files/directories that are hidden or backup files (start