Before do FileUtils.rm_rf(TEST_DIR) FileUtils.mkdir(TEST_DIR) Dir.chdir(TEST_DIR) end World(Test::Unit::Assertions) Given /^I have a blank site in "(.*)"$/ do |path| FileUtils.mkdir(path) end Given /^I do not have a "(.*)" directory$/ do |path| File.directory?("#{TEST_DIR}/#{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 (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text| File.open(file, 'w') do |f| f.write < true) end When /^I call jekyll new with test_blank --blank$/ do call_jekyll_new(:path => "test_blank", :blank => true) end When /^I debug jekyll$/ do run_jekyll(:debug => true) end When /^I change "(.*)" to contain "(.*)"$/ do |file, text| File.open(file, 'a') do |f| f.write(text) end end When /^I delete the file "(.*)"$/ do |file| File.delete(file) end Then /^the (.*) directory should exist$/ do |dir| assert File.directory?(dir), "The directory \"#{dir}\" does not exist" end Then /^I should see "(.*)" in "(.*)"$/ do |text, file| assert Regexp.new(text).match(File.open(file).readlines.join) end Then /^I should see exactly "(.*)" in "(.*)"$/ do |text, file| assert_equal text, File.open(file).readlines.join.strip end Then /^I should not see "(.*)" in "(.*)"$/ do |text, file| assert_no_match Regexp.new(text), File.read(file) end 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) end Then /^the "(.*)" file should not exist$/ do |file| assert !File.exists?(file) end Then /^I should see today's time in "(.*)"$/ do |file| assert_match Regexp.new(Regexp.escape(Time.now.to_s)), File.open(file).readlines.join end Then /^I should see today's date in "(.*)"$/ do |file| assert_match Regexp.new(Date.today.to_s), File.open(file).readlines.join end