lib/cucumber/chef/steps/ssh_steps.rb in cucumber-chef-2.0.2.pre vs lib/cucumber/chef/steps/ssh_steps.rb in cucumber-chef-2.0.3.pre
- old
+ new
@@ -91,5 +91,48 @@
@output.should =~ /#{$servers[name][key.downcase.to_sym]}/i
else
@output.should_not =~ /#{$servers[name][key.downcase.to_sym]}/i
end
end
+
+Then /^path "([^\"]*)" should exist$/ do |dir|
+ parent = File.dirname dir
+ child = File.basename dir
+ command = "ls %s" % [
+ parent
+ ]
+ @output = @connection.exec!(command)
+ @output.should =~ /#{child}/
+end
+
+Then /^path "([^\"]*)" should be owned by "([^\"]*)"$/ do |path, owner|
+ command = "stat -c %%U:%%G %s" % [
+ path
+ ]
+ @output = @connection.exec!(command)
+ @output.should =~ /#{owner}/
+end
+
+Then /^file "([^\"]*)" should( not)? contain "([^\"]*)"$/ do |path, boolean, content|
+ command = "cat %s" % [
+ path
+ ]
+ @output = @connection.exec!(command)
+ if (!boolean)
+ @output.should =~ /#{content}/
+ else
+ @output.should_not =~ /#{content}/
+ end
+end
+
+Then /^package "([^\"]*)" should be installed$/ do |package|
+ command = ""
+ if (dpkg = @connection.exec!("which dpkg 2> /dev/null")).length > 0
+ command = "#{dpkg.chomp} --get-selections"
+ elsif (yum = @connection.exec!("which yum 2> /dev/null")).length > 0
+ command = "#{yum.chomp} -q list installed"
+# could easily add more cases here, if I knew what they were :)
+ end
+
+ @output = @connection.exec!(command)
+ @output.should =~ /#{package}/
+end