Making sure excludes can work with a YAML array
This commit is contained in:
parent
252ca94b81
commit
53368cc3e1
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue