diff --git a/features/site_configuration.feature b/features/site_configuration.feature index 0c59a2b9..31b8c71e 100644 --- a/features/site_configuration.feature +++ b/features/site_configuration.feature @@ -18,7 +18,7 @@ Feature: Site configuration Then the _mysite directory should exist And I should see "Changing destination directory" in "_mysite/index.html" - Scenario: Exclude files + Scenario: Exclude files inline Given I have an "Rakefile" file that contains "I want to be excluded" And I have an "README" file that contains "I want to be excluded" And I have an "index.html" file that contains "I want to be included" @@ -28,6 +28,19 @@ Feature: Site configuration And the "_site/Rakefile" file should not exist And the "_site/README" file should not exist + Scenario: Exclude files with YAML array + Given I have an "Rakefile" file that contains "I want to be excluded" + And I have an "README" file that contains "I want to be excluded" + And I have an "index.html" file that contains "I want to be included" + And I have a configuration file with "exclude" set to: + | Value | + | README | + | Rakefile | + When I run jekyll + Then I should see "I want to be included" in "_site/index.html" + And the "_site/Rakefile" file should not exist + And the "_site/README" file should not exist + Scenario: Use RDiscount for markup Given I have an "index.markdown" page that contains "[Google](http://google.com)" And I have a configuration file with "markdown" set to "rdiscount" diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index bb8dbbea..91c64f57 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -86,10 +86,25 @@ Given /^I have a configuration file with "(.*)" set to "(.*)"$/ do |key, value| end end +Given /^I have a configuration file with "([^\"]*)" set to:$/ do |key, table| + File.open('_config.yml', 'w') do |f| + f.write("#{key}:\n") + table.hashes.each do |row| + f.write("- #{row["Value"]}\n") + end + f.close + end +end + + When /^I run jekyll$/ do run_jekyll end +When /^I debug jekyll$/ do + run_jekyll(:debug => true) +end + When /^I change "(.*)" to contain "(.*)"$/ do |file, text| File.open(file, 'a') do |f| f.write(text) diff --git a/features/support/env.rb b/features/support/env.rb index 91734f08..635d3735 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -10,9 +10,7 @@ TEST_DIR = File.join('/', 'tmp', 'jekyll') JEKYLL_PATH = File.join(ENV['PWD'], 'bin', 'jekyll') def run_jekyll(opts = {}) - if opts[:bg] - bg = '&' - end - - system "#{JEKYLL_PATH} >> /dev/null" + command = JEKYLL_PATH + command << " >> /dev/null" if opts[:debug].nil? + system command end diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 1ed3836a..8eda3832 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -16,7 +16,6 @@ module Jekyll self.lsi = config['lsi'] self.pygments = config['pygments'] self.permalink_style = config['permalink'].to_sym - self.exclude = config['exclude'] || [] self.reset @@ -230,11 +229,9 @@ module Jekyll def filter_entries(entries) entries = entries.reject do |e| unless ['_posts', '.htaccess'].include?(e) - # Reject backup/hidden - ['.', '_', '#'].include?(e[0..0]) or e[-1..-1] == '~' or self.exclude.include?(e) + ['.', '_', '#'].include?(e[0..0]) || e[-1..-1] == '~' || self.exclude.include?(e) end end end - end end diff --git a/test/test_site.rb b/test/test_site.rb index d3a2de04..a99b8c6d 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -53,5 +53,13 @@ class TestSite < Test::Unit::TestCase assert_equal %w[foo.markdown bar.markdown baz.markdown], @site.filter_entries(ent1) assert_equal ent2, @site.filter_entries(ent2) end + + should "filter entries with exclude" do + excludes = %w[README TODO] + includes = %w[index.html site.css] + + @site.exclude = excludes + assert_equal includes, @site.filter_entries(excludes + includes) + end end end