middleman/features/step_definitions/builder_steps.rb
2011-07-27 01:45:57 -07:00

35 lines
1.5 KiB
Ruby

require 'fileutils'
require 'middleman/cli'
Given /^a built test app$/ do
target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app")
build_cmd = File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "bin", "middleman build"))
`cd #{target} && #{build_cmd}`
end
Given /^a built test app with flags "([^"]*)"$/ do |flags|
target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app")
build_cmd = File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "bin", "middleman build"))
`cd #{target} && #{build_cmd} #{flags}`
end
Given /^cleanup built test app$/ do
target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build")
FileUtils.rm_rf(target)
end
Then /^"([^"]*)" should exist$/ do |target_file,|
target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build", target_file)
File.exists?(target).should be_true
end
Then /^"([^"]*)" should exist and include "([^"]*)"$/ do |target_file, expected|
target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build", target_file)
File.exists?(target).should be_true
File.read(target).should include(expected)
end
Then /^"([^"]*)" should not exist$/ do |target_file|
target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build", target_file)
File.exists?(target).should be_false
end