1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00
middleman--middleman/features/step_definitions/builder_steps.rb

52 lines
1.9 KiB
Ruby
Raw Normal View History

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
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)
build_cmd = File.expand_path(File.join(root, "bin", "middleman build"))
`cd #{target} && #{build_cmd}`
end
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"))
`cd #{target} && #{build_cmd} #{flags}`
end
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
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)
File.exists?(target).should be_true
File.read(target).should include(expected)
end
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)
File.exists?(target).should be_false
end