2009-11-30 20:32:02 +01:00
|
|
|
require 'fileutils'
|
|
|
|
|
2010-09-06 19:59:51 +02:00
|
|
|
Given /^generated directory at "([^\"]*)"$/ do |dirname|
|
|
|
|
target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", dirname)
|
2011-07-27 10:45:57 +02:00
|
|
|
init_cmd = File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "bin", "middleman init"))
|
2010-09-06 19:59:51 +02:00
|
|
|
`cd #{File.dirname(target)} && #{init_cmd} #{File.basename(target)}`
|
|
|
|
end
|
|
|
|
|
2009-11-30 20:32:02 +01:00
|
|
|
Then /^template files should exist at "([^\"]*)"$/ do |dirname|
|
2010-09-06 19:59:51 +02:00
|
|
|
target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", dirname)
|
2011-04-13 05:32:13 +02:00
|
|
|
template_glob = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "lib", "middleman", "templates", "default", "*/**/*")
|
2009-11-30 20:32:02 +01:00
|
|
|
|
|
|
|
Dir[template_glob].each do |f|
|
|
|
|
next if File.directory?(f)
|
|
|
|
File.exists?("#{target}/#{f.split('template/')[1]}").should be_true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^empty directories should exist at "([^\"]*)"$/ do |dirname|
|
2010-09-06 19:59:51 +02:00
|
|
|
target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", dirname)
|
2009-11-30 20:32:02 +01:00
|
|
|
|
2011-05-31 07:33:11 +02:00
|
|
|
%w(source/stylesheets source/javascripts source/images).each do |d|
|
2009-11-30 20:32:02 +01:00
|
|
|
File.exists?("#{target}/#{d}").should be_true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Then /^cleanup at "([^\"]*)"$/ do |dirname|
|
2010-09-06 19:59:51 +02:00
|
|
|
target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", dirname)
|
2009-11-30 20:32:02 +01:00
|
|
|
FileUtils.rm_rf(target)
|
|
|
|
end
|