Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Started on site config feature
Browse files Browse the repository at this point in the history
  • Loading branch information
qrush committed Apr 1, 2009
1 parent 3c0bc3b commit 4e302c0
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ test/dest/
pkg/
*.swp
*~
_site/
50 changes: 21 additions & 29 deletions features/site_configuration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,59 @@ 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
And I go to "http://0.0.0.0:1337"
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. |
Expand All @@ -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. |
Expand All @@ -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
Expand Down
25 changes: 19 additions & 6 deletions features/step_definitions/jekyll_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
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
Expand Down Expand Up @@ -75,16 +79,25 @@
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|
Expand Down
10 changes: 9 additions & 1 deletion features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@
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

0 comments on commit 4e302c0

Please sign in to comment.