chefspec 2.0.1 → 3.0.0.beta.1
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.
- 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,80 @@
|
|
|
1
|
+
module ChefSpec::API
|
|
2
|
+
# @since 3.0.0
|
|
3
|
+
module FreebsdPackageMatchers
|
|
4
|
+
ChefSpec::Runner.define_runner_method :freebsd_package
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
# Assert that a +freebsd_package+ resource exists in the Chef run with the
|
|
8
|
+
# action +:install+. Given a Chef Recipe that installs "apache2" as a
|
|
9
|
+
# +freebsd_package+:
|
|
10
|
+
#
|
|
11
|
+
# freebsd_package 'apache2' do
|
|
12
|
+
# action :install
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# The Examples section demonstrates the different ways to test a
|
|
16
|
+
# +freebsd_package+ resource with ChefSpec.
|
|
17
|
+
#
|
|
18
|
+
# @example Assert that a +freebsd_package+ was installed
|
|
19
|
+
# expect(chef_run).to install_freebsd_package('apache2')
|
|
20
|
+
#
|
|
21
|
+
# @example Assert that a +freebsd_package+ was installed with predicate matchers
|
|
22
|
+
# expect(chef_run).to install_freebsd_package('apache2').with_version('1.2.3')
|
|
23
|
+
#
|
|
24
|
+
# @example Assert that a +freebsd_package+ was installed with attributes
|
|
25
|
+
# expect(chef_run).to install_freebsd_package('apache2').with(version: '1.2.3')
|
|
26
|
+
#
|
|
27
|
+
# @example Assert that a +freebsd_package+ was installed using a regex
|
|
28
|
+
# expect(chef_run).to install_freebsd_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
|
29
|
+
#
|
|
30
|
+
# @example Assert that a +freebsd_package+ was _not_ installed
|
|
31
|
+
# expect(chef_run).to_not install_freebsd_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_freebsd_package(resource_name)
|
|
40
|
+
ChefSpec::Matchers::ResourceMatcher.new(:freebsd_package, :install, resource_name)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# Assert that a +freebsd_package+ resource exists in the Chef run with the
|
|
45
|
+
# action +:remove+. Given a Chef Recipe that removes "apache2" as a
|
|
46
|
+
# +freebsd_package+:
|
|
47
|
+
#
|
|
48
|
+
# freebsd_package 'apache2' do
|
|
49
|
+
# action :remove
|
|
50
|
+
# end
|
|
51
|
+
#
|
|
52
|
+
# The Examples section demonstrates the different ways to test a
|
|
53
|
+
# +freebsd_package+ resource with ChefSpec.
|
|
54
|
+
#
|
|
55
|
+
# @example Assert that a +freebsd_package+ was removed
|
|
56
|
+
# expect(chef_run).to remove_freebsd_package('apache2')
|
|
57
|
+
#
|
|
58
|
+
# @example Assert that a +freebsd_package+ was removed with predicate matchers
|
|
59
|
+
# expect(chef_run).to remove_freebsd_package('apache2').with_version('1.2.3')
|
|
60
|
+
#
|
|
61
|
+
# @example Assert that a +freebsd_package+ was removed with attributes
|
|
62
|
+
# expect(chef_run).to remove_freebsd_package('apache2').with(version: '1.2.3')
|
|
63
|
+
#
|
|
64
|
+
# @example Assert that a +freebsd_package+ was removed using a regex
|
|
65
|
+
# expect(chef_run).to remove_freebsd_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
|
66
|
+
#
|
|
67
|
+
# @example Assert that a +freebsd_package+ was _not_ removed
|
|
68
|
+
# expect(chef_run).to_not remove_freebsd_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_freebsd_package(resource_name)
|
|
77
|
+
ChefSpec::Matchers::ResourceMatcher.new(:freebsd_package, :remove, resource_name)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
module ChefSpec::API
|
|
2
|
+
# @since 0.5.0
|
|
3
|
+
module GemPackageMatchers
|
|
4
|
+
ChefSpec::Runner.define_runner_method :gem_package
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
# Assert that a +gem_package+ resource exists in the Chef run with the
|
|
8
|
+
# action +:install+. Given a Chef Recipe that installs "community-zero" as a
|
|
9
|
+
# +gem_package+:
|
|
10
|
+
#
|
|
11
|
+
# gem_package 'community-zero' do
|
|
12
|
+
# action :install
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# The Examples section demonstrates the different ways to test a
|
|
16
|
+
# +gem_package+ resource with ChefSpec.
|
|
17
|
+
#
|
|
18
|
+
# @example Assert that a +gem_package+ was installed
|
|
19
|
+
# expect(chef_run).to install_gem_package('community-zero')
|
|
20
|
+
#
|
|
21
|
+
# @example Assert that a +gem_package+ was installed with predicate matchers
|
|
22
|
+
# expect(chef_run).to install_gem_package('community-zero').with_version('1.2.3')
|
|
23
|
+
#
|
|
24
|
+
# @example Assert that a +gem_package+ was installed with attributes
|
|
25
|
+
# expect(chef_run).to install_gem_package('community-zero').with(version: '1.2.3')
|
|
26
|
+
#
|
|
27
|
+
# @example Assert that a +gem_package+ was installed using a regex
|
|
28
|
+
# expect(chef_run).to install_gem_package('community-zero').with(version: /(\d+\.){2}\.\d+/)
|
|
29
|
+
#
|
|
30
|
+
# @example Assert that a +gem_package+ was _not_ installed
|
|
31
|
+
# expect(chef_run).to_not install_gem_package('community-zero')
|
|
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_gem_package(resource_name)
|
|
40
|
+
ChefSpec::Matchers::ResourceMatcher.new(:gem_package, :install, resource_name)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# Assert that a +gem_package+ resource exists in the Chef run with the
|
|
45
|
+
# action +:purge+. Given a Chef Recipe that purges "community-zero" as a
|
|
46
|
+
# +gem_package+:
|
|
47
|
+
#
|
|
48
|
+
# gem_package 'community-zero' do
|
|
49
|
+
# action :purge
|
|
50
|
+
# end
|
|
51
|
+
#
|
|
52
|
+
# The Examples section demonstrates the different ways to test a
|
|
53
|
+
# +gem_package+ resource with ChefSpec.
|
|
54
|
+
#
|
|
55
|
+
# @example Assert that a +gem_package+ was purgeed
|
|
56
|
+
# expect(chef_run).to purge_gem_package('community-zero')
|
|
57
|
+
#
|
|
58
|
+
# @example Assert that a +gem_package+ was purgeed with predicate matchers
|
|
59
|
+
# expect(chef_run).to purge_gem_package('community-zero').with_version('1.2.3')
|
|
60
|
+
#
|
|
61
|
+
# @example Assert that a +gem_package+ was purgeed with attributes
|
|
62
|
+
# expect(chef_run).to purge_gem_package('community-zero').with(version: '1.2.3')
|
|
63
|
+
#
|
|
64
|
+
# @example Assert that a +gem_package+ was purgeed using a regex
|
|
65
|
+
# expect(chef_run).to purge_gem_package('community-zero').with(version: /(\d+\.){2}\.\d+/)
|
|
66
|
+
#
|
|
67
|
+
# @example Assert that a +gem_package+ was _not_ purgeed
|
|
68
|
+
# expect(chef_run).to_not purge_gem_package('community-zero')
|
|
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_gem_package(resource_name)
|
|
77
|
+
ChefSpec::Matchers::ResourceMatcher.new(:gem_package, :purge, resource_name)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
#
|
|
81
|
+
# Assert that a +gem_package+ resource exists in the Chef run with the
|
|
82
|
+
# action +:reconfig+. Given a Chef Recipe that reconfigures "community-zero"
|
|
83
|
+
# as a +gem_package+:
|
|
84
|
+
#
|
|
85
|
+
# gem_package 'community-zero' do
|
|
86
|
+
# action :reconfig
|
|
87
|
+
# end
|
|
88
|
+
#
|
|
89
|
+
# The Examples section demonstrates the different ways to test a
|
|
90
|
+
# +gem_package+ resource with ChefSpec.
|
|
91
|
+
#
|
|
92
|
+
# @example Assert that a +gem_package+ was reconfigured
|
|
93
|
+
# expect(chef_run).to reconfig_gem_package('community-zero')
|
|
94
|
+
#
|
|
95
|
+
# @example Assert that a +gem_package+ was reconfigured with predicate matchers
|
|
96
|
+
# expect(chef_run).to reconfig_gem_package('community-zero').with_version('1.2.3')
|
|
97
|
+
#
|
|
98
|
+
# @example Assert that a +gem_package+ was reconfigured with attributes
|
|
99
|
+
# expect(chef_run).to reconfig_gem_package('community-zero').with(version: '1.2.3')
|
|
100
|
+
#
|
|
101
|
+
# @example Assert that a +gem_package+ was reconfigured using a regex
|
|
102
|
+
# expect(chef_run).to reconfig_gem_package('community-zero').with(version: /(\d+\.){2}\.\d+/)
|
|
103
|
+
#
|
|
104
|
+
# @example Assert that a +gem_package+ was _not_ reconfigured
|
|
105
|
+
# expect(chef_run).to_not reconfig_gem_package('community-zero')
|
|
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_gem_package(resource_name)
|
|
114
|
+
ChefSpec::Matchers::ResourceMatcher.new(:gem_package, :reconfig, resource_name)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
#
|
|
118
|
+
# Assert that a +gem_package+ resource exists in the Chef run with the
|
|
119
|
+
# action +:remove+. Given a Chef Recipe that removes "community-zero" as a
|
|
120
|
+
# +gem_package+:
|
|
121
|
+
#
|
|
122
|
+
# gem_package 'community-zero' do
|
|
123
|
+
# action :remove
|
|
124
|
+
# end
|
|
125
|
+
#
|
|
126
|
+
# The Examples section demonstrates the different ways to test a
|
|
127
|
+
# +gem_package+ resource with ChefSpec.
|
|
128
|
+
#
|
|
129
|
+
# @example Assert that a +gem_package+ was removeed
|
|
130
|
+
# expect(chef_run).to remove_gem_package('community-zero')
|
|
131
|
+
#
|
|
132
|
+
# @example Assert that a +gem_package+ was removeed with predicate matchers
|
|
133
|
+
# expect(chef_run).to remove_gem_package('community-zero').with_version('1.2.3')
|
|
134
|
+
#
|
|
135
|
+
# @example Assert that a +gem_package+ was removeed with attributes
|
|
136
|
+
# expect(chef_run).to remove_gem_package('community-zero').with(version: '1.2.3')
|
|
137
|
+
#
|
|
138
|
+
# @example Assert that a +gem_package+ was removeed using a regex
|
|
139
|
+
# expect(chef_run).to remove_gem_package('community-zero').with(version: /(\d+\.){2}\.\d+/)
|
|
140
|
+
#
|
|
141
|
+
# @example Assert that a +gem_package+ was _not_ removeed
|
|
142
|
+
# expect(chef_run).to_not remove_gem_package('community-zero')
|
|
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_gem_package(resource_name)
|
|
151
|
+
ChefSpec::Matchers::ResourceMatcher.new(:gem_package, :remove, resource_name)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
#
|
|
155
|
+
# Assert that a +gem_package+ resource exists in the Chef run with the
|
|
156
|
+
# action +:upgrade+. Given a Chef Recipe that upgrades "community-zero" as a
|
|
157
|
+
# +gem_package+:
|
|
158
|
+
#
|
|
159
|
+
# gem_package 'community-zero' do
|
|
160
|
+
# action :upgrade
|
|
161
|
+
# end
|
|
162
|
+
#
|
|
163
|
+
# The Examples section demonstrates the different ways to test a
|
|
164
|
+
# +gem_package+ resource with ChefSpec.
|
|
165
|
+
#
|
|
166
|
+
# @example Assert that a +gem_package+ was upgradeed
|
|
167
|
+
# expect(chef_run).to upgrade_gem_package('community-zero')
|
|
168
|
+
#
|
|
169
|
+
# @example Assert that a +gem_package+ was upgradeed with predicate matchers
|
|
170
|
+
# expect(chef_run).to upgrade_gem_package('community-zero').with_version('1.2.3')
|
|
171
|
+
#
|
|
172
|
+
# @example Assert that a +gem_package+ was upgradeed with attributes
|
|
173
|
+
# expect(chef_run).to upgrade_gem_package('community-zero').with(version: '1.2.3')
|
|
174
|
+
#
|
|
175
|
+
# @example Assert that a +gem_package+ was upgradeed using a regex
|
|
176
|
+
# expect(chef_run).to upgrade_gem_package('community-zero').with(version: /(\d+\.){2}\.\d+/)
|
|
177
|
+
#
|
|
178
|
+
# @example Assert that a +gem_package+ was _not_ upgradeed
|
|
179
|
+
# expect(chef_run).to_not upgrade_gem_package('community-zero')
|
|
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_gem_package(resource_name)
|
|
188
|
+
ChefSpec::Matchers::ResourceMatcher.new(:gem_package, :upgrade, resource_name)
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
module ChefSpec::API
|
|
2
|
+
# @since 3.0.0
|
|
3
|
+
module GitMatchers
|
|
4
|
+
ChefSpec::Runner.define_runner_method :git
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
# Assert that a +git+ resource exists in the Chef run with the
|
|
8
|
+
# action +:checkout+. Given a Chef Recipe that checks out "git://..." as a
|
|
9
|
+
# +git+:
|
|
10
|
+
#
|
|
11
|
+
# git 'git://...' do
|
|
12
|
+
# action :checkout
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# The Examples section demonstrates the different ways to test a
|
|
16
|
+
# +git+ resource with ChefSpec.
|
|
17
|
+
#
|
|
18
|
+
# @example Assert that a +git+ was checked out
|
|
19
|
+
# expect(chef_run).to checkout_git('git://...')
|
|
20
|
+
#
|
|
21
|
+
# @example Assert that a +git+ was checked out with predicate matchers
|
|
22
|
+
# expect(chef_run).to checkout_git('git://...').with_user('svargo')
|
|
23
|
+
#
|
|
24
|
+
# @example Assert that a +git+ was checked out with attributes
|
|
25
|
+
# expect(chef_run).to checkout_git('git://...').with(user: 'svargo')
|
|
26
|
+
#
|
|
27
|
+
# @example Assert that a +git+ was checked out using a regex
|
|
28
|
+
# expect(chef_run).to checkout_git('git://...').with(user: /sva(.+)/)
|
|
29
|
+
#
|
|
30
|
+
# @example Assert that a +git+ was _not_ checked out
|
|
31
|
+
# expect(chef_run).to_not checkout_git('git://...')
|
|
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 checkout_git(resource_name)
|
|
40
|
+
ChefSpec::Matchers::ResourceMatcher.new(:git, :checkout, resource_name)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# Assert that a +git+ resource exists in the Chef run with the
|
|
45
|
+
# action +:export+. Given a Chef Recipe that exports "git://" as a
|
|
46
|
+
# +git+:
|
|
47
|
+
#
|
|
48
|
+
# git 'git://' do
|
|
49
|
+
# action :export
|
|
50
|
+
# end
|
|
51
|
+
#
|
|
52
|
+
# The Examples section demonstrates the different ways to test a
|
|
53
|
+
# +git+ resource with ChefSpec.
|
|
54
|
+
#
|
|
55
|
+
# @example Assert that a +git+ was exported
|
|
56
|
+
# expect(chef_run).to export_git('git://')
|
|
57
|
+
#
|
|
58
|
+
# @example Assert that a +git+ was exported with predicate matchers
|
|
59
|
+
# expect(chef_run).to export_git('git://').with_user('svargo')
|
|
60
|
+
#
|
|
61
|
+
# @example Assert that a +git+ was exported with attributes
|
|
62
|
+
# expect(chef_run).to export_git('git://').with(user: 'svargo')
|
|
63
|
+
#
|
|
64
|
+
# @example Assert that a +git+ was exported using a regex
|
|
65
|
+
# expect(chef_run).to export_git('git://').with(user: /sva(.+)/)
|
|
66
|
+
#
|
|
67
|
+
# @example Assert that a +git+ was _not_ exported
|
|
68
|
+
# expect(chef_run).to_not export_git('git://')
|
|
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 export_git(resource_name)
|
|
77
|
+
ChefSpec::Matchers::ResourceMatcher.new(:git, :export, resource_name)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
#
|
|
81
|
+
# Assert that a +git+ resource exists in the Chef run with the
|
|
82
|
+
# action +:sync+. Given a Chef Recipe that syncs "git://" as a
|
|
83
|
+
# +git+:
|
|
84
|
+
#
|
|
85
|
+
# git 'git://' do
|
|
86
|
+
# action :sync
|
|
87
|
+
# end
|
|
88
|
+
#
|
|
89
|
+
# The Examples section demonstrates the different ways to test a
|
|
90
|
+
# +git+ resource with ChefSpec.
|
|
91
|
+
#
|
|
92
|
+
# @example Assert that a +git+ was synced
|
|
93
|
+
# expect(chef_run).to sync_git('git://')
|
|
94
|
+
#
|
|
95
|
+
# @example Assert that a +git+ was synced with predicate matchers
|
|
96
|
+
# expect(chef_run).to sync_git('git://').with_user('svargo')
|
|
97
|
+
#
|
|
98
|
+
# @example Assert that a +git+ was synced with attributes
|
|
99
|
+
# expect(chef_run).to sync_git('git://').with(user: 'svargo')
|
|
100
|
+
#
|
|
101
|
+
# @example Assert that a +git+ was synced using a regex
|
|
102
|
+
# expect(chef_run).to sync_git('git://').with(user: /sva(.+)/)
|
|
103
|
+
#
|
|
104
|
+
# @example Assert that a +git+ was _not_ synced
|
|
105
|
+
# expect(chef_run).to_not sync_git('git://')
|
|
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 sync_git(resource_name)
|
|
114
|
+
ChefSpec::Matchers::ResourceMatcher.new(:git, :sync, resource_name)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
module ChefSpec::API
|
|
2
|
+
# @since 1.0.0
|
|
3
|
+
module GroupMatchers
|
|
4
|
+
ChefSpec::Runner.define_runner_method :group
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
# Assert that a +group+ resource exists in the Chef run with the
|
|
8
|
+
# action +:create+. Given a Chef Recipe that creates "apache2" as a
|
|
9
|
+
# +group+:
|
|
10
|
+
#
|
|
11
|
+
# group 'apache2' do
|
|
12
|
+
# action :create
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# The Examples section demonstrates the different ways to test a
|
|
16
|
+
# +group+ resource with ChefSpec.
|
|
17
|
+
#
|
|
18
|
+
# @example Assert that a +group+ was createed
|
|
19
|
+
# expect(chef_run).to create_group('apache2')
|
|
20
|
+
#
|
|
21
|
+
# @example Assert that a +group+ was createed with predicate matchers
|
|
22
|
+
# expect(chef_run).to create_group('apache2').with_gid(1234)
|
|
23
|
+
#
|
|
24
|
+
# @example Assert that a +group+ was createed with attributes
|
|
25
|
+
# expect(chef_run).to create_group('apache2').with(gid: 1234)
|
|
26
|
+
#
|
|
27
|
+
# @example Assert that a +group+ was createed using a regex
|
|
28
|
+
# expect(chef_run).to create_group('apache2').with(gid: /\d+/)
|
|
29
|
+
#
|
|
30
|
+
# @example Assert that a +group+ was _not_ createed
|
|
31
|
+
# expect(chef_run).to_not create_group('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 create_group(resource_name)
|
|
40
|
+
ChefSpec::Matchers::ResourceMatcher.new(:group, :create, resource_name)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# Assert that a +group+ resource exists in the Chef run with the
|
|
45
|
+
# action +:manage+. Given a Chef Recipe that manages "apache2" as a
|
|
46
|
+
# +group+:
|
|
47
|
+
#
|
|
48
|
+
# group 'apache2' do
|
|
49
|
+
# action :manage
|
|
50
|
+
# end
|
|
51
|
+
#
|
|
52
|
+
# The Examples section demonstrates the different ways to test a
|
|
53
|
+
# +group+ resource with ChefSpec.
|
|
54
|
+
#
|
|
55
|
+
# @example Assert that a +group+ was managed
|
|
56
|
+
# expect(chef_run).to manage_group('apache2')
|
|
57
|
+
#
|
|
58
|
+
# @example Assert that a +group+ was managed with predicate matchers
|
|
59
|
+
# expect(chef_run).to manage_group('apache2').with_gid(1234)
|
|
60
|
+
#
|
|
61
|
+
# @example Assert that a +group+ was managed with attributes
|
|
62
|
+
# expect(chef_run).to manage_group('apache2').with(gid: 1234)
|
|
63
|
+
#
|
|
64
|
+
# @example Assert that a +group+ was managed using a regex
|
|
65
|
+
# expect(chef_run).to manage_group('apache2').with(gid: /\d+/)
|
|
66
|
+
#
|
|
67
|
+
# @example Assert that a +group+ was _not_ managed
|
|
68
|
+
# expect(chef_run).to_not manage_group('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 manage_group(resource_name)
|
|
77
|
+
ChefSpec::Matchers::ResourceMatcher.new(:group, :manage, resource_name)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
#
|
|
81
|
+
# Assert that a +group+ resource exists in the Chef run with the
|
|
82
|
+
# action +:modify+. Given a Chef Recipe that modifies "apache2" as a
|
|
83
|
+
# +group+:
|
|
84
|
+
#
|
|
85
|
+
# group 'apache2' do
|
|
86
|
+
# action :modify
|
|
87
|
+
# end
|
|
88
|
+
#
|
|
89
|
+
# The Examples section demonstrates the different ways to test a
|
|
90
|
+
# +group+ resource with ChefSpec.
|
|
91
|
+
#
|
|
92
|
+
# @example Assert that a +group+ was modified
|
|
93
|
+
# expect(chef_run).to modify_group('apache2')
|
|
94
|
+
#
|
|
95
|
+
# @example Assert that a +group+ was modified with predicate matchers
|
|
96
|
+
# expect(chef_run).to modify_group('apache2').with_gid(1234)
|
|
97
|
+
#
|
|
98
|
+
# @example Assert that a +group+ was modified with attributes
|
|
99
|
+
# expect(chef_run).to modify_group('apache2').with(gid: 1234)
|
|
100
|
+
#
|
|
101
|
+
# @example Assert that a +group+ was modified using a regex
|
|
102
|
+
# expect(chef_run).to modify_group('apache2').with(gid: /\d+/)
|
|
103
|
+
#
|
|
104
|
+
# @example Assert that a +group+ was _not_ modified
|
|
105
|
+
# expect(chef_run).to_not modify_group('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 modify_group(resource_name)
|
|
114
|
+
ChefSpec::Matchers::ResourceMatcher.new(:group, :modify, resource_name)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
#
|
|
118
|
+
# Assert that a +group+ resource exists in the Chef run with the
|
|
119
|
+
# action +:remove+. Given a Chef Recipe that removes "apache2" as a
|
|
120
|
+
# +group+:
|
|
121
|
+
#
|
|
122
|
+
# group 'apache2' do
|
|
123
|
+
# action :remove
|
|
124
|
+
# end
|
|
125
|
+
#
|
|
126
|
+
# The Examples section demonstrates the different ways to test a
|
|
127
|
+
# +group+ resource with ChefSpec.
|
|
128
|
+
#
|
|
129
|
+
# @example Assert that a +group+ was removed
|
|
130
|
+
# expect(chef_run).to remove_group('apache2')
|
|
131
|
+
#
|
|
132
|
+
# @example Assert that a +group+ was removed with predicate matchers
|
|
133
|
+
# expect(chef_run).to remove_group('apache2').with_gid(1234)
|
|
134
|
+
#
|
|
135
|
+
# @example Assert that a +group+ was removed with attributes
|
|
136
|
+
# expect(chef_run).to remove_group('apache2').with(gid: 1234)
|
|
137
|
+
#
|
|
138
|
+
# @example Assert that a +group+ was removed using a regex
|
|
139
|
+
# expect(chef_run).to remove_group('apache2').with(gid: /\d+/)
|
|
140
|
+
#
|
|
141
|
+
# @example Assert that a +group+ was _not_ removed
|
|
142
|
+
# expect(chef_run).to_not remove_group('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_group(resource_name)
|
|
151
|
+
ChefSpec::Matchers::ResourceMatcher.new(:group, :remove, resource_name)
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|