2010-09-06 13:59:51 -04:00
|
|
|
require 'fileutils'
|
|
|
|
|
2011-10-15 14:21:56 -04:00
|
|
|
Given /^app "([^"]*)" is using config "([^"]*)"$/ do |path, config_name|
|
|
|
|
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
|
|
|
target = File.join(root, "fixtures", path)
|
|
|
|
config_path = File.join(target, "config-#{config_name}.rb")
|
|
|
|
config_dest = File.join(target, "config.rb")
|
|
|
|
FileUtils.cp(config_path, config_dest)
|
|
|
|
end
|
|
|
|
|
2011-07-27 22:59:38 -04:00
|
|
|
Given /^a built app at "([^"]*)"$/ do |path|
|
|
|
|
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
|
|
|
target = File.join(root, "fixtures", path)
|
2011-11-08 01:34:02 -05:00
|
|
|
|
|
|
|
build_target = File.join(target, "build")
|
|
|
|
FileUtils.rm_rf(build_target)
|
|
|
|
|
2011-07-27 22:59:38 -04:00
|
|
|
build_cmd = File.expand_path(File.join(root, "bin", "middleman build"))
|
2011-07-27 02:19:43 -04:00
|
|
|
`cd #{target} && #{build_cmd}`
|
2010-09-06 13:59:51 -04:00
|
|
|
end
|
|
|
|
|
2011-07-27 22:59:38 -04:00
|
|
|
Then /^cleanup built app at "([^"]*)"$/ do |path|
|
|
|
|
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
|
|
|
target = File.join(root, "fixtures", path, "build")
|
|
|
|
FileUtils.rm_rf(target)
|
|
|
|
end
|
|
|
|
|
2011-08-05 18:29:21 -04:00
|
|
|
Given /^a built app at "([^"]*)" with flags "([^"]*)"$/ do |path, flags|
|
|
|
|
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
|
|
|
target = File.join(root, "fixtures", path)
|
|
|
|
build_cmd = File.expand_path(File.join(root, "bin", "middleman build"))
|
2011-07-27 02:19:43 -04:00
|
|
|
`cd #{target} && #{build_cmd} #{flags}`
|
2011-04-19 17:24:21 -04:00
|
|
|
end
|
|
|
|
|
2011-07-27 22:59:38 -04:00
|
|
|
Then /^"([^"]*)" should exist at "([^"]*)"$/ do |target_file, path|
|
|
|
|
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
|
|
|
target = File.join(root, "fixtures", path, "build", target_file)
|
2011-07-22 14:43:00 -04:00
|
|
|
File.exists?(target).should be_true
|
|
|
|
end
|
|
|
|
|
2011-07-27 22:59:38 -04:00
|
|
|
Then /^"([^"]*)" should exist at "([^"]*)" and include "([^"]*)"$/ do |target_file, path, expected|
|
|
|
|
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
|
|
|
target = File.join(root, "fixtures", path, "build", target_file)
|
2010-09-06 13:59:51 -04:00
|
|
|
File.exists?(target).should be_true
|
|
|
|
File.read(target).should include(expected)
|
|
|
|
end
|
|
|
|
|
2011-07-27 22:59:38 -04:00
|
|
|
Then /^"([^"]*)" should not exist at "([^"]*)"$/ do |target_file, path|
|
|
|
|
root = File.dirname(File.dirname(File.dirname(__FILE__)))
|
|
|
|
target = File.join(root, "fixtures", path, "build", target_file)
|
2010-09-06 13:59:51 -04:00
|
|
|
File.exists?(target).should be_false
|
2011-05-31 01:33:11 -04:00
|
|
|
end
|