Started on site config feature

This commit is contained in:
Nick Quaranto 2009-04-01 18:43:06 -04:00
parent 3c0bc3b2de
commit 4e302c0445
4 changed files with 50 additions and 36 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ test/dest/
pkg/
*.swp
*~
_site/

View File

@ -5,56 +5,51 @@ Feature: Site configuration
Scenario: Change destination directory
Given I have a blank site in "_sourcedir"
And I have an "index.html" file that contains "Changing source directory"
And I have a configuration file in "_sourcedir" with "source" set to "_sourcedir"
And I have an "_sourcedir/index.html" file that contains "Changing source directory"
And I have a configuration file with "source" set to "_sourcedir"
When I run jekyll
Then the _site directory should exist
And I should see "Changing source directory" in "_site/index.html"
Scenario: Change destination directory
Given I have a blank site
And I have an "index.html" file that contains "Changing destination directory"
And I have a configuration file with "site" set to "_mysite"
Given I have an "index.html" file that contains "Changing destination directory"
And I have a configuration file with "destination" set to "_mysite"
When I run jekyll
Then the _mysite directory should exist
And I should see "Basic Site" in "_mysite/index.html"
And I should see "Changing destination directory" in "_mysite/index.html"
Scenario: Use RDiscount for markup
Given I have a blank site
And I have an "index.html" file that contains "[Google](http://google.com)"
Given I have an "index.html" file that contains "[Google](http://google.com)"
And I have a configuration file with "markdown" set to "rdiscount"
When I run jekyll
Then the _site directory should exist
And I should see "<a href='http://google.com/>Google</a>" in "_site/index.html"
Scenario: Use Maruku for markup
Given I have a blank site
And I have an "index.html" file that contains "[Google](http://google.com)"
And I have a configuration file with "markdown" set to "rdiscount"
Given I have an "index.markdown" page that contains "[Google](http://google.com)"
And I have a configuration file with "markdown" set to "maruku"
When I run jekyll
Then the _site directory should exist
And I should see "<a href='http://google.com/>Google</a>" in "_site/index.html"
And I should see "<a href='http://google.com'>Google</a>" in "_site/index.html"
Scenario: Disable auto-regeneration
Given I have a blank site
And I have an "index.html" file that contains "My Awesome Site"
And I have a configuration file with "auto" set to "false"
When I run jekyll
And I change "index.html" to contain "Auto-regenerate off!"
Scenario: Enable auto-regeneration
Given I have an "index.html" file that contains "My Awesome Site"
And I have a configuration file with "auto" set to "true"
When I run jekyll in the background
And I change "index.html" to contain "Auto-regenerate on!"
Then the _site directory should exist
And I should see "My awesome site" in "_site/index.html"
And I should see "My Awesome Site" in "_site/index.html"
And I should see "Auto-regenerate on!" in "_site/index.html"
Scenario: Run server to host generated site
Given I have a blank site
And I have an "index.html" file that contains "WEBrick to the rescue"
Given I have an "index.html" file that contains "WEBrick to the rescue"
And I have a configuration file with "server" set to "true"
When I run jekyll
And I go to "http://0.0.0.0:4000"
Then I should see "WEBrick to the rescue"
Scenario: Run server on a different server port
Given I have a blank site
And I have an "index.html" file that contains "Changing Port"
Given I have an "index.html" file that contains "Changing Port"
And I have a configuration file with "server" set to "true"
And I have a configuration file with "port" set to "1337"
When I run jekyll
@ -62,8 +57,7 @@ Feature: Site configuration
Then I should see "Changing Port"
Scenario: Use none permalink schema
Given I have a blank site
And I have a _posts directory
Given I have a _posts directory
And I have the following post:
| title | date | content |
| None Permalink Schema | 3/27/2009 | Totally nothing. |
@ -73,8 +67,7 @@ Feature: Site configuration
And I should see "Totally nothing." in "_site/none-permalink-schema.html"
Scenario: Use pretty permalink schema
Given I have a blank site
And I have a _posts directory
Given I have a _posts directory
And I have the following post:
| title | date | content |
| Pretty Permalink Schema | 3/27/2009 | Totally wordpress. |
@ -84,8 +77,7 @@ Feature: Site configuration
And I should see "Totally wordpress." in "_site/2009/03/27/pretty-permalink-schema/index.html"
Scenario: Highlight code with pygments
Given I have a blank site
And I have an "index.html" file that contains "{% highlight ruby %} puts 'Hello world!' {% endhighlight %}"
Given I have an "index.html" file that contains "{% highlight ruby %} puts 'Hello world!' {% endhighlight %}"
And I have a configuration file with "pygments" set to "true"
When I run jekyll
Then the _site directory should exist

View File

@ -8,15 +8,19 @@ After do
FileUtils.rm_rf(TEST_DIR)
end
Given /^I have a blank site in "(.*)"$/ do |path|
FileUtils.mkdir(path)
end
# Like "I have a foo file" but gives a yaml front matter so jekyll actually processes it
Given /^I have an "(.*)" page(?: with layout "(.*)")? that contains "(.*)"$/ do |file, layout, text|
File.open(file, 'w') do |f|
f.write <<EOF
---
layout: #{layout || 'nil'}
---
#{text}
EOF
f.write(text)
f.close
end
end
@ -75,16 +79,25 @@ EOF
end
end
Given /^I have a configuration file(?: in "(.*)")? with "(.*)" set to "(.*)"$/ do |dir, key, value|
pending
Given /^I have a configuration file with "(.*)" set to "(.*)"$/ do |key, value|
File.open('_config.yml', 'w') do |f|
f.write("#{key}: #{value}")
f.close
end
end
When /^I run jekyll in the background$/ do
run_jekyll(:bg => true)
end
When /^I run jekyll$/ do
system File.join(ENV['PWD'], 'bin', 'jekyll') + " >> /dev/null"
run_jekyll
end
When /^I change "(.*)" to contain "(.*)"$/ do |file, text|
pending
File.open(file, 'a') do |f|
f.write(text)
end
end
When /^I go to "(.*)"$/ do |address|

View File

@ -6,4 +6,12 @@ World do
include Test::Unit::Assertions
end
TEST_DIR = File.join('/', 'tmp', 'jekyll')
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 #{bg}"
end