From c22cd84153c2324e050492952cb3a8c367333a61 Mon Sep 17 00:00:00 2001 From: Nick Quaranto Date: Tue, 31 Mar 2009 17:26:04 -0400 Subject: [PATCH] Starting on implementing the step defs --- features/create_sites.feature | 15 ++++------ features/step_definitions/jekyll_steps.rb | 36 ++++++++++++++++++----- features/support/env.rb | 4 +++ 3 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 features/support/env.rb diff --git a/features/create_sites.feature b/features/create_sites.feature index 4aff818c..3346b7bd 100644 --- a/features/create_sites.feature +++ b/features/create_sites.feature @@ -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 | @@ -21,8 +19,7 @@ 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 @@ -30,8 +27,7 @@ Feature: Create sites 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 | @@ -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 diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 37fe0e3e..33156469 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -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 <> /dev/null` end When /^I change "(.*)" to contain "(.*)"$/ do |file, text| @@ -35,7 +55,7 @@ When /^I go to "(.*)"$/ do |address| end Then /^the (.*) directory should exist$/ do |dir| - pending + pending end Then /^I should see "(.*)"(?: in "(.*)")?$/ do |text, file| diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 00000000..93cbd8a6 --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1,4 @@ +require 'fileutils' +require 'rr' + +TEST_DIR = File.join('/', 'tmp', 'jekyll')