diff --git a/.gitignore b/.gitignore index de43f334..66de090b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ test/dest/ pkg/ *.swp *~ +_site/ diff --git a/features/site_configuration.feature b/features/site_configuration.feature index 101fbe8d..d2f06219 100644 --- a/features/site_configuration.feature +++ b/features/site_configuration.feature @@ -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 "Google" in "_site/index.html" + And I should see "Google" 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 diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 87e2b5a0..e0125486 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -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 < 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| diff --git a/features/support/env.rb b/features/support/env.rb index 109880f2..31f028d4 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -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