add drafts.feature
This commit is contained in:
parent
2df63e5b9d
commit
c48de6b320
|
@ -23,6 +23,7 @@ command :build do |c|
|
|||
|
||||
c.option '-w', '--watch', 'Watch for changes and rebuild'
|
||||
c.option '--lsi', 'Use LSI for improved related posts'
|
||||
c.option '--drafts', 'Render posts in the _drafts folder'
|
||||
|
||||
c.action do |args, options|
|
||||
options.defaults :serving => false
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
Feature: Draft Posts
|
||||
As a hacker who likes to blog
|
||||
I want to be able to preview drafts locally
|
||||
In order to see if they look alright before publishing
|
||||
|
||||
Scenario: Preview a draft
|
||||
Given I have a configuration file with "permalink" set to "none"
|
||||
And I have a _drafts directory
|
||||
And I have the following draft:
|
||||
| title | date | layout | content |
|
||||
| Recipe | 3/27/2009 | default | Not baked yet. |
|
||||
When I run jekyll with drafts
|
||||
Then the _site directory should exist
|
||||
And I should see "Not baked yet." in "_site/recipe.html"
|
||||
|
||||
Scenario: Don't preview a draft
|
||||
Given I have a configuration file with "permalink" set to "none"
|
||||
And I have an "index.html" page that contains "Totally index"
|
||||
And I have a _drafts directory
|
||||
And I have the following draft:
|
||||
| title | date | layout | content |
|
||||
| Recipe | 3/27/2009 | default | Not baked yet. |
|
||||
When I run jekyll
|
||||
Then the _site directory should exist
|
||||
And the "_site/recipe.html" file should not exist
|
|
@ -50,7 +50,9 @@ Given /^I have an? (.*) directory$/ do |dir|
|
|||
FileUtils.mkdir_p(dir)
|
||||
end
|
||||
|
||||
Given /^I have the following posts?(?: (.*) "(.*)")?:$/ do |direction, folder, table|
|
||||
Given /^I have the following (draft|post)s?(?: (.*) "(.*)")?:$/ do |type, direction, folder, table|
|
||||
subdir = "_#{type}s"
|
||||
|
||||
table.hashes.each do |post|
|
||||
date = Date.strptime(post['date'], '%m/%d/%Y').strftime('%Y-%m-%d')
|
||||
title = post['title'].downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-')
|
||||
|
@ -61,7 +63,7 @@ Given /^I have the following posts?(?: (.*) "(.*)")?:$/ do |direction, folder, t
|
|||
after = folder || '.'
|
||||
end
|
||||
|
||||
path = File.join(before || '.', '_posts', after || '.', "#{date}-#{title}.#{post['type'] || 'textile'}")
|
||||
path = File.join(before || '.', subdir, after || '.', "#{date}-#{title}.#{post['type'] || 'textile'}")
|
||||
|
||||
matter_hash = {}
|
||||
%w(title layout tag tags category categories published author).each do |key|
|
||||
|
@ -117,6 +119,10 @@ When /^I run jekyll$/ do
|
|||
run_jekyll
|
||||
end
|
||||
|
||||
When /^I run jekyll with drafts$/ do
|
||||
run_jekyll(:drafts => true)
|
||||
end
|
||||
|
||||
When /^I debug jekyll$/ do
|
||||
run_jekyll(:debug => true)
|
||||
end
|
||||
|
|
|
@ -10,8 +10,9 @@ TEST_DIR = File.join('/', 'tmp', 'jekyll')
|
|||
JEKYLL_PATH = File.join(ENV['PWD'], 'bin', 'jekyll')
|
||||
|
||||
def run_jekyll(opts = {})
|
||||
command = JEKYLL_PATH
|
||||
command = JEKYLL_PATH.clone
|
||||
command << " build"
|
||||
command << " --drafts" if opts[:drafts]
|
||||
command << " >> /dev/null 2>&1" if opts[:debug].nil?
|
||||
system command
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue