Feature:
In order to deploy my application
As a systems administrator
I want to know that the config files are legal
Scenario: ValidApache config
Given a config file template apache2.conf in etc/apache2
WhenI generate it
Then there should be a file called apache2.conf in etc/apache2
And it should be valid
apache.steps
require'fileutils'require'spec/expectations'Beforedo@tmp_dir='tmp'endGiven/^a config file template (.*) in (.*)$/do |file, server_root|
@server_root= server_root
@tmp_server_root=File.join('tmp',@server_root)
@template_file=File.join('templates',server_root,file)
@file= file
File.exists?(@template_file).should be_true
endWhen/^I generate it$/do
dest_file =File.join(@tmp_server_root,@file)
FileUtils.mkdir_p(@tmp_server_root)
server_root =@server_root# the ERB template needs this
template =ERB.new(File.read(@template_file))
File.open(dest_file,'w+') {|f| f.write(template.result(binding)) }
File.size(dest_file).should >0endThen/^there should be a file called (.*) in (.*)$/do |name, dir|
@config_file= name
File.exists?(File.join(@tmp_dir,dir,name)).should be_true
endAnd/^it should be valid$/do
system("/usr/sbin/httpd -d #{@tmp_server_root} -t -f #{@config_file}").should be_true
end