cucumber-chef 2.0.3.pre → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -172,7 +172,7 @@ module Cucumber
|
|
172
172
|
cookbook_repo = ::Chef::CookbookLoader.new(@cookbooks_path)
|
173
173
|
cookbook_repo.each do |name, cookbook|
|
174
174
|
$logger.debug { "::Chef::CookbookUploader(#{name}) ATTEMPT" }
|
175
|
-
::Chef::CookbookUploader.new(cookbook, @cookbooks_path, :force => true).
|
175
|
+
::Chef::CookbookUploader.new(cookbook, @cookbooks_path, :force => true).upload_cookbooks
|
176
176
|
$logger.debug { "::Chef::CookbookUploader(#{name}) UPLOADED" }
|
177
177
|
end
|
178
178
|
#@command.knife([ "cookbook upload cucumber-chef", "-o", @cookbooks_path ], :silence => true)
|
@@ -94,17 +94,41 @@ Then /^I should( not)? see the "([^\"]*)" of "([^\"]*)" in the output$/ do |bool
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
Then /^path "([^\"]*)" should exist$/ do |
|
98
|
-
parent = File.dirname
|
99
|
-
child = File.basename
|
97
|
+
Then /^(path|directory|file|symlink) "([^\"]*)" should exist$/ do |type, path|
|
98
|
+
parent = File.dirname path
|
99
|
+
child = File.basename path
|
100
100
|
command = "ls %s" % [
|
101
101
|
parent
|
102
102
|
]
|
103
103
|
@output = @connection.exec!(command)
|
104
104
|
@output.should =~ /#{child}/
|
105
|
+
|
106
|
+
# if a specific type (directory|file) was specified, test for it
|
107
|
+
command = "stat -c %%F %s" % [
|
108
|
+
path
|
109
|
+
]
|
110
|
+
@output = @connection.exec!(command)
|
111
|
+
types = {
|
112
|
+
"file" => /regular file/,
|
113
|
+
"directory" => /directory/,
|
114
|
+
"symlink" => /symbolic link/
|
115
|
+
}
|
116
|
+
|
117
|
+
if types.keys.include? type
|
118
|
+
@output.should =~ types[type]
|
119
|
+
end
|
120
|
+
# if type == "file"
|
121
|
+
# @output.should =~ /regular file/
|
122
|
+
# end
|
123
|
+
# if type == "directory"
|
124
|
+
# @output.should =~ /directory/
|
125
|
+
# end
|
126
|
+
# if type == "symlink"
|
127
|
+
# @output.should =~ /symbolic link/
|
128
|
+
# end
|
105
129
|
end
|
106
130
|
|
107
|
-
Then /^path "([^\"]*)" should be owned by "([^\"]*)"$/ do |path, owner|
|
131
|
+
Then /^(?:path|directory|file) "([^\"]*)" should be owned by "([^\"]*)"$/ do |path, owner|
|
108
132
|
command = "stat -c %%U:%%G %s" % [
|
109
133
|
path
|
110
134
|
]
|
@@ -112,15 +136,44 @@ Then /^path "([^\"]*)" should be owned by "([^\"]*)"$/ do |path, owner|
|
|
112
136
|
@output.should =~ /#{owner}/
|
113
137
|
end
|
114
138
|
|
115
|
-
|
139
|
+
# we can now match multi-line strings. We want to match *contiguous lines*
|
140
|
+
Then /^file "([^\"]*)" should( not)? contain/ do |path, boolean, content|
|
116
141
|
command = "cat %s" % [
|
117
142
|
path
|
118
143
|
]
|
119
|
-
|
144
|
+
|
145
|
+
# turn the command-line output and the expectation string into Arrays and strip
|
146
|
+
# leading and trailing cruft from members
|
147
|
+
@output = @connection.exec!(command).split("\n").map{ |i| i.strip }
|
148
|
+
content = content.split("\n").map{ |i| i.strip }
|
149
|
+
|
150
|
+
# assume no match
|
151
|
+
match = false
|
152
|
+
count = 0
|
153
|
+
|
154
|
+
# step through the command output array
|
155
|
+
while count < @output.length
|
156
|
+
current = @output[count]
|
157
|
+
|
158
|
+
# if we get a match with the start of the expectation
|
159
|
+
if @output[count] == content[0]
|
160
|
+
|
161
|
+
# take a slice of the same size as that expectation
|
162
|
+
slice = @output[count..count + content.length - 1]
|
163
|
+
|
164
|
+
# and see if they match
|
165
|
+
if content == slice
|
166
|
+
match = true
|
167
|
+
end
|
168
|
+
end
|
169
|
+
count += 1
|
170
|
+
end
|
171
|
+
|
172
|
+
# there's a neater way to express this logic, but it's 17:30 and I'm going home
|
120
173
|
if (!boolean)
|
121
|
-
|
174
|
+
match.should == true
|
122
175
|
else
|
123
|
-
|
176
|
+
match.should == false
|
124
177
|
end
|
125
178
|
end
|
126
179
|
|
@@ -136,3 +189,25 @@ Then /^package "([^\"]*)" should be installed$/ do |package|
|
|
136
189
|
@output = @connection.exec!(command)
|
137
190
|
@output.should =~ /#{package}/
|
138
191
|
end
|
192
|
+
|
193
|
+
# This regex is a little ugly, but it's so we can accept any of these
|
194
|
+
#
|
195
|
+
# * "foo" is running
|
196
|
+
# * service "foo" is running
|
197
|
+
# * application "foo" is running
|
198
|
+
# * process "foo" is running
|
199
|
+
#
|
200
|
+
# basically because I couldn't decide what they should be called. Maybe there's
|
201
|
+
# an Official Cucumber-chef Opinion on this. Still, Rubular is fun :)
|
202
|
+
|
203
|
+
# TiL that in Ruby regexes, "?:" marks a non-capturing group, which is how this
|
204
|
+
# works
|
205
|
+
Then /^(?:(?:service|application|process)? )?"([^\"]*)" should( not)? be running$/ do |service, boolean|
|
206
|
+
command = "ps ax"
|
207
|
+
@output = @connection.exec!(command)
|
208
|
+
if (!boolean)
|
209
|
+
@output.should =~ /#{service}/
|
210
|
+
else
|
211
|
+
@output.should_not =~ /#{service}/
|
212
|
+
end
|
213
|
+
end
|
@@ -24,7 +24,7 @@ module Cucumber
|
|
24
24
|
|
25
25
|
################################################################################
|
26
26
|
|
27
|
-
VERSION = "2.0.3
|
27
|
+
VERSION = "2.0.3" unless const_defined?(:VERSION)
|
28
28
|
|
29
29
|
################################################################################
|
30
30
|
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.3
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.3
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Stephen Nelson-Smith
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-09-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: chef
|