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,38 @@
|
|
1
|
+
module ChefSpec::API
|
2
|
+
# @since 0.9.0
|
3
|
+
module NotificationsMatchers
|
4
|
+
#
|
5
|
+
# Assert that a resource notifies another. Given a Chef Recipe that
|
6
|
+
# notifies a template resource to restart apache:
|
7
|
+
#
|
8
|
+
# ifconfig '10.0.0.1' do
|
9
|
+
# action :add
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# The Examples section demonstrates the different ways to test an
|
13
|
+
# +ifconfig+ resource with ChefSpec.
|
14
|
+
#
|
15
|
+
# @example Assert the template notifies apache of something
|
16
|
+
# template = chef_run.template('/etc/apache2.conf')
|
17
|
+
# expect(template).to notify('service[apache2]')
|
18
|
+
#
|
19
|
+
# @example Assert the template notifies apache to restart
|
20
|
+
# expect(template).to notify('service[apache2]').to(:restart)
|
21
|
+
#
|
22
|
+
# @example Assert the template notifies apache to restart immediately
|
23
|
+
# expect(template).to notify('service[apache2]').to(:restart).immediately
|
24
|
+
#
|
25
|
+
# @example Assert the template notifies apache to restart delayed
|
26
|
+
# expect(template).to notify('service[apache2]').to(:restart).delayed
|
27
|
+
#
|
28
|
+
#
|
29
|
+
# @param [String] signature
|
30
|
+
# the signature of the notification to match
|
31
|
+
#
|
32
|
+
# @return [ChefSpec::Matchers::NotificationsMatcher]
|
33
|
+
#
|
34
|
+
def notify(signature)
|
35
|
+
ChefSpec::Matchers::NotificationsMatcher.new(signature)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module ChefSpec::API
|
2
|
+
# @since 3.0.0
|
3
|
+
module OhaiMatchers
|
4
|
+
ChefSpec::Runner.define_runner_method :ohai
|
5
|
+
|
6
|
+
#
|
7
|
+
# Assert that an +ohai+ resource exists in the Chef run with the
|
8
|
+
# action +:reload+. Given a Chef Recipe that reloads "reload" as an
|
9
|
+
# +ohai+:
|
10
|
+
#
|
11
|
+
# ohai 'reload' do
|
12
|
+
# action :reload
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# The Examples section demonstrates the different ways to test an
|
16
|
+
# +ohai+ resource with ChefSpec.
|
17
|
+
#
|
18
|
+
# @example Assert that an +ohai+ was reloaded
|
19
|
+
# expect(chef_run).to reload_ohai('reload')
|
20
|
+
#
|
21
|
+
# @example Assert that an +ohai+ was reloaded with predicate matchers
|
22
|
+
# expect(chef_run).to reload_ohai('reload').with_system(true)
|
23
|
+
#
|
24
|
+
# @example Assert that an +ohai+ was reloaded with attributes
|
25
|
+
# expect(chef_run).to reload_ohai('reload').with(system: true)
|
26
|
+
#
|
27
|
+
# @example Assert that an +ohai+ was reloaded using a regex
|
28
|
+
# expect(chef_run).to reload_ohai('reload').with(system: Boolean)
|
29
|
+
#
|
30
|
+
# @example Assert that an +ohai+ was _not_ reloaded
|
31
|
+
# expect(chef_run).to_not reload_ohai('reload')
|
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 reload_ohai(resource_name)
|
40
|
+
ChefSpec::Matchers::ResourceMatcher.new(:ohai, :reload, resource_name)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
module ChefSpec::API
|
2
|
+
# @since 0.0.1
|
3
|
+
module PackageMatchers
|
4
|
+
ChefSpec::Runner.define_runner_method :package
|
5
|
+
|
6
|
+
#
|
7
|
+
# Assert that an +package+ resource exists in the Chef run with the
|
8
|
+
# action +:install+. Given a Chef Recipe that installs "apache2" as an
|
9
|
+
# +package+:
|
10
|
+
#
|
11
|
+
# package 'apache2' do
|
12
|
+
# action :install
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# The Examples section demonstrates the different ways to test an
|
16
|
+
# +package+ resource with ChefSpec.
|
17
|
+
#
|
18
|
+
# @example Assert that an +package+ was installed
|
19
|
+
# expect(chef_run).to install_package('apache2')
|
20
|
+
#
|
21
|
+
# @example Assert that an +package+ was installed with predicate matchers
|
22
|
+
# expect(chef_run).to install_package('apache2').with_version('1.2.3')
|
23
|
+
#
|
24
|
+
# @example Assert that an +package+ was installed with attributes
|
25
|
+
# expect(chef_run).to install_package('apache2').with(version: '1.2.3')
|
26
|
+
#
|
27
|
+
# @example Assert that an +package+ was installed using a regex
|
28
|
+
# expect(chef_run).to install_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
29
|
+
#
|
30
|
+
# @example Assert that an +package+ was _not_ installed
|
31
|
+
# expect(chef_run).to_not install_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_package(resource_name)
|
40
|
+
ChefSpec::Matchers::ResourceMatcher.new(:package, :install, resource_name)
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Assert that an +package+ resource exists in the Chef run with the
|
45
|
+
# action +:purge+. Given a Chef Recipe that purges "apache2" as an
|
46
|
+
# +package+:
|
47
|
+
#
|
48
|
+
# package 'apache2' do
|
49
|
+
# action :purge
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# The Examples section demonstrates the different ways to test an
|
53
|
+
# +package+ resource with ChefSpec.
|
54
|
+
#
|
55
|
+
# @example Assert that an +package+ was purged
|
56
|
+
# expect(chef_run).to purge_package('apache2')
|
57
|
+
#
|
58
|
+
# @example Assert that an +package+ was purged with predicate matchers
|
59
|
+
# expect(chef_run).to purge_package('apache2').with_version('1.2.3')
|
60
|
+
#
|
61
|
+
# @example Assert that an +package+ was purged with attributes
|
62
|
+
# expect(chef_run).to purge_package('apache2').with(version: '1.2.3')
|
63
|
+
#
|
64
|
+
# @example Assert that an +package+ was purged using a regex
|
65
|
+
# expect(chef_run).to purge_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
66
|
+
#
|
67
|
+
# @example Assert that an +package+ was _not_ purged
|
68
|
+
# expect(chef_run).to_not purge_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 purge_package(resource_name)
|
77
|
+
ChefSpec::Matchers::ResourceMatcher.new(:package, :purge, resource_name)
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Assert that an +package+ resource exists in the Chef run with the
|
82
|
+
# action +:reconfig+. Given a Chef Recipe that reconfigures "apache2" as an
|
83
|
+
# +package+:
|
84
|
+
#
|
85
|
+
# package 'apache2' do
|
86
|
+
# action :reconfig
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
# The Examples section demonstrates the different ways to test an
|
90
|
+
# +package+ resource with ChefSpec.
|
91
|
+
#
|
92
|
+
# @example Assert that an +package+ was reconfigured
|
93
|
+
# expect(chef_run).to reconfig_package('apache2')
|
94
|
+
#
|
95
|
+
# @example Assert that an +package+ was reconfigured with predicate matchers
|
96
|
+
# expect(chef_run).to reconfig_package('apache2').with_version('1.2.3')
|
97
|
+
#
|
98
|
+
# @example Assert that an +package+ was reconfigured with attributes
|
99
|
+
# expect(chef_run).to reconfig_package('apache2').with(version: '1.2.3')
|
100
|
+
#
|
101
|
+
# @example Assert that an +package+ was reconfigured using a regex
|
102
|
+
# expect(chef_run).to reconfig_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
103
|
+
#
|
104
|
+
# @example Assert that an +package+ was _not_ reconfigured
|
105
|
+
# expect(chef_run).to_not reconfig_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 reconfig_package(resource_name)
|
114
|
+
ChefSpec::Matchers::ResourceMatcher.new(:package, :reconfig, resource_name)
|
115
|
+
end
|
116
|
+
|
117
|
+
#
|
118
|
+
# Assert that an +package+ resource exists in the Chef run with the
|
119
|
+
# action +:remove+. Given a Chef Recipe that removes "apache2" as an
|
120
|
+
# +package+:
|
121
|
+
#
|
122
|
+
# package 'apache2' do
|
123
|
+
# action :remove
|
124
|
+
# end
|
125
|
+
#
|
126
|
+
# The Examples section demonstrates the different ways to test an
|
127
|
+
# +package+ resource with ChefSpec.
|
128
|
+
#
|
129
|
+
# @example Assert that an +package+ was removed
|
130
|
+
# expect(chef_run).to remove_package('apache2')
|
131
|
+
#
|
132
|
+
# @example Assert that an +package+ was removed with predicate matchers
|
133
|
+
# expect(chef_run).to remove_package('apache2').with_version('1.2.3')
|
134
|
+
#
|
135
|
+
# @example Assert that an +package+ was removed with attributes
|
136
|
+
# expect(chef_run).to remove_package('apache2').with(version: '1.2.3')
|
137
|
+
#
|
138
|
+
# @example Assert that an +package+ was removed using a regex
|
139
|
+
# expect(chef_run).to remove_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
140
|
+
#
|
141
|
+
# @example Assert that an +package+ was _not_ removed
|
142
|
+
# expect(chef_run).to_not remove_package('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 remove_package(resource_name)
|
151
|
+
ChefSpec::Matchers::ResourceMatcher.new(:package, :remove, resource_name)
|
152
|
+
end
|
153
|
+
|
154
|
+
#
|
155
|
+
# Assert that an +package+ resource exists in the Chef run with the
|
156
|
+
# action +:upgrade+. Given a Chef Recipe that upgrades "apache2" as an
|
157
|
+
# +package+:
|
158
|
+
#
|
159
|
+
# package 'apache2' do
|
160
|
+
# action :upgrade
|
161
|
+
# end
|
162
|
+
#
|
163
|
+
# The Examples section demonstrates the different ways to test an
|
164
|
+
# +package+ resource with ChefSpec.
|
165
|
+
#
|
166
|
+
# @example Assert that an +package+ was upgraded
|
167
|
+
# expect(chef_run).to upgrade_package('apache2')
|
168
|
+
#
|
169
|
+
# @example Assert that an +package+ was upgraded with predicate matchers
|
170
|
+
# expect(chef_run).to upgrade_package('apache2').with_version('1.2.3')
|
171
|
+
#
|
172
|
+
# @example Assert that an +package+ was upgraded with attributes
|
173
|
+
# expect(chef_run).to upgrade_package('apache2').with(version: '1.2.3')
|
174
|
+
#
|
175
|
+
# @example Assert that an +package+ was upgraded using a regex
|
176
|
+
# expect(chef_run).to upgrade_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
177
|
+
#
|
178
|
+
# @example Assert that an +package+ was _not_ upgraded
|
179
|
+
# expect(chef_run).to_not upgrade_package('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 upgrade_package(resource_name)
|
188
|
+
ChefSpec::Matchers::ResourceMatcher.new(:package, :upgrade, resource_name)
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
module ChefSpec::API
|
2
|
+
# @since 3.0.0
|
3
|
+
module PacmanPackageMatchers
|
4
|
+
ChefSpec::Runner.define_runner_method :pacman_package
|
5
|
+
|
6
|
+
#
|
7
|
+
# Assert that an +pacman_package+ resource exists in the Chef run with the
|
8
|
+
# action +:install+. Given a Chef Recipe that installs "apache2" as an
|
9
|
+
# +pacman_package+:
|
10
|
+
#
|
11
|
+
# pacman_package 'apache2' do
|
12
|
+
# action :install
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# The Examples section demonstrates the different ways to test an
|
16
|
+
# +pacman_package+ resource with ChefSpec.
|
17
|
+
#
|
18
|
+
# @example Assert that an +pacman_package+ was installed
|
19
|
+
# expect(chef_run).to install_pacman_package('apache2')
|
20
|
+
#
|
21
|
+
# @example Assert that an +pacman_package+ was installed with predicate matchers
|
22
|
+
# expect(chef_run).to install_pacman_package('apache2').with_version('1.2.3')
|
23
|
+
#
|
24
|
+
# @example Assert that an +pacman_package+ was installed with attributes
|
25
|
+
# expect(chef_run).to install_pacman_package('apache2').with(version: '1.2.3')
|
26
|
+
#
|
27
|
+
# @example Assert that an +pacman_package+ was installed using a regex
|
28
|
+
# expect(chef_run).to install_pacman_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
29
|
+
#
|
30
|
+
# @example Assert that an +pacman_package+ was _not_ installed
|
31
|
+
# expect(chef_run).to_not install_pacman_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_pacman_package(resource_name)
|
40
|
+
ChefSpec::Matchers::ResourceMatcher.new(:pacman_package, :install, resource_name)
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Assert that an +pacman_package+ resource exists in the Chef run with the
|
45
|
+
# action +:purge+. Given a Chef Recipe that purges "apache2" as an
|
46
|
+
# +pacman_package+:
|
47
|
+
#
|
48
|
+
# pacman_package 'apache2' do
|
49
|
+
# action :purge
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# The Examples section demonstrates the different ways to test an
|
53
|
+
# +pacman_package+ resource with ChefSpec.
|
54
|
+
#
|
55
|
+
# @example Assert that an +pacman_package+ was purged
|
56
|
+
# expect(chef_run).to purge_pacman_package('apache2')
|
57
|
+
#
|
58
|
+
# @example Assert that an +pacman_package+ was purged with predicate matchers
|
59
|
+
# expect(chef_run).to purge_pacman_package('apache2').with_version('1.2.3')
|
60
|
+
#
|
61
|
+
# @example Assert that an +pacman_package+ was purged with attributes
|
62
|
+
# expect(chef_run).to purge_pacman_package('apache2').with(version: '1.2.3')
|
63
|
+
#
|
64
|
+
# @example Assert that an +pacman_package+ was purged using a regex
|
65
|
+
# expect(chef_run).to purge_pacman_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
66
|
+
#
|
67
|
+
# @example Assert that an +pacman_package+ was _not_ purged
|
68
|
+
# expect(chef_run).to_not purge_pacman_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 purge_pacman_package(resource_name)
|
77
|
+
ChefSpec::Matchers::ResourceMatcher.new(:pacman_package, :purge, resource_name)
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Assert that an +pacman_package+ resource exists in the Chef run with the
|
82
|
+
# action +:remove+. Given a Chef Recipe that removes "apache2" as an
|
83
|
+
# +pacman_package+:
|
84
|
+
#
|
85
|
+
# pacman_package 'apache2' do
|
86
|
+
# action :remove
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
# The Examples section demonstrates the different ways to test an
|
90
|
+
# +pacman_package+ resource with ChefSpec.
|
91
|
+
#
|
92
|
+
# @example Assert that an +pacman_package+ was removed
|
93
|
+
# expect(chef_run).to remove_pacman_package('apache2')
|
94
|
+
#
|
95
|
+
# @example Assert that an +pacman_package+ was removed with predicate matchers
|
96
|
+
# expect(chef_run).to remove_pacman_package('apache2').with_version('1.2.3')
|
97
|
+
#
|
98
|
+
# @example Assert that an +pacman_package+ was removed with attributes
|
99
|
+
# expect(chef_run).to remove_pacman_package('apache2').with(version: '1.2.3')
|
100
|
+
#
|
101
|
+
# @example Assert that an +pacman_package+ was removed using a regex
|
102
|
+
# expect(chef_run).to remove_pacman_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
103
|
+
#
|
104
|
+
# @example Assert that an +pacman_package+ was _not_ removed
|
105
|
+
# expect(chef_run).to_not remove_pacman_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 remove_pacman_package(resource_name)
|
114
|
+
ChefSpec::Matchers::ResourceMatcher.new(:pacman_package, :remove, resource_name)
|
115
|
+
end
|
116
|
+
|
117
|
+
#
|
118
|
+
# Assert that an +pacman_package+ resource exists in the Chef run with the
|
119
|
+
# action +:upgrade+. Given a Chef Recipe that upgrades "apache2" as an
|
120
|
+
# +pacman_package+:
|
121
|
+
#
|
122
|
+
# pacman_package 'apache2' do
|
123
|
+
# action :upgrade
|
124
|
+
# end
|
125
|
+
#
|
126
|
+
# The Examples section demonstrates the different ways to test an
|
127
|
+
# +pacman_package+ resource with ChefSpec.
|
128
|
+
#
|
129
|
+
# @example Assert that an +pacman_package+ was upgraded
|
130
|
+
# expect(chef_run).to upgrade_pacman_package('apache2')
|
131
|
+
#
|
132
|
+
# @example Assert that an +pacman_package+ was upgraded with predicate matchers
|
133
|
+
# expect(chef_run).to upgrade_pacman_package('apache2').with_version('1.2.3')
|
134
|
+
#
|
135
|
+
# @example Assert that an +pacman_package+ was upgraded with attributes
|
136
|
+
# expect(chef_run).to upgrade_pacman_package('apache2').with(version: '1.2.3')
|
137
|
+
#
|
138
|
+
# @example Assert that an +pacman_package+ was upgraded using a regex
|
139
|
+
# expect(chef_run).to upgrade_pacman_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
140
|
+
#
|
141
|
+
# @example Assert that an +pacman_package+ was _not_ upgraded
|
142
|
+
# expect(chef_run).to_not upgrade_pacman_package('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 upgrade_pacman_package(resource_name)
|
151
|
+
ChefSpec::Matchers::ResourceMatcher.new(:pacman_package, :upgrade, resource_name)
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
module ChefSpec::API
|
2
|
+
# @since 3.0.0
|
3
|
+
module PortagePackageMatchers
|
4
|
+
ChefSpec::Runner.define_runner_method :portage_package
|
5
|
+
|
6
|
+
#
|
7
|
+
# Assert that an +portage_package+ resource exists in the Chef run with the
|
8
|
+
# action +:install+. Given a Chef Recipe that installs "apache2" as an
|
9
|
+
# +portage_package+:
|
10
|
+
#
|
11
|
+
# portage_package 'apache2' do
|
12
|
+
# action :install
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# The Examples section demonstrates the different ways to test an
|
16
|
+
# +portage_package+ resource with ChefSpec.
|
17
|
+
#
|
18
|
+
# @example Assert that an +portage_package+ was installed
|
19
|
+
# expect(chef_run).to install_portage_package('apache2')
|
20
|
+
#
|
21
|
+
# @example Assert that an +portage_package+ was installed with predicate matchers
|
22
|
+
# expect(chef_run).to install_portage_package('apache2').with_version('1.2.3')
|
23
|
+
#
|
24
|
+
# @example Assert that an +portage_package+ was installed with attributes
|
25
|
+
# expect(chef_run).to install_portage_package('apache2').with(version: '1.2.3')
|
26
|
+
#
|
27
|
+
# @example Assert that an +portage_package+ was installed using a regex
|
28
|
+
# expect(chef_run).to install_portage_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
29
|
+
#
|
30
|
+
# @example Assert that an +portage_package+ was _not_ installed
|
31
|
+
# expect(chef_run).to_not install_portage_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_portage_package(resource_name)
|
40
|
+
ChefSpec::Matchers::ResourceMatcher.new(:portage_package, :install, resource_name)
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Assert that an +portage_package+ resource exists in the Chef run with the
|
45
|
+
# action +:purge+. Given a Chef Recipe that purges "apache2" as an
|
46
|
+
# +portage_package+:
|
47
|
+
#
|
48
|
+
# portage_package 'apache2' do
|
49
|
+
# action :purge
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# The Examples section demonstrates the different ways to test an
|
53
|
+
# +portage_package+ resource with ChefSpec.
|
54
|
+
#
|
55
|
+
# @example Assert that an +portage_package+ was purged
|
56
|
+
# expect(chef_run).to purge_portage_package('apache2')
|
57
|
+
#
|
58
|
+
# @example Assert that an +portage_package+ was purged with predicate matchers
|
59
|
+
# expect(chef_run).to purge_portage_package('apache2').with_version('1.2.3')
|
60
|
+
#
|
61
|
+
# @example Assert that an +portage_package+ was purged with attributes
|
62
|
+
# expect(chef_run).to purge_portage_package('apache2').with(version: '1.2.3')
|
63
|
+
#
|
64
|
+
# @example Assert that an +portage_package+ was purged using a regex
|
65
|
+
# expect(chef_run).to purge_portage_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
66
|
+
#
|
67
|
+
# @example Assert that an +portage_package+ was _not_ purged
|
68
|
+
# expect(chef_run).to_not purge_portage_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 purge_portage_package(resource_name)
|
77
|
+
ChefSpec::Matchers::ResourceMatcher.new(:portage_package, :purge, resource_name)
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Assert that an +portage_package+ resource exists in the Chef run with the
|
82
|
+
# action +:remove+. Given a Chef Recipe that removes "apache2" as an
|
83
|
+
# +portage_package+:
|
84
|
+
#
|
85
|
+
# portage_package 'apache2' do
|
86
|
+
# action :remove
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
# The Examples section demonstrates the different ways to test an
|
90
|
+
# +portage_package+ resource with ChefSpec.
|
91
|
+
#
|
92
|
+
# @example Assert that an +portage_package+ was removed
|
93
|
+
# expect(chef_run).to remove_portage_package('apache2')
|
94
|
+
#
|
95
|
+
# @example Assert that an +portage_package+ was removed with predicate matchers
|
96
|
+
# expect(chef_run).to remove_portage_package('apache2').with_version('1.2.3')
|
97
|
+
#
|
98
|
+
# @example Assert that an +portage_package+ was removed with attributes
|
99
|
+
# expect(chef_run).to remove_portage_package('apache2').with(version: '1.2.3')
|
100
|
+
#
|
101
|
+
# @example Assert that an +portage_package+ was removed using a regex
|
102
|
+
# expect(chef_run).to remove_portage_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
103
|
+
#
|
104
|
+
# @example Assert that an +portage_package+ was _not_ removed
|
105
|
+
# expect(chef_run).to_not remove_portage_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 remove_portage_package(resource_name)
|
114
|
+
ChefSpec::Matchers::ResourceMatcher.new(:portage_package, :remove, resource_name)
|
115
|
+
end
|
116
|
+
|
117
|
+
#
|
118
|
+
# Assert that an +portage_package+ resource exists in the Chef run with the
|
119
|
+
# action +:upgrade+. Given a Chef Recipe that upgrades "apache2" as an
|
120
|
+
# +portage_package+:
|
121
|
+
#
|
122
|
+
# portage_package 'apache2' do
|
123
|
+
# action :upgrade
|
124
|
+
# end
|
125
|
+
#
|
126
|
+
# The Examples section demonstrates the different ways to test an
|
127
|
+
# +portage_package+ resource with ChefSpec.
|
128
|
+
#
|
129
|
+
# @example Assert that an +portage_package+ was upgraded
|
130
|
+
# expect(chef_run).to upgrade_portage_package('apache2')
|
131
|
+
#
|
132
|
+
# @example Assert that an +portage_package+ was upgraded with predicate matchers
|
133
|
+
# expect(chef_run).to upgrade_portage_package('apache2').with_version('1.2.3')
|
134
|
+
#
|
135
|
+
# @example Assert that an +portage_package+ was upgraded with attributes
|
136
|
+
# expect(chef_run).to upgrade_portage_package('apache2').with(version: '1.2.3')
|
137
|
+
#
|
138
|
+
# @example Assert that an +portage_package+ was upgraded using a regex
|
139
|
+
# expect(chef_run).to upgrade_portage_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
140
|
+
#
|
141
|
+
# @example Assert that an +portage_package+ was _not_ upgraded
|
142
|
+
# expect(chef_run).to_not upgrade_portage_package('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 upgrade_portage_package(resource_name)
|
151
|
+
ChefSpec::Matchers::ResourceMatcher.new(:portage_package, :upgrade, resource_name)
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
end
|