chefspec 2.0.1 → 3.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chefspec.rb +30 -44
- data/lib/chefspec/api.rb +74 -0
- data/lib/chefspec/api/apt_package.rb +192 -0
- data/lib/chefspec/api/batch.rb +43 -0
- data/lib/chefspec/api/chef_gem.rb +191 -0
- data/lib/chefspec/api/cookbook_file.rb +166 -0
- data/lib/chefspec/api/cron.rb +80 -0
- data/lib/chefspec/api/deploy.rb +117 -0
- data/lib/chefspec/api/directory.rb +80 -0
- data/lib/chefspec/api/dpkg_package.rb +117 -0
- data/lib/chefspec/api/easy_install_package.rb +154 -0
- data/lib/chefspec/api/env.rb +117 -0
- data/lib/chefspec/api/erl_call.rb +43 -0
- data/lib/chefspec/api/execute.rb +43 -0
- data/lib/chefspec/api/file.rb +166 -0
- data/lib/chefspec/api/freebsd_package.rb +80 -0
- data/lib/chefspec/api/gem_package.rb +191 -0
- data/lib/chefspec/api/git.rb +117 -0
- data/lib/chefspec/api/group.rb +154 -0
- data/lib/chefspec/api/http_request.rb +228 -0
- data/lib/chefspec/api/ifconfig.rb +154 -0
- data/lib/chefspec/api/include_recipe.rb +26 -0
- data/lib/chefspec/api/ips_package.rb +117 -0
- data/lib/chefspec/api/link.rb +102 -0
- data/lib/chefspec/api/log.rb +43 -0
- data/lib/chefspec/api/macports_package.rb +154 -0
- data/lib/chefspec/api/mdadm.rb +117 -0
- data/lib/chefspec/api/mount.rb +192 -0
- data/lib/chefspec/api/notifications.rb +38 -0
- data/lib/chefspec/api/ohai.rb +43 -0
- data/lib/chefspec/api/package.rb +192 -0
- data/lib/chefspec/api/pacman_package.rb +155 -0
- data/lib/chefspec/api/portage_package.rb +155 -0
- data/lib/chefspec/api/powershell_script.rb +43 -0
- data/lib/chefspec/api/registry_key.rb +166 -0
- data/lib/chefspec/api/remote_directory.rb +120 -0
- data/lib/chefspec/api/remote_file.rb +166 -0
- data/lib/chefspec/api/render_file.rb +32 -0
- data/lib/chefspec/api/route.rb +80 -0
- data/lib/chefspec/api/rpm_package.rb +117 -0
- data/lib/chefspec/api/ruby_block.rb +37 -0
- data/lib/chefspec/api/script.rb +228 -0
- data/lib/chefspec/api/service.rb +246 -0
- data/lib/chefspec/api/smartos_package.rb +117 -0
- data/lib/chefspec/api/solaris_package.rb +80 -0
- data/lib/chefspec/api/subversion.rb +154 -0
- data/lib/chefspec/api/template.rb +166 -0
- data/lib/chefspec/api/user.rb +228 -0
- data/lib/chefspec/api/yum_package.rb +154 -0
- data/lib/chefspec/berkshelf.rb +37 -0
- data/lib/chefspec/deprecations.rb +151 -0
- data/lib/chefspec/errors.rb +99 -0
- data/lib/chefspec/expect_exception.rb +45 -0
- data/lib/chefspec/extensions/chef/client.rb +15 -0
- data/lib/chefspec/extensions/chef/conditional.rb +11 -0
- data/lib/chefspec/extensions/chef/data_query.rb +29 -0
- data/lib/chefspec/extensions/chef/lwrp_base.rb +44 -0
- data/lib/chefspec/extensions/chef/resource.rb +27 -0
- data/lib/chefspec/extensions/chef/securable.rb +19 -0
- data/lib/chefspec/formatter.rb +270 -0
- data/lib/chefspec/macros.rb +217 -0
- data/lib/chefspec/matchers.rb +9 -0
- data/lib/chefspec/matchers/include_recipe_matcher.rb +45 -0
- data/lib/chefspec/matchers/link_to_matcher.rb +28 -0
- data/lib/chefspec/matchers/notifications_matcher.rb +92 -0
- data/lib/chefspec/matchers/render_file_matcher.rb +72 -0
- data/lib/chefspec/matchers/resource_matcher.rb +143 -0
- data/lib/chefspec/renderer.rb +137 -0
- data/lib/chefspec/rspec.rb +17 -0
- data/lib/chefspec/runner.rb +274 -0
- data/lib/chefspec/stubs/command_registry.rb +11 -0
- data/lib/chefspec/stubs/command_stub.rb +37 -0
- data/lib/chefspec/stubs/data_bag_item_registry.rb +13 -0
- data/lib/chefspec/stubs/data_bag_item_stub.rb +25 -0
- data/lib/chefspec/stubs/data_bag_registry.rb +13 -0
- data/lib/chefspec/stubs/data_bag_stub.rb +23 -0
- data/lib/chefspec/stubs/registry.rb +32 -0
- data/lib/chefspec/stubs/search_registry.rb +13 -0
- data/lib/chefspec/stubs/search_stub.rb +25 -0
- data/lib/chefspec/stubs/stub.rb +37 -0
- data/lib/chefspec/version.rb +1 -2
- metadata +100 -103
- data/lib/chef/expect_exception.rb +0 -34
- data/lib/chef/formatters/chefspec.rb +0 -233
- data/lib/chef/knife/cookbook_create_specs.rb +0 -107
- data/lib/chefspec/chef_runner.rb +0 -275
- data/lib/chefspec/helpers/describe.rb +0 -17
- data/lib/chefspec/matchers/cron.rb +0 -7
- data/lib/chefspec/matchers/env.rb +0 -8
- data/lib/chefspec/matchers/execute.rb +0 -33
- data/lib/chefspec/matchers/file.rb +0 -83
- data/lib/chefspec/matchers/file_content.rb +0 -32
- data/lib/chefspec/matchers/group.rb +0 -8
- data/lib/chefspec/matchers/include_recipe.rb +0 -20
- data/lib/chefspec/matchers/link.rb +0 -14
- data/lib/chefspec/matchers/log.rb +0 -21
- data/lib/chefspec/matchers/notifications.rb +0 -43
- data/lib/chefspec/matchers/package.rb +0 -39
- data/lib/chefspec/matchers/python.rb +0 -7
- data/lib/chefspec/matchers/ruby_block.rb +0 -13
- data/lib/chefspec/matchers/script.rb +0 -34
- data/lib/chefspec/matchers/service.rb +0 -25
- data/lib/chefspec/matchers/shared.rb +0 -132
- data/lib/chefspec/matchers/user.rb +0 -8
- data/lib/chefspec/minitest.rb +0 -195
- data/lib/chefspec/monkey_patches/conditional.rb +0 -19
- data/lib/chefspec/monkey_patches/hash.rb +0 -23
- data/lib/chefspec/monkey_patches/lwrp_base.rb +0 -45
- data/lib/chefspec/monkey_patches/provider.rb +0 -43
@@ -0,0 +1,228 @@
|
|
1
|
+
module ChefSpec::API
|
2
|
+
# @since 3.0.0
|
3
|
+
module HttpRequestMatchers
|
4
|
+
ChefSpec::Runner.define_runner_method :http_request
|
5
|
+
|
6
|
+
#
|
7
|
+
# Assert that an +http_request+ resource exists in the Chef run with the
|
8
|
+
# action +:delete+. Given a Chef Recipe that deletes "apache2" as an
|
9
|
+
# +http_request+:
|
10
|
+
#
|
11
|
+
# http_request 'apache2' do
|
12
|
+
# action :delete
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# The Examples section demonstrates the different ways to test an
|
16
|
+
# +http_request+ resource with ChefSpec.
|
17
|
+
#
|
18
|
+
# @example Assert that an +http_request+ was DELETE
|
19
|
+
# expect(chef_run).to delete_http_request('apache2')
|
20
|
+
#
|
21
|
+
# @example Assert that an +http_request+ was DELETE with predicate matchers
|
22
|
+
# expect(chef_run).to delete_http_request('apache2').with_message('hello')
|
23
|
+
#
|
24
|
+
# @example Assert that an +http_request+ was DELETE with attributes
|
25
|
+
# expect(chef_run).to delete_http_request('apache2').with(message: 'hello')
|
26
|
+
#
|
27
|
+
# @example Assert that an +http_request+ was DELETE using a regex
|
28
|
+
# expect(chef_run).to delete_http_request('apache2').with(message: /he(.+)/)
|
29
|
+
#
|
30
|
+
# @example Assert that an +http_request+ was _not_ DELETE
|
31
|
+
# expect(chef_run).to_not delete_http_request('apache2')
|
32
|
+
#
|
33
|
+
#
|
34
|
+
# @param [String, Regex] resource_name
|
35
|
+
# the name of the resource to match
|
36
|
+
#
|
37
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
38
|
+
#
|
39
|
+
def delete_http_request(resource_name)
|
40
|
+
ChefSpec::Matchers::ResourceMatcher.new(:http_request, :delete, resource_name)
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Assert that an +http_request+ resource exists in the Chef run with the
|
45
|
+
# action +:get+. Given a Chef Recipe that gets "apache2" as an
|
46
|
+
# +http_request+:
|
47
|
+
#
|
48
|
+
# http_request 'apache2' do
|
49
|
+
# action :get
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# The Examples section demonstrates the different ways to test an
|
53
|
+
# +http_request+ resource with ChefSpec.
|
54
|
+
#
|
55
|
+
# @example Assert that an +http_request+ was GET
|
56
|
+
# expect(chef_run).to get_http_request('apache2')
|
57
|
+
#
|
58
|
+
# @example Assert that an +http_request+ was GET with predicate matchers
|
59
|
+
# expect(chef_run).to get_http_request('apache2').with_message('hello')
|
60
|
+
#
|
61
|
+
# @example Assert that an +http_request+ was GET with attributes
|
62
|
+
# expect(chef_run).to get_http_request('apache2').with(message: 'hello')
|
63
|
+
#
|
64
|
+
# @example Assert that an +http_request+ was GET using a regex
|
65
|
+
# expect(chef_run).to get_http_request('apache2').with(message: /he(.+)/)
|
66
|
+
#
|
67
|
+
# @example Assert that an +http_request+ was _not_ GET
|
68
|
+
# expect(chef_run).to_not get_http_request('apache2')
|
69
|
+
#
|
70
|
+
#
|
71
|
+
# @param [String, Regex] resource_name
|
72
|
+
# the name of the resource to match
|
73
|
+
#
|
74
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
75
|
+
#
|
76
|
+
def get_http_request(resource_name)
|
77
|
+
ChefSpec::Matchers::ResourceMatcher.new(:http_request, :get, resource_name)
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Assert that an +http_request+ resource exists in the Chef run with the
|
82
|
+
# action +:head+. Given a Chef Recipe that heads "apache2" as an
|
83
|
+
# +http_request+:
|
84
|
+
#
|
85
|
+
# http_request 'apache2' do
|
86
|
+
# action :head
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
# The Examples section demonstrates the different ways to test an
|
90
|
+
# +http_request+ resource with ChefSpec.
|
91
|
+
#
|
92
|
+
# @example Assert that an +http_request+ was HEAD
|
93
|
+
# expect(chef_run).to head_http_request('apache2')
|
94
|
+
#
|
95
|
+
# @example Assert that an +http_request+ was HEAD with predicate matchers
|
96
|
+
# expect(chef_run).to head_http_request('apache2').with_message('hello')
|
97
|
+
#
|
98
|
+
# @example Assert that an +http_request+ was HEAD with attributes
|
99
|
+
# expect(chef_run).to head_http_request('apache2').with(message: 'hello')
|
100
|
+
#
|
101
|
+
# @example Assert that an +http_request+ was HEAD using a regex
|
102
|
+
# expect(chef_run).to head_http_request('apache2').with(message: /he(.+)/)
|
103
|
+
#
|
104
|
+
# @example Assert that an +http_request+ was _not_ HEAD
|
105
|
+
# expect(chef_run).to_not head_http_request('apache2')
|
106
|
+
#
|
107
|
+
#
|
108
|
+
# @param [String, Regex] resource_name
|
109
|
+
# the name of the resource to match
|
110
|
+
#
|
111
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
112
|
+
#
|
113
|
+
def head_http_request(resource_name)
|
114
|
+
ChefSpec::Matchers::ResourceMatcher.new(:http_request, :head, resource_name)
|
115
|
+
end
|
116
|
+
|
117
|
+
#
|
118
|
+
# Assert that an +http_request+ resource exists in the Chef run with the
|
119
|
+
# action +:options+. Given a Chef Recipe that optionss "apache2" as an
|
120
|
+
# +http_request+:
|
121
|
+
#
|
122
|
+
# http_request 'apache2' do
|
123
|
+
# action :options
|
124
|
+
# end
|
125
|
+
#
|
126
|
+
# The Examples section demonstrates the different ways to test an
|
127
|
+
# +http_request+ resource with ChefSpec.
|
128
|
+
#
|
129
|
+
# @example Assert that an +http_request+ was OPTIONS
|
130
|
+
# expect(chef_run).to options_http_request('apache2')
|
131
|
+
#
|
132
|
+
# @example Assert that an +http_request+ was OPTIONS with predicate matchers
|
133
|
+
# expect(chef_run).to options_http_request('apache2').with_message('hello')
|
134
|
+
#
|
135
|
+
# @example Assert that an +http_request+ was OPTIONS with attributes
|
136
|
+
# expect(chef_run).to options_http_request('apache2').with(message: 'hello')
|
137
|
+
#
|
138
|
+
# @example Assert that an +http_request+ was OPTIONS using a regex
|
139
|
+
# expect(chef_run).to options_http_request('apache2').with(message: /he(.+)/)
|
140
|
+
#
|
141
|
+
# @example Assert that an +http_request+ was _not_ OPTIONS
|
142
|
+
# expect(chef_run).to_not options_http_request('apache2')
|
143
|
+
#
|
144
|
+
#
|
145
|
+
# @param [String, Regex] resource_name
|
146
|
+
# the name of the resource to match
|
147
|
+
#
|
148
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
149
|
+
#
|
150
|
+
def options_http_request(resource_name)
|
151
|
+
ChefSpec::Matchers::ResourceMatcher.new(:http_request, :options, resource_name)
|
152
|
+
end
|
153
|
+
|
154
|
+
#
|
155
|
+
# Assert that an +http_request+ resource exists in the Chef run with the
|
156
|
+
# action +:post+. Given a Chef Recipe that posts "apache2" as an
|
157
|
+
# +http_request+:
|
158
|
+
#
|
159
|
+
# http_request 'apache2' do
|
160
|
+
# action :post
|
161
|
+
# end
|
162
|
+
#
|
163
|
+
# The Examples section demonstrates the different ways to test an
|
164
|
+
# +http_request+ resource with ChefSpec.
|
165
|
+
#
|
166
|
+
# @example Assert that an +http_request+ was POST
|
167
|
+
# expect(chef_run).to post_http_request('apache2')
|
168
|
+
#
|
169
|
+
# @example Assert that an +http_request+ was POST with predicate matchers
|
170
|
+
# expect(chef_run).to post_http_request('apache2').with_message('hello')
|
171
|
+
#
|
172
|
+
# @example Assert that an +http_request+ was POST with attributes
|
173
|
+
# expect(chef_run).to post_http_request('apache2').with(message: 'hello')
|
174
|
+
#
|
175
|
+
# @example Assert that an +http_request+ was POST using a regex
|
176
|
+
# expect(chef_run).to post_http_request('apache2').with(message: /he(.+)/)
|
177
|
+
#
|
178
|
+
# @example Assert that an +http_request+ was _not_ POST
|
179
|
+
# expect(chef_run).to_not post_http_request('apache2')
|
180
|
+
#
|
181
|
+
#
|
182
|
+
# @param [String, Regex] resource_name
|
183
|
+
# the name of the resource to match
|
184
|
+
#
|
185
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
186
|
+
#
|
187
|
+
def post_http_request(resource_name)
|
188
|
+
ChefSpec::Matchers::ResourceMatcher.new(:http_request, :post, resource_name)
|
189
|
+
end
|
190
|
+
|
191
|
+
#
|
192
|
+
# Assert that an +http_request+ resource exists in the Chef run with the
|
193
|
+
# action +:put+. Given a Chef Recipe that puts "apache2" as an
|
194
|
+
# +http_request+:
|
195
|
+
#
|
196
|
+
# http_request 'apache2' do
|
197
|
+
# action :put
|
198
|
+
# end
|
199
|
+
#
|
200
|
+
# The Examples section demonstrates the different ways to test an
|
201
|
+
# +http_request+ resource with ChefSpec.
|
202
|
+
#
|
203
|
+
# @example Assert that an +http_request+ was PUT
|
204
|
+
# expect(chef_run).to put_http_request('apache2')
|
205
|
+
#
|
206
|
+
# @example Assert that an +http_request+ was PUT with predicate matchers
|
207
|
+
# expect(chef_run).to put_http_request('apache2').with_message('hello')
|
208
|
+
#
|
209
|
+
# @example Assert that an +http_request+ was PUT with attributes
|
210
|
+
# expect(chef_run).to put_http_request('apache2').with(message: 'hello')
|
211
|
+
#
|
212
|
+
# @example Assert that an +http_request+ was PUT using a regex
|
213
|
+
# expect(chef_run).to put_http_request('apache2').with(message: /he(.+)/)
|
214
|
+
#
|
215
|
+
# @example Assert that an +http_request+ was _not_ PUT
|
216
|
+
# expect(chef_run).to_not put_http_request('apache2')
|
217
|
+
#
|
218
|
+
#
|
219
|
+
# @param [String, Regex] resource_name
|
220
|
+
# the name of the resource to match
|
221
|
+
#
|
222
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
223
|
+
#
|
224
|
+
def put_http_request(resource_name)
|
225
|
+
ChefSpec::Matchers::ResourceMatcher.new(:http_request, :put, resource_name)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
module ChefSpec::API
|
2
|
+
# @since 3.0.0
|
3
|
+
module IfconfigMatchers
|
4
|
+
ChefSpec::Runner.define_runner_method :ifconfig
|
5
|
+
|
6
|
+
#
|
7
|
+
# Assert that an +ifconfig+ resource exists in the Chef run with the
|
8
|
+
# action +:add+. Given a Chef Recipe that adds "10.0.0.1" as an
|
9
|
+
# +ifconfig+:
|
10
|
+
#
|
11
|
+
# ifconfig '10.0.0.1' do
|
12
|
+
# action :add
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# The Examples section demonstrates the different ways to test an
|
16
|
+
# +ifconfig+ resource with ChefSpec.
|
17
|
+
#
|
18
|
+
# @example Assert that an +ifconfig+ was added
|
19
|
+
# expect(chef_run).to add_ifconfig('10.0.0.1')
|
20
|
+
#
|
21
|
+
# @example Assert that an +ifconfig+ was added with predicate matchers
|
22
|
+
# expect(chef_run).to add_ifconfig('10.0.0.1').with_device('eth0')
|
23
|
+
#
|
24
|
+
# @example Assert that an +ifconfig+ was added with attributes
|
25
|
+
# expect(chef_run).to add_ifconfig('10.0.0.1').with(device: 'eth0')
|
26
|
+
#
|
27
|
+
# @example Assert that an +ifconfig+ was added using a regex
|
28
|
+
# expect(chef_run).to add_ifconfig('10.0.0.1').with(device: /eth(\d+)/)
|
29
|
+
#
|
30
|
+
# @example Assert that an +ifconfig+ was _not_ added
|
31
|
+
# expect(chef_run).to_not add_ifconfig('10.0.0.1')
|
32
|
+
#
|
33
|
+
#
|
34
|
+
# @param [String, Regex] resource_name
|
35
|
+
# the name of the resource to match
|
36
|
+
#
|
37
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
38
|
+
#
|
39
|
+
def add_ifconfig(resource_name)
|
40
|
+
ChefSpec::Matchers::ResourceMatcher.new(:ifconfig, :add, resource_name)
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Assert that an +ifconfig+ resource exists in the Chef run with the
|
45
|
+
# action +:delete+. Given a Chef Recipe that deletes "10.0.0.1" as an
|
46
|
+
# +ifconfig+:
|
47
|
+
#
|
48
|
+
# ifconfig '10.0.0.1' do
|
49
|
+
# action :delete
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# The Examples section demonstrates the different ways to test an
|
53
|
+
# +ifconfig+ resource with ChefSpec.
|
54
|
+
#
|
55
|
+
# @example Assert that an +ifconfig+ was deleted
|
56
|
+
# expect(chef_run).to delete_ifconfig('10.0.0.1')
|
57
|
+
#
|
58
|
+
# @example Assert that an +ifconfig+ was deleted with predicate matchers
|
59
|
+
# expect(chef_run).to delete_ifconfig('10.0.0.1').with_device('eth0')
|
60
|
+
#
|
61
|
+
# @example Assert that an +ifconfig+ was deleted with attributes
|
62
|
+
# expect(chef_run).to delete_ifconfig('10.0.0.1').with(device: 'eth0')
|
63
|
+
#
|
64
|
+
# @example Assert that an +ifconfig+ was deleted using a regex
|
65
|
+
# expect(chef_run).to delete_ifconfig('10.0.0.1').with(device: /eth(\d+)/)
|
66
|
+
#
|
67
|
+
# @example Assert that an +ifconfig+ was _not_ deleted
|
68
|
+
# expect(chef_run).to_not delete_ifconfig('10.0.0.1')
|
69
|
+
#
|
70
|
+
#
|
71
|
+
# @param [String, Regex] resource_name
|
72
|
+
# the name of the resource to match
|
73
|
+
#
|
74
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
75
|
+
#
|
76
|
+
def delete_ifconfig(resource_name)
|
77
|
+
ChefSpec::Matchers::ResourceMatcher.new(:ifconfig, :delete, resource_name)
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Assert that an +ifconfig+ resource exists in the Chef run with the
|
82
|
+
# action +:disable+. Given a Chef Recipe that disables "10.0.0.1" as an
|
83
|
+
# +ifconfig+:
|
84
|
+
#
|
85
|
+
# ifconfig '10.0.0.1' do
|
86
|
+
# action :disable
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
# The Examples section demonstrates the different ways to test an
|
90
|
+
# +ifconfig+ resource with ChefSpec.
|
91
|
+
#
|
92
|
+
# @example Assert that an +ifconfig+ was disabled
|
93
|
+
# expect(chef_run).to disable_ifconfig('10.0.0.1')
|
94
|
+
#
|
95
|
+
# @example Assert that an +ifconfig+ was disabled with predicate matchers
|
96
|
+
# expect(chef_run).to disable_ifconfig('10.0.0.1').with_device('eth0')
|
97
|
+
#
|
98
|
+
# @example Assert that an +ifconfig+ was disabled with attributes
|
99
|
+
# expect(chef_run).to disable_ifconfig('10.0.0.1').with(device: 'eth0')
|
100
|
+
#
|
101
|
+
# @example Assert that an +ifconfig+ was disabled using a regex
|
102
|
+
# expect(chef_run).to disable_ifconfig('10.0.0.1').with(device: /eth(\d+)/)
|
103
|
+
#
|
104
|
+
# @example Assert that an +ifconfig+ was _not_ disabled
|
105
|
+
# expect(chef_run).to_not disable_ifconfig('10.0.0.1')
|
106
|
+
#
|
107
|
+
#
|
108
|
+
# @param [String, Regex] resource_name
|
109
|
+
# the name of the resource to match
|
110
|
+
#
|
111
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
112
|
+
#
|
113
|
+
def disable_ifconfig(resource_name)
|
114
|
+
ChefSpec::Matchers::ResourceMatcher.new(:ifconfig, :disable, resource_name)
|
115
|
+
end
|
116
|
+
|
117
|
+
#
|
118
|
+
# Assert that an +ifconfig+ resource exists in the Chef run with the
|
119
|
+
# action +:enable+. Given a Chef Recipe that enables "10.0.0.1" as an
|
120
|
+
# +ifconfig+:
|
121
|
+
#
|
122
|
+
# ifconfig '10.0.0.1' do
|
123
|
+
# action :enable
|
124
|
+
# end
|
125
|
+
#
|
126
|
+
# The Examples section demonstrates the different ways to test an
|
127
|
+
# +ifconfig+ resource with ChefSpec.
|
128
|
+
#
|
129
|
+
# @example Assert that an +ifconfig+ was enabled
|
130
|
+
# expect(chef_run).to enable_ifconfig('10.0.0.1')
|
131
|
+
#
|
132
|
+
# @example Assert that an +ifconfig+ was enabled with predicate matchers
|
133
|
+
# expect(chef_run).to enable_ifconfig('10.0.0.1').with_device('eth0')
|
134
|
+
#
|
135
|
+
# @example Assert that an +ifconfig+ was enabled with attributes
|
136
|
+
# expect(chef_run).to enable_ifconfig('10.0.0.1').with(device: 'eth0')
|
137
|
+
#
|
138
|
+
# @example Assert that an +ifconfig+ was enabled using a regex
|
139
|
+
# expect(chef_run).to enable_ifconfig('10.0.0.1').with(device: /eth(\d+)/)
|
140
|
+
#
|
141
|
+
# @example Assert that an +ifconfig+ was _not_ enabled
|
142
|
+
# expect(chef_run).to_not enable_ifconfig('10.0.0.1')
|
143
|
+
#
|
144
|
+
#
|
145
|
+
# @param [String, Regex] resource_name
|
146
|
+
# the name of the resource to match
|
147
|
+
#
|
148
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
149
|
+
#
|
150
|
+
def enable_ifconfig(resource_name)
|
151
|
+
ChefSpec::Matchers::ResourceMatcher.new(:ifconfig, :enable, resource_name)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ChefSpec::API
|
2
|
+
# @since 0.2.1
|
3
|
+
module IncludeRecipeMatchers
|
4
|
+
#
|
5
|
+
# Assert that a Chef run includes a certain recipe. Given a Chef Recipe
|
6
|
+
# that calls +include_recipe+:
|
7
|
+
#
|
8
|
+
# include_recipe 'apache2::default'
|
9
|
+
#
|
10
|
+
# The Examples section demonstrates the different ways to test an
|
11
|
+
# +include_recipe+ directive with ChefSpec.
|
12
|
+
#
|
13
|
+
# @example Assert the +apache2::default+ recipe is included in the Chef run
|
14
|
+
# expect(chef_run).to include_recipe('apache2::default')
|
15
|
+
#
|
16
|
+
#
|
17
|
+
# @param [String] recipe_name
|
18
|
+
# the name of the recipe to be included
|
19
|
+
#
|
20
|
+
# @return [ChefSpec::Matchers::IncludeRecipeMatcher]
|
21
|
+
#
|
22
|
+
def include_recipe(recipe_name)
|
23
|
+
ChefSpec::Matchers::IncludeRecipeMatcher.new(recipe_name)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
module ChefSpec::API
|
2
|
+
# @since 3.0.0
|
3
|
+
module IpsPackageMatchers
|
4
|
+
ChefSpec::Runner.define_runner_method :ips_package
|
5
|
+
|
6
|
+
#
|
7
|
+
# Assert that an +ips_package+ resource exists in the Chef run with the
|
8
|
+
# action +:install+. Given a Chef Recipe that installs "apache2" as an
|
9
|
+
# +ips_package+:
|
10
|
+
#
|
11
|
+
# ips_package 'apache2' do
|
12
|
+
# action :install
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# The Examples section demonstrates the different ways to test an
|
16
|
+
# +ips_package+ resource with ChefSpec.
|
17
|
+
#
|
18
|
+
# @example Assert that an +ips_package+ was installed
|
19
|
+
# expect(chef_run).to install_ips_package('apache2')
|
20
|
+
#
|
21
|
+
# @example Assert that an +ips_package+ was installed with predicate matchers
|
22
|
+
# expect(chef_run).to install_ips_package('apache2').with_version('1.2.3')
|
23
|
+
#
|
24
|
+
# @example Assert that an +ips_package+ was installed with attributes
|
25
|
+
# expect(chef_run).to install_ips_package('apache2').with(version: '1.2.3')
|
26
|
+
#
|
27
|
+
# @example Assert that an +ips_package+ was installed using a regex
|
28
|
+
# expect(chef_run).to install_ips_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
29
|
+
#
|
30
|
+
# @example Assert that an +ips_package+ was _not_ installed
|
31
|
+
# expect(chef_run).to_not install_ips_package('apache2')
|
32
|
+
#
|
33
|
+
#
|
34
|
+
# @param [String, Regex] resource_name
|
35
|
+
# the name of the resource to match
|
36
|
+
#
|
37
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
38
|
+
#
|
39
|
+
def install_ips_package(resource_name)
|
40
|
+
ChefSpec::Matchers::ResourceMatcher.new(:ips_package, :install, resource_name)
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Assert that an +ips_package+ resource exists in the Chef run with the
|
45
|
+
# action +:remove+. Given a Chef Recipe that removes "apache2" as an
|
46
|
+
# +ips_package+:
|
47
|
+
#
|
48
|
+
# ips_package 'apache2' do
|
49
|
+
# action :remove
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# The Examples section demonstrates the different ways to test an
|
53
|
+
# +ips_package+ resource with ChefSpec.
|
54
|
+
#
|
55
|
+
# @example Assert that an +ips_package+ was removed
|
56
|
+
# expect(chef_run).to remove_ips_package('apache2')
|
57
|
+
#
|
58
|
+
# @example Assert that an +ips_package+ was removed with predicate matchers
|
59
|
+
# expect(chef_run).to remove_ips_package('apache2').with_version('1.2.3')
|
60
|
+
#
|
61
|
+
# @example Assert that an +ips_package+ was removed with attributes
|
62
|
+
# expect(chef_run).to remove_ips_package('apache2').with(version: '1.2.3')
|
63
|
+
#
|
64
|
+
# @example Assert that an +ips_package+ was removed using a regex
|
65
|
+
# expect(chef_run).to remove_ips_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
66
|
+
#
|
67
|
+
# @example Assert that an +ips_package+ was _not_ removed
|
68
|
+
# expect(chef_run).to_not remove_ips_package('apache2')
|
69
|
+
#
|
70
|
+
#
|
71
|
+
# @param [String, Regex] resource_name
|
72
|
+
# the name of the resource to match
|
73
|
+
#
|
74
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
75
|
+
#
|
76
|
+
def remove_ips_package(resource_name)
|
77
|
+
ChefSpec::Matchers::ResourceMatcher.new(:ips_package, :remove, resource_name)
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Assert that an +ips_package+ resource exists in the Chef run with the
|
82
|
+
# action +:upgrade+. Given a Chef Recipe that upgrades "apache2" as an
|
83
|
+
# +ips_package+:
|
84
|
+
#
|
85
|
+
# ips_package 'apache2' do
|
86
|
+
# action :upgrade
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
# The Examples section demonstrates the different ways to test an
|
90
|
+
# +ips_package+ resource with ChefSpec.
|
91
|
+
#
|
92
|
+
# @example Assert that an +ips_package+ was upgradeed
|
93
|
+
# expect(chef_run).to upgrade_ips_package('apache2')
|
94
|
+
#
|
95
|
+
# @example Assert that an +ips_package+ was upgradeed with predicate matchers
|
96
|
+
# expect(chef_run).to upgrade_ips_package('apache2').with_version('1.2.3')
|
97
|
+
#
|
98
|
+
# @example Assert that an +ips_package+ was upgradeed with attributes
|
99
|
+
# expect(chef_run).to upgrade_ips_package('apache2').with(version: '1.2.3')
|
100
|
+
#
|
101
|
+
# @example Assert that an +ips_package+ was upgradeed using a regex
|
102
|
+
# expect(chef_run).to upgrade_ips_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
103
|
+
#
|
104
|
+
# @example Assert that an +ips_package+ was _not_ upgradeed
|
105
|
+
# expect(chef_run).to_not upgrade_ips_package('apache2')
|
106
|
+
#
|
107
|
+
#
|
108
|
+
# @param [String, Regex] resource_name
|
109
|
+
# the name of the resource to match
|
110
|
+
#
|
111
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
112
|
+
#
|
113
|
+
def upgrade_ips_package(resource_name)
|
114
|
+
ChefSpec::Matchers::ResourceMatcher.new(:ips_package, :upgrade, resource_name)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|