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

Commit

Permalink
Starting on implementing the step defs
Browse files Browse the repository at this point in the history
  • Loading branch information
qrush committed Mar 31, 2009
1 parent 6c41f93 commit c22cd84
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
15 changes: 5 additions & 10 deletions features/create_sites.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ Feature: Create sites
In order to share my awesome ideas with the interwebs

Scenario: Basic site
Given I have a blank site
And I have an "index.html" file that contains "Basic Site"
Given I have an "index.html" file that contains "Basic Site"
When I run jekyll
Then the _site directory should exist
And I should see "Basic Site" in "_site/index.html"

Scenario: Basic site with a post
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 |
| Hackers | 3/27/2009 | My First Exploit |
Expand All @@ -21,17 +19,15 @@ Feature: Create sites
And I should see "My First Exploit" in "_site/2009/03/27/hackers.html"

Scenario: Basic site with layout and a page
Given I have a blank site
And I have a _layouts directory
Given I have a _layouts directory
And I have an "index.html" file with layout "default" that contains "Basic Site with Layout"
And I have a default layout that contains "Page Layout: {{ content }}"
When I run jekyll
Then the _site directory should exist
And I should see "Page Layout: Basic Site with Layout" in "_site/index.html"

Scenario: Basic site with layout and a post
Given I have a blank site
And I have a _layouts directory
Given I have a _layouts directory
And I have a _posts directory
And I have the following post:
| title | date | layout | content |
Expand All @@ -42,8 +38,7 @@ Feature: Create sites
And I should see "Post Layout: Would you like to play a game?" in "_site/2009/03/27/wargames.html"

Scenario: Basic site with include tag
Given I have a blank site
And I have a _includes directory
Given I have a _includes directory
And I have an "index.html" file that contains "Basic Site with include tag: {% include about.html %}"
And I have an "_includes/about.html" file that contains "Generated by Jekyll"
When I run jekyll
Expand Down
36 changes: 28 additions & 8 deletions features/step_definitions/jekyll_steps.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
Given /^I have a blank site(?: in (.*))?$/ do |dir|
pending
Before do
FileUtils.mkdir(TEST_DIR)
Dir.chdir(TEST_DIR)
end

Given /^I have an "(.*)" file( with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text|
pending
After do
Dir.chdir(TEST_DIR)
FileUtils.rm_rf(TEST_DIR)
end

Given /^I have an "(.*)" file(?: with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text|
File.open(file, 'w') do |f|
if key && value
f.write <<EOF
---
#{key}: #{value}
---
EOF
end

f.write(text)
f.close
end
end

Given /^I have a (.*) layout that contains "(.*)"$/ do |layout, text|
pending
File.open(layout, 'w') do |f|
f.write(text)
f.close
end
end

Given /^I have a (.*) directory$/ do |dir|
pending
FileUtils.mkdir(dir)
end

Given /^I have the following posts?(?: in "(.*)")?:$/ do |table, dir|
Expand All @@ -23,7 +43,7 @@
end

When /^I run jekyll$/ do
pending
`#{File.join(ENV['PWD'], 'bin', 'jekyll')} >> /dev/null`
end

When /^I change "(.*)" to contain "(.*)"$/ do |file, text|
Expand All @@ -35,7 +55,7 @@
end

Then /^the (.*) directory should exist$/ do |dir|
pending
pending
end

Then /^I should see "(.*)"(?: in "(.*)")?$/ do |text, file|
Expand Down
4 changes: 4 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'fileutils'
require 'rr'

TEST_DIR = File.join('/', 'tmp', 'jekyll')

0 comments on commit c22cd84

Please sign in to comment.