From 0f4d646510cc4f8d323a8724eccf1ba85fb93c77 Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Mon, 16 Sep 2013 15:19:29 +0200 Subject: [PATCH] extend feature tests and use scenario outline --- features/site_configuration.feature | 35 +++++++++++------------ features/step_definitions/jekyll_steps.rb | 14 +++++---- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/features/site_configuration.feature b/features/site_configuration.feature index 80a4b50b..89324cb1 100644 --- a/features/site_configuration.feature +++ b/features/site_configuration.feature @@ -18,27 +18,26 @@ Feature: Site configuration Then the _mysite directory should exist And I should see "Changing destination directory" in "_mysite/index.html" - Scenario: Similarly named source and destination - Given I have a blank site in "mysite_source" - And I have an "mysite_source/index.html" file that contains "html" + Scenario Outline: Similarly named source and destination + Given I have a blank site in "" + And I have an "/index.md" page that contains "markdown" And I have a configuration file with: - | key | value | - | source | mysite_source | - | destination | mysite | + | key | value | + | source | | + | destination | | When I run jekyll - Then the mysite directory should exist - And I should see "html" in "mysite/index.html" + Then the directory should exist + And the "/index.html" file should exist + And I should see "markdown" in "/index.md" - Scenario: Similarly named source and destination 2 - Given I have a blank site in "mysite" - And I have an "mysite/index.html" file that contains "html" - And I have a configuration file with: - | key | value | - | source | mysite | - | destination | mysite_dest | - When I run jekyll - Then the mysite_dest directory should exist - And I should see "html" in "mysite_dest/index.html" + Examples: + | source | dest | file_exist | + | mysite_source | mysite | | + | mysite | mysite_dest | | + | mysite/ | mysite | not | + | mysite | ./mysite | not | + | mysite/source | mysite | not | + | mysite | mysite/dest | | Scenario: Exclude files inline Given I have an "Rakefile" file that contains "I want to be excluded" diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index a1a1b797..56da1d11 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -7,7 +7,7 @@ end World(Test::Unit::Assertions) Given /^I have a blank site in "(.*)"$/ do |path| - FileUtils.mkdir(path) + FileUtils.mkdir_p(path) end Given /^I do not have a "(.*)" directory$/ do |path| @@ -137,10 +137,14 @@ When /^I delete the file "(.*)"$/ do |file| File.delete(file) end -Then /^the (.*) directory should exist$/ do |dir| +Then /^the (.*) directory should +exist$/ do |dir| assert File.directory?(dir), "The directory \"#{dir}\" does not exist" end +Then /^the (.*) directory should not exist$/ do |dir| + assert !File.directory?(dir), "The directory \"#{dir}\" exists" +end + Then /^I should see "(.*)" in "(.*)"$/ do |text, file| assert Regexp.new(text).match(File.open(file).readlines.join) end @@ -157,12 +161,12 @@ Then /^I should see escaped "(.*)" in "(.*)"$/ do |text, file| assert Regexp.new(Regexp.escape(text)).match(File.open(file).readlines.join) end -Then /^the "(.*)" file should exist$/ do |file| - assert File.file?(file) +Then /^the "(.*)" file should +exist$/ do |file| + assert File.file?(file), "The file \"#{file}\" does not exist" end Then /^the "(.*)" file should not exist$/ do |file| - assert !File.exists?(file) + assert !File.exists?(file), "The file \"#{file}\" exists" end Then /^I should see today's time in "(.*)"$/ do |file|