cucumber-chef 2.0.2.pre → 2.0.3.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cucumber/chef/helpers/chef_server.rb +13 -0
- data/lib/cucumber/chef/steps/chef_steps.rb +6 -0
- data/lib/cucumber/chef/steps/provision_steps.rb +1 -1
- data/lib/cucumber/chef/steps/ssh_steps.rb +43 -0
- data/lib/cucumber/chef/test_runner.rb +2 -2
- data/lib/cucumber/chef/version.rb +1 -1
- metadata +2 -2
@@ -35,6 +35,19 @@ module Cucumber::Chef::Helpers::ChefServer
|
|
35
35
|
log("chef-server", "destroyed client '#{name}'")
|
36
36
|
end
|
37
37
|
|
38
|
+
################################################################################
|
39
|
+
|
40
|
+
def load_cookbook(cookbook, cookbook_path)
|
41
|
+
if !File.exists?(cookbook_path)
|
42
|
+
raise "Cookbook path does not exist!"
|
43
|
+
end
|
44
|
+
cookbook_repo = ::Chef::CookbookLoader.new(cookbook_path)
|
45
|
+
cookbook_repo.each do |name, cbook|
|
46
|
+
::Chef::CookbookUploader.new(cbook, cookbook_path, :force => true).upload_cookbook
|
47
|
+
log("chef-server", "uploaded cookbook '#{cookbook}' from path '#{cookbook_path}'")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
38
51
|
################################################################################
|
39
52
|
|
40
53
|
def load_role(role, role_path)
|
@@ -30,3 +30,9 @@ And /^the following roles have been updated:$/ do |table|
|
|
30
30
|
load_role(entry['role'], entry['role_path'])
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
And /^the following cookbooks have been uploaded:$/ do |table|
|
35
|
+
table.hashes.each do |entry|
|
36
|
+
load_cookbook(entry['cookbook'], entry['cookbook_path'])
|
37
|
+
end
|
38
|
+
end
|
@@ -31,7 +31,7 @@ And /^"([^\"]*)" has "([^\"]*)" architecture$/ do |name, arch|
|
|
31
31
|
@servers[name].merge!( :arch => arch )
|
32
32
|
end
|
33
33
|
|
34
|
-
And /^"([^\"]*)" should( not)? be
|
34
|
+
And /^"([^\"]*)" should( not)? be persist[ae]nt$/ do |name, boolean|
|
35
35
|
@servers[name].merge!( :persist => (!boolean ? true : false) )
|
36
36
|
end
|
37
37
|
|
@@ -93,3 +93,46 @@ Then /^I should( not)? see the "([^\"]*)" of "([^\"]*)" in the output$/ do |bool
|
|
93
93
|
@output.should_not =~ /#{$servers[name][key.downcase.to_sym]}/i
|
94
94
|
end
|
95
95
|
end
|
96
|
+
|
97
|
+
Then /^path "([^\"]*)" should exist$/ do |dir|
|
98
|
+
parent = File.dirname dir
|
99
|
+
child = File.basename dir
|
100
|
+
command = "ls %s" % [
|
101
|
+
parent
|
102
|
+
]
|
103
|
+
@output = @connection.exec!(command)
|
104
|
+
@output.should =~ /#{child}/
|
105
|
+
end
|
106
|
+
|
107
|
+
Then /^path "([^\"]*)" should be owned by "([^\"]*)"$/ do |path, owner|
|
108
|
+
command = "stat -c %%U:%%G %s" % [
|
109
|
+
path
|
110
|
+
]
|
111
|
+
@output = @connection.exec!(command)
|
112
|
+
@output.should =~ /#{owner}/
|
113
|
+
end
|
114
|
+
|
115
|
+
Then /^file "([^\"]*)" should( not)? contain "([^\"]*)"$/ do |path, boolean, content|
|
116
|
+
command = "cat %s" % [
|
117
|
+
path
|
118
|
+
]
|
119
|
+
@output = @connection.exec!(command)
|
120
|
+
if (!boolean)
|
121
|
+
@output.should =~ /#{content}/
|
122
|
+
else
|
123
|
+
@output.should_not =~ /#{content}/
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
Then /^package "([^\"]*)" should be installed$/ do |package|
|
128
|
+
command = ""
|
129
|
+
if (dpkg = @connection.exec!("which dpkg 2> /dev/null")).length > 0
|
130
|
+
command = "#{dpkg.chomp} --get-selections"
|
131
|
+
elsif (yum = @connection.exec!("which yum 2> /dev/null")).length > 0
|
132
|
+
command = "#{yum.chomp} -q list installed"
|
133
|
+
# could easily add more cases here, if I knew what they were :)
|
134
|
+
end
|
135
|
+
|
136
|
+
@output = @connection.exec!(command)
|
137
|
+
@output.should =~ /#{package}/
|
138
|
+
end
|
@@ -51,9 +51,9 @@ module Cucumber
|
|
51
51
|
|
52
52
|
@stdout.puts("Executing Cucumber-Chef Test Runner")
|
53
53
|
remote_path = File.join("/", "home", "ubuntu", "features")
|
54
|
-
cucumber_options = args.flatten.compact.
|
54
|
+
cucumber_options = args.flatten.compact.join(" ")
|
55
55
|
env = ( destroy ? "DESTROY=1" : nil )
|
56
|
-
command = [ "cd #{remote_path}", "&&", "sudo", env, "cucumber", cucumber_options, "--exclude support/roles", "--exclude support/data_bags", "--exclude support/keys", "." ].flatten.compact.join(" ")
|
56
|
+
command = [ "cd #{remote_path}", "&&", "sudo", env, "cucumber", cucumber_options, "--exclude support/cookbooks", "--exclude support/roles", "--exclude support/data_bags", "--exclude support/keys", "." ].flatten.compact.join(" ")
|
57
57
|
|
58
58
|
@ssh.exec(command)
|
59
59
|
end
|
@@ -24,7 +24,7 @@ module Cucumber
|
|
24
24
|
|
25
25
|
################################################################################
|
26
26
|
|
27
|
-
VERSION = "2.0.
|
27
|
+
VERSION = "2.0.3.pre" unless const_defined?(:VERSION)
|
28
28
|
|
29
29
|
################################################################################
|
30
30
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3.pre
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-08-
|
13
|
+
date: 2012-08-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: chef
|