Before do FileUtils.mkdir(TEST_DIR) Dir.chdir(TEST_DIR) end After do Dir.chdir(TEST_DIR) FileUtils.rm_rf(TEST_DIR) end Given /^I have an "(.*)" page(?: with layout "(.*)")? that contains "(.*)"$/ do |file, layout, text| File.open(file, 'w') do |f| f.write < post['title']} matter_hash['layout'] = post['layout'] if post['layout'] matter = matter_hash.map { |k, v| "#{k}: #{v}\n" } File.open(path, 'w') do |f| f.write <