chefspec 7.0.0 → 7.1.0
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/CHANGELOG.md +11 -1
- data/Gemfile +6 -0
- data/README.md +43 -11
- data/Rakefile +48 -8
- data/chefspec.gemspec +0 -8
- data/examples/cab_package/spec/install_spec.rb +20 -18
- data/examples/cab_package/spec/remove_spec.rb +17 -15
- data/examples/cached/spec/default_spec.rb +1 -0
- data/examples/compile_time/spec/default_spec.rb +2 -0
- data/examples/custom_matcher/libraries/matcher.rb +1 -23
- data/examples/dnf_package/spec/install_spec.rb +20 -18
- data/examples/dnf_package/spec/purge_spec.rb +17 -15
- data/examples/dnf_package/spec/remove_spec.rb +17 -15
- data/examples/dnf_package/spec/upgrade_spec.rb +17 -15
- data/examples/heavy_provider_light_resource/spec/provider_service_spec.rb +1 -0
- data/examples/msu_package/spec/install_spec.rb +20 -18
- data/examples/msu_package/spec/remove_spec.rb +17 -15
- data/examples/server/spec/exotic_port_spec.rb +15 -2
- data/lib/chefspec.rb +1 -8
- data/lib/chefspec/api.rb +6 -84
- data/lib/chefspec/api/do_nothing.rb +18 -21
- data/lib/chefspec/api/include_recipe.rb +20 -23
- data/lib/chefspec/api/link.rb +20 -99
- data/lib/chefspec/api/notifications.rb +32 -35
- data/lib/chefspec/api/reboot.rb +5 -14
- data/lib/chefspec/api/render_file.rb +29 -32
- data/lib/chefspec/api/state_attrs.rb +22 -25
- data/lib/chefspec/api/subscriptions.rb +29 -32
- data/lib/chefspec/api/user.rb +216 -219
- data/lib/chefspec/extensions.rb +16 -0
- data/lib/chefspec/extensions/chef/resource.rb +90 -8
- data/lib/chefspec/version.rb +1 -1
- data/lib/chefspec/zero_server.rb +20 -18
- metadata +3 -313
- data/examples/custom_resource/libraries/matchers.rb +0 -5
- data/examples/use_inline_resources/libraries/matchers.rb +0 -5
- data/features/apt_package.feature +0 -14
- data/features/apt_repository.feature +0 -15
- data/features/apt_update.feature +0 -13
- data/features/attributes.feature +0 -7
- data/features/batch.feature +0 -10
- data/features/bff_package.feature +0 -12
- data/features/cab_package.feature +0 -21
- data/features/cached.feature +0 -7
- data/features/chef_gem.feature +0 -14
- data/features/chocolatey_package.feature +0 -14
- data/features/compile_time.feature +0 -7
- data/features/cookbook_file.feature +0 -13
- data/features/cron.feature +0 -11
- data/features/custom_matcher.feature +0 -11
- data/features/custom_resource.feature +0 -7
- data/features/deploy.feature +0 -12
- data/features/directory.feature +0 -11
- data/features/dnf_package.feature +0 -26
- data/features/do_nothing.feature +0 -10
- data/features/dpkg_package.feature +0 -12
- data/features/dsc_resource.feature +0 -10
- data/features/dsc_script.feature +0 -10
- data/features/env.feature +0 -12
- data/features/erl_call.feature +0 -10
- data/features/execute.feature +0 -10
- data/features/exotic_zero_port.feature +0 -7
- data/features/expect_exception.feature +0 -12
- data/features/file.feature +0 -13
- data/features/freebsd_package.feature +0 -11
- data/features/gem_package.feature +0 -14
- data/features/git.feature +0 -12
- data/features/group.feature +0 -13
- data/features/guards.feature +0 -10
- data/features/heavy_provider_light_resource.feature +0 -10
- data/features/homebrew_package.feature +0 -12
- data/features/http_request.feature +0 -15
- data/features/ifconfig.feature +0 -13
- data/features/include_recipe.feature +0 -10
- data/features/ips_package.feature +0 -12
- data/features/launchd.feature +0 -17
- data/features/link.feature +0 -12
- data/features/log.feature +0 -10
- data/features/macports_package.feature +0 -13
- data/features/mdadm.feature +0 -12
- data/features/mount.feature +0 -14
- data/features/msu_package.feature +0 -23
- data/features/multiple_actions.feature +0 -12
- data/features/multiple_run_action.feature +0 -7
- data/features/notifications.feature +0 -14
- data/features/ohai.feature +0 -10
- data/features/openbsd_package.feature +0 -12
- data/features/osx_profile.feature +0 -13
- data/features/package.feature +0 -14
- data/features/pacman_package.feature +0 -13
- data/features/paludis_package.feature +0 -12
- data/features/portage_package.feature +0 -13
- data/features/powershell_script.feature +0 -10
- data/features/reboot.feature +0 -12
- data/features/registry_key.feature +0 -13
- data/features/remote_directory.feature +0 -12
- data/features/remote_file.feature +0 -13
- data/features/render_file.feature +0 -11
- data/features/roles.feature +0 -7
- data/features/route.feature +0 -11
- data/features/rpm_package.feature +0 -12
- data/features/ruby_block.feature +0 -11
- data/features/script.feature +0 -16
- data/features/server.feature +0 -16
- data/features/server_on_disk.feature +0 -16
- data/features/service.feature +0 -15
- data/features/smartos_package.feature +0 -12
- data/features/solaris_package.feature +0 -12
- data/features/state_attrs.feature +0 -7
- data/features/step_definitions/background_steps.rb +0 -7
- data/features/step_into.feature +0 -7
- data/features/stub_command.feature +0 -7
- data/features/stub_data_bag.feature +0 -7
- data/features/stub_data_bag_item.feature +0 -7
- data/features/stub_node.feature +0 -7
- data/features/stub_search.feature +0 -7
- data/features/subscribes.feature +0 -14
- data/features/subversion.feature +0 -13
- data/features/support/env.rb +0 -38
- data/features/support/executor.rb +0 -20
- data/features/support/exotic_zero_port.rb +0 -3
- data/features/support/on_disk.rb +0 -7
- data/features/systemd_unit.feature +0 -27
- data/features/template.feature +0 -13
- data/features/use_inline_resources.feature +0 -7
- data/features/user.feature +0 -15
- data/features/windows_package.feature +0 -11
- data/features/windows_service.feature +0 -16
- data/features/yum_package.feature +0 -13
- data/features/yum_repository.feature +0 -23
- data/features/zypper_package.feature +0 -13
- data/lib/chefspec/api/apt_package.rb +0 -192
- data/lib/chefspec/api/apt_repository.rb +0 -56
- data/lib/chefspec/api/apt_update.rb +0 -53
- data/lib/chefspec/api/batch.rb +0 -43
- data/lib/chefspec/api/bff_package.rb +0 -154
- data/lib/chefspec/api/cab_package.rb +0 -80
- data/lib/chefspec/api/chef_gem.rb +0 -191
- data/lib/chefspec/api/chocolatey_package.rb +0 -107
- data/lib/chefspec/api/cookbook_file.rb +0 -166
- data/lib/chefspec/api/cron.rb +0 -80
- data/lib/chefspec/api/deploy.rb +0 -117
- data/lib/chefspec/api/directory.rb +0 -80
- data/lib/chefspec/api/dnf_package.rb +0 -154
- data/lib/chefspec/api/dpkg_package.rb +0 -117
- data/lib/chefspec/api/dsc_resource.rb +0 -49
- data/lib/chefspec/api/dsc_script.rb +0 -37
- data/lib/chefspec/api/easy_install_package.rb +0 -154
- data/lib/chefspec/api/env.rb +0 -117
- data/lib/chefspec/api/erl_call.rb +0 -43
- data/lib/chefspec/api/execute.rb +0 -43
- data/lib/chefspec/api/file.rb +0 -166
- data/lib/chefspec/api/freebsd_package.rb +0 -80
- data/lib/chefspec/api/gem_package.rb +0 -191
- data/lib/chefspec/api/git.rb +0 -117
- data/lib/chefspec/api/group.rb +0 -154
- data/lib/chefspec/api/homebrew_package.rb +0 -154
- data/lib/chefspec/api/http_request.rb +0 -228
- data/lib/chefspec/api/ifconfig.rb +0 -154
- data/lib/chefspec/api/ips_package.rb +0 -117
- data/lib/chefspec/api/launchd.rb +0 -151
- data/lib/chefspec/api/log.rb +0 -43
- data/lib/chefspec/api/macports_package.rb +0 -154
- data/lib/chefspec/api/mdadm.rb +0 -117
- data/lib/chefspec/api/mount.rb +0 -192
- data/lib/chefspec/api/msu_package.rb +0 -81
- data/lib/chefspec/api/ohai.rb +0 -43
- data/lib/chefspec/api/openbsd_package.rb +0 -155
- data/lib/chefspec/api/osx_profile.rb +0 -63
- data/lib/chefspec/api/package.rb +0 -192
- data/lib/chefspec/api/pacman_package.rb +0 -155
- data/lib/chefspec/api/paludis_package.rb +0 -155
- data/lib/chefspec/api/portage_package.rb +0 -155
- data/lib/chefspec/api/powershell_script.rb +0 -43
- data/lib/chefspec/api/registry_key.rb +0 -166
- data/lib/chefspec/api/remote_directory.rb +0 -120
- data/lib/chefspec/api/remote_file.rb +0 -166
- data/lib/chefspec/api/route.rb +0 -80
- data/lib/chefspec/api/rpm_package.rb +0 -117
- data/lib/chefspec/api/ruby_block.rb +0 -68
- data/lib/chefspec/api/script.rb +0 -278
- data/lib/chefspec/api/service.rb +0 -246
- data/lib/chefspec/api/smartos_package.rb +0 -117
- data/lib/chefspec/api/solaris_package.rb +0 -117
- data/lib/chefspec/api/subversion.rb +0 -154
- data/lib/chefspec/api/systemd_unit.rb +0 -353
- data/lib/chefspec/api/template.rb +0 -166
- data/lib/chefspec/api/windows_package.rb +0 -86
- data/lib/chefspec/api/windows_service.rb +0 -286
- data/lib/chefspec/api/yum_package.rb +0 -154
- data/lib/chefspec/api/yum_repository.rb +0 -130
- data/lib/chefspec/api/zypper_package.rb +0 -154
- data/spec/unit/api_spec.rb +0 -18
|
@@ -1,38 +1,35 @@
|
|
|
1
1
|
module ChefSpec::API
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def notify(signature)
|
|
35
|
-
ChefSpec::Matchers::NotificationsMatcher.new(signature)
|
|
36
|
-
end
|
|
2
|
+
#
|
|
3
|
+
# Assert that a resource notifies another. Given a Chef Recipe that
|
|
4
|
+
# notifies a template resource to restart apache:
|
|
5
|
+
#
|
|
6
|
+
# template '/etc/apache2/config' do
|
|
7
|
+
# notifies :restart, 'service[apache2]'
|
|
8
|
+
# end
|
|
9
|
+
#
|
|
10
|
+
# The Examples section demonstrates the different ways to test an
|
|
11
|
+
# notifications on a resource with ChefSpec.
|
|
12
|
+
#
|
|
13
|
+
# @example Assert the template notifies apache of something
|
|
14
|
+
# template = chef_run.template('/etc/apache2.conf')
|
|
15
|
+
# expect(template).to notify('service[apache2]')
|
|
16
|
+
#
|
|
17
|
+
# @example Assert the template notifies apache to restart
|
|
18
|
+
# expect(template).to notify('service[apache2]').to(:restart)
|
|
19
|
+
#
|
|
20
|
+
# @example Assert the template notifies apache to restart immediately
|
|
21
|
+
# expect(template).to notify('service[apache2]').to(:restart).immediately
|
|
22
|
+
#
|
|
23
|
+
# @example Assert the template notifies apache to restart delayed
|
|
24
|
+
# expect(template).to notify('service[apache2]').to(:restart).delayed
|
|
25
|
+
#
|
|
26
|
+
#
|
|
27
|
+
# @param [String] signature
|
|
28
|
+
# the signature of the notification to match
|
|
29
|
+
#
|
|
30
|
+
# @return [ChefSpec::Matchers::NotificationsMatcher]
|
|
31
|
+
#
|
|
32
|
+
def notify(signature)
|
|
33
|
+
ChefSpec::Matchers::NotificationsMatcher.new(signature)
|
|
37
34
|
end
|
|
38
35
|
end
|
data/lib/chefspec/api/reboot.rb
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
module ChefSpec::API
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def now_reboot(resource_name)
|
|
7
|
-
ChefSpec::Matchers::ResourceMatcher.new(:reboot, :reboot_now, resource_name)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def request_reboot(resource_name)
|
|
11
|
-
ChefSpec::Matchers::ResourceMatcher.new(:reboot, :request_reboot, resource_name)
|
|
12
|
-
end
|
|
2
|
+
def now_reboot(resource_name)
|
|
3
|
+
ChefSpec::Matchers::ResourceMatcher.new(:reboot, :reboot_now, resource_name)
|
|
4
|
+
end
|
|
13
5
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
end
|
|
6
|
+
def request_reboot(resource_name)
|
|
7
|
+
ChefSpec::Matchers::ResourceMatcher.new(:reboot, :request_reboot, resource_name)
|
|
17
8
|
end
|
|
18
9
|
end
|
|
@@ -1,35 +1,32 @@
|
|
|
1
1
|
module ChefSpec::API
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def render_file(path)
|
|
32
|
-
ChefSpec::Matchers::RenderFileMatcher.new(path)
|
|
33
|
-
end
|
|
2
|
+
#
|
|
3
|
+
# Assert that a file is rendered by the Chef run. This matcher works for
|
|
4
|
+
# +template+, +file+, and +cookbook_file+ resources. The content from the
|
|
5
|
+
# resource must be convertable to a string; verifying the content of a
|
|
6
|
+
# binary file is not permissible at this time.
|
|
7
|
+
#
|
|
8
|
+
# @example Assert a template is rendered
|
|
9
|
+
# expect(chef_run).to render_file('/etc/foo')
|
|
10
|
+
#
|
|
11
|
+
# @example Assert a template is rendered with certain content
|
|
12
|
+
# expect(template).to render_file('/etc/foo').with_content('This is a file')
|
|
13
|
+
#
|
|
14
|
+
# @example Assert a template is rendered with matching content
|
|
15
|
+
# expect(template).to render_file('/etc/foo').with_content(/^This(.+)$/)
|
|
16
|
+
#
|
|
17
|
+
# @example Assert a template is rendered with content matching any RSpec matcher
|
|
18
|
+
# expect(template).to render_file('/etc/foo').with_content(starts_with('This'))
|
|
19
|
+
#
|
|
20
|
+
# @example Assert a partial path to a template is rendered with matching content
|
|
21
|
+
# expect(template).to render_file(/\/etc\/foo-(\d+)$/).with_content(/^This(.+)$/)
|
|
22
|
+
#
|
|
23
|
+
#
|
|
24
|
+
# @param [String] path
|
|
25
|
+
# the path of the file to render
|
|
26
|
+
#
|
|
27
|
+
# @return [ChefSpec::Matchers::RenderFileMatcher]
|
|
28
|
+
#
|
|
29
|
+
def render_file(path)
|
|
30
|
+
ChefSpec::Matchers::RenderFileMatcher.new(path)
|
|
34
31
|
end
|
|
35
32
|
end
|
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
module ChefSpec::API
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def have_state_attrs(*state_attrs)
|
|
25
|
-
ChefSpec::Matchers::StateAttrsMatcher.new(state_attrs)
|
|
26
|
-
end
|
|
2
|
+
#
|
|
3
|
+
# Assert that a Chef resource has certain state attributes (since Chef
|
|
4
|
+
# 11.8.0):
|
|
5
|
+
#
|
|
6
|
+
# state_attrs :time, :temperature
|
|
7
|
+
#
|
|
8
|
+
# @see https://github.com/opscode/chef/blob/e43d7ebda/lib/chef/resource/file.rb#L32-L37
|
|
9
|
+
#
|
|
10
|
+
# The Examples section demonstrates the different ways to test a
|
|
11
|
+
# resource's +state_attrs+ with ChefSpec.
|
|
12
|
+
#
|
|
13
|
+
# @example Assert the +lwrp+ resource has two state attributes
|
|
14
|
+
# expect(lwrp).to have_state_attrs(:time, :temperature)
|
|
15
|
+
#
|
|
16
|
+
#
|
|
17
|
+
# @param [Array] state_attrs
|
|
18
|
+
# the list of state attributes to assert
|
|
19
|
+
#
|
|
20
|
+
# @return [ChefSpec::Matchers::StateAttrsMatcher]
|
|
21
|
+
#
|
|
22
|
+
def have_state_attrs(*state_attrs)
|
|
23
|
+
ChefSpec::Matchers::StateAttrsMatcher.new(state_attrs)
|
|
27
24
|
end
|
|
28
25
|
end
|
|
@@ -1,35 +1,32 @@
|
|
|
1
1
|
module ChefSpec::API
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def subscribe_to(signature)
|
|
32
|
-
ChefSpec::Matchers::SubscribesMatcher.new(signature)
|
|
33
|
-
end
|
|
2
|
+
#
|
|
3
|
+
# Assert that a resource subscribes to another. Given a Chef Recipe that
|
|
4
|
+
# subscribes a template resource to restart apache:
|
|
5
|
+
#
|
|
6
|
+
# service 'apache2' do
|
|
7
|
+
# subscribes :create, 'template[/etc/apache2/config]'
|
|
8
|
+
# end
|
|
9
|
+
#
|
|
10
|
+
# The Examples section demonstrates the different ways to test a
|
|
11
|
+
# subscription on a resource with ChefSpec.
|
|
12
|
+
#
|
|
13
|
+
# @example Assert a basic subscription
|
|
14
|
+
# service = chef_run.service('apache2')
|
|
15
|
+
# expect(service).to subscribe_to('template[/etc/apache2/config]')
|
|
16
|
+
#
|
|
17
|
+
# @example Assert a subscription with specified action
|
|
18
|
+
# expect(service).to subscribe_to('template[/etc/apache2/config]').on(:restart)
|
|
19
|
+
#
|
|
20
|
+
# @example Assert a subscription with specified action and timing
|
|
21
|
+
# expect(service).to subscribe_to('template[/etc/apache2/config]').on(:restart).immediately
|
|
22
|
+
#
|
|
23
|
+
#
|
|
24
|
+
# @param [String] signature
|
|
25
|
+
# the signature of the notification to match
|
|
26
|
+
#
|
|
27
|
+
# @return [ChefSpec::Matchers::NotificationsMatcher]
|
|
28
|
+
#
|
|
29
|
+
def subscribe_to(signature)
|
|
30
|
+
ChefSpec::Matchers::SubscribesMatcher.new(signature)
|
|
34
31
|
end
|
|
35
32
|
end
|
data/lib/chefspec/api/user.rb
CHANGED
|
@@ -1,228 +1,225 @@
|
|
|
1
1
|
module ChefSpec::API
|
|
2
|
-
|
|
3
|
-
module UserMatchers
|
|
4
|
-
ChefSpec.define_matcher :user
|
|
2
|
+
ChefSpec.define_matcher :user
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
4
|
+
#
|
|
5
|
+
# Assert that a +user+ resource exists in the Chef run with the
|
|
6
|
+
# action +:create+. Given a Chef Recipe that creates "apache2" as a
|
|
7
|
+
# +user+:
|
|
8
|
+
#
|
|
9
|
+
# user 'apache2' do
|
|
10
|
+
# action :create
|
|
11
|
+
# end
|
|
12
|
+
#
|
|
13
|
+
# The Examples section demonstrates the different ways to test a
|
|
14
|
+
# +user+ resource with ChefSpec.
|
|
15
|
+
#
|
|
16
|
+
# @example Assert that a +user+ was created
|
|
17
|
+
# expect(chef_run).to create_user('apache2')
|
|
18
|
+
#
|
|
19
|
+
# @example Assert that a +user+ was created with predicate matchers
|
|
20
|
+
# expect(chef_run).to create_user('apache2').with_uid(1234)
|
|
21
|
+
#
|
|
22
|
+
# @example Assert that a +user+ was created with attributes
|
|
23
|
+
# expect(chef_run).to create_user('apache2').with(uid: 1234)
|
|
24
|
+
#
|
|
25
|
+
# @example Assert that a +user+ was created using a regex
|
|
26
|
+
# expect(chef_run).to create_user('apache2').with(uid: /\d+/)
|
|
27
|
+
#
|
|
28
|
+
# @example Assert that a +user+ was _not_ created
|
|
29
|
+
# expect(chef_run).to_not create_user('apache2')
|
|
30
|
+
#
|
|
31
|
+
#
|
|
32
|
+
# @param [String, Regex] resource_name
|
|
33
|
+
# the name of the resource to match
|
|
34
|
+
#
|
|
35
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
36
|
+
#
|
|
37
|
+
def create_user(resource_name)
|
|
38
|
+
ChefSpec::Matchers::ResourceMatcher.new(:user, :create, resource_name)
|
|
39
|
+
end
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
41
|
+
#
|
|
42
|
+
# Assert that a +user+ resource exists in the Chef run with the
|
|
43
|
+
# action +:remove+. Given a Chef Recipe that removes "apache2" as a
|
|
44
|
+
# +user+:
|
|
45
|
+
#
|
|
46
|
+
# user 'apache2' do
|
|
47
|
+
# action :remove
|
|
48
|
+
# end
|
|
49
|
+
#
|
|
50
|
+
# The Examples section demonstrates the different ways to test a
|
|
51
|
+
# +user+ resource with ChefSpec.
|
|
52
|
+
#
|
|
53
|
+
# @example Assert that a +user+ was remove
|
|
54
|
+
# expect(chef_run).to remove_user('apache2')
|
|
55
|
+
#
|
|
56
|
+
# @example Assert that a +user+ was remove with predicate matchers
|
|
57
|
+
# expect(chef_run).to remove_user('apache2').with_uid(1234)
|
|
58
|
+
#
|
|
59
|
+
# @example Assert that a +user+ was remove with attributes
|
|
60
|
+
# expect(chef_run).to remove_user('apache2').with(uid: 1234)
|
|
61
|
+
#
|
|
62
|
+
# @example Assert that a +user+ was remove using a regex
|
|
63
|
+
# expect(chef_run).to remove_user('apache2').with(uid: /\d+/)
|
|
64
|
+
#
|
|
65
|
+
# @example Assert that a +user+ was _not_ remove
|
|
66
|
+
# expect(chef_run).to_not remove_user('apache2')
|
|
67
|
+
#
|
|
68
|
+
#
|
|
69
|
+
# @param [String, Regex] resource_name
|
|
70
|
+
# the name of the resource to match
|
|
71
|
+
#
|
|
72
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
73
|
+
#
|
|
74
|
+
def remove_user(resource_name)
|
|
75
|
+
ChefSpec::Matchers::ResourceMatcher.new(:user, :remove, resource_name)
|
|
76
|
+
end
|
|
79
77
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
78
|
+
#
|
|
79
|
+
# Assert that a +user+ resource exists in the Chef run with the
|
|
80
|
+
# action +:modify+. Given a Chef Recipe that modifies "apache2" as a
|
|
81
|
+
# +user+:
|
|
82
|
+
#
|
|
83
|
+
# user 'apache2' do
|
|
84
|
+
# action :modify
|
|
85
|
+
# end
|
|
86
|
+
#
|
|
87
|
+
# The Examples section demonstrates the different ways to test a
|
|
88
|
+
# +user+ resource with ChefSpec.
|
|
89
|
+
#
|
|
90
|
+
# @example Assert that a +user+ was modified
|
|
91
|
+
# expect(chef_run).to modify_user('apache2')
|
|
92
|
+
#
|
|
93
|
+
# @example Assert that a +user+ was modified with predicate matchers
|
|
94
|
+
# expect(chef_run).to modify_user('apache2').with_uid(1234)
|
|
95
|
+
#
|
|
96
|
+
# @example Assert that a +user+ was modified with attributes
|
|
97
|
+
# expect(chef_run).to modify_user('apache2').with(uid: 1234)
|
|
98
|
+
#
|
|
99
|
+
# @example Assert that a +user+ was modified using a regex
|
|
100
|
+
# expect(chef_run).to modify_user('apache2').with(uid: /\d+/)
|
|
101
|
+
#
|
|
102
|
+
# @example Assert that a +user+ was _not_ modified
|
|
103
|
+
# expect(chef_run).to_not modify_user('apache2')
|
|
104
|
+
#
|
|
105
|
+
#
|
|
106
|
+
# @param [String, Regex] resource_name
|
|
107
|
+
# the name of the resource to match
|
|
108
|
+
#
|
|
109
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
110
|
+
#
|
|
111
|
+
def modify_user(resource_name)
|
|
112
|
+
ChefSpec::Matchers::ResourceMatcher.new(:user, :modify, resource_name)
|
|
113
|
+
end
|
|
116
114
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
115
|
+
#
|
|
116
|
+
# Assert that a +user+ resource exists in the Chef run with the
|
|
117
|
+
# action +:manage+. Given a Chef Recipe that manages "apache2" as a
|
|
118
|
+
# +user+:
|
|
119
|
+
#
|
|
120
|
+
# user 'apache2' do
|
|
121
|
+
# action :manage
|
|
122
|
+
# end
|
|
123
|
+
#
|
|
124
|
+
# The Examples section demonstrates the different ways to test a
|
|
125
|
+
# +user+ resource with ChefSpec.
|
|
126
|
+
#
|
|
127
|
+
# @example Assert that a +user+ was managed
|
|
128
|
+
# expect(chef_run).to manage_user('apache2')
|
|
129
|
+
#
|
|
130
|
+
# @example Assert that a +user+ was managed with predicate matchers
|
|
131
|
+
# expect(chef_run).to manage_user('apache2').with_uid(1234)
|
|
132
|
+
#
|
|
133
|
+
# @example Assert that a +user+ was managed with attributes
|
|
134
|
+
# expect(chef_run).to manage_user('apache2').with(uid: 1234)
|
|
135
|
+
#
|
|
136
|
+
# @example Assert that a +user+ was managed using a regex
|
|
137
|
+
# expect(chef_run).to manage_user('apache2').with(uid: /\d+/)
|
|
138
|
+
#
|
|
139
|
+
# @example Assert that a +user+ was _not_ managed
|
|
140
|
+
# expect(chef_run).to_not manage_user('apache2')
|
|
141
|
+
#
|
|
142
|
+
#
|
|
143
|
+
# @param [String, Regex] resource_name
|
|
144
|
+
# the name of the resource to match
|
|
145
|
+
#
|
|
146
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
147
|
+
#
|
|
148
|
+
def manage_user(resource_name)
|
|
149
|
+
ChefSpec::Matchers::ResourceMatcher.new(:user, :manage, resource_name)
|
|
150
|
+
end
|
|
153
151
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
152
|
+
#
|
|
153
|
+
# Assert that a +user+ resource exists in the Chef run with the
|
|
154
|
+
# action +:lock+. Given a Chef Recipe that locks "apache2" as a
|
|
155
|
+
# +user+:
|
|
156
|
+
#
|
|
157
|
+
# user 'apache2' do
|
|
158
|
+
# action :lock
|
|
159
|
+
# end
|
|
160
|
+
#
|
|
161
|
+
# The Examples section demonstrates the different ways to test a
|
|
162
|
+
# +user+ resource with ChefSpec.
|
|
163
|
+
#
|
|
164
|
+
# @example Assert that a +user+ was locked
|
|
165
|
+
# expect(chef_run).to lock_user('apache2')
|
|
166
|
+
#
|
|
167
|
+
# @example Assert that a +user+ was locked with predicate matchers
|
|
168
|
+
# expect(chef_run).to lock_user('apache2').with_uid(1234)
|
|
169
|
+
#
|
|
170
|
+
# @example Assert that a +user+ was locked with attributes
|
|
171
|
+
# expect(chef_run).to lock_user('apache2').with(uid: 1234)
|
|
172
|
+
#
|
|
173
|
+
# @example Assert that a +user+ was locked using a regex
|
|
174
|
+
# expect(chef_run).to lock_user('apache2').with(uid: /\d+/)
|
|
175
|
+
#
|
|
176
|
+
# @example Assert that a +user+ was _not_ locked
|
|
177
|
+
# expect(chef_run).to_not lock_user('apache2')
|
|
178
|
+
#
|
|
179
|
+
#
|
|
180
|
+
# @param [String, Regex] resource_name
|
|
181
|
+
# the name of the resource to match
|
|
182
|
+
#
|
|
183
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
184
|
+
#
|
|
185
|
+
def lock_user(resource_name)
|
|
186
|
+
ChefSpec::Matchers::ResourceMatcher.new(:user, :lock, resource_name)
|
|
187
|
+
end
|
|
190
188
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
end
|
|
189
|
+
#
|
|
190
|
+
# Assert that a +user+ resource exists in the Chef run with the
|
|
191
|
+
# action +:unlock+. Given a Chef Recipe that unlocks "apache2" as a
|
|
192
|
+
# +user+:
|
|
193
|
+
#
|
|
194
|
+
# user 'apache2' do
|
|
195
|
+
# action :unlock
|
|
196
|
+
# end
|
|
197
|
+
#
|
|
198
|
+
# The Examples section demonstrates the different ways to test a
|
|
199
|
+
# +user+ resource with ChefSpec.
|
|
200
|
+
#
|
|
201
|
+
# @example Assert that a +user+ was unlocked
|
|
202
|
+
# expect(chef_run).to unlock_user('apache2')
|
|
203
|
+
#
|
|
204
|
+
# @example Assert that a +user+ was unlocked with predicate matchers
|
|
205
|
+
# expect(chef_run).to unlock_user('apache2').with_uid(1234)
|
|
206
|
+
#
|
|
207
|
+
# @example Assert that a +user+ was unlocked with attributes
|
|
208
|
+
# expect(chef_run).to unlock_user('apache2').with(uid: 1234)
|
|
209
|
+
#
|
|
210
|
+
# @example Assert that a +user+ was unlocked using a regex
|
|
211
|
+
# expect(chef_run).to unlock_user('apache2').with(uid: /\d+/)
|
|
212
|
+
#
|
|
213
|
+
# @example Assert that a +user+ was _not_ unlocked
|
|
214
|
+
# expect(chef_run).to_not unlock_user('apache2')
|
|
215
|
+
#
|
|
216
|
+
#
|
|
217
|
+
# @param [String, Regex] resource_name
|
|
218
|
+
# the name of the resource to match
|
|
219
|
+
#
|
|
220
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
221
|
+
#
|
|
222
|
+
def unlock_user(resource_name)
|
|
223
|
+
ChefSpec::Matchers::ResourceMatcher.new(:user, :unlock, resource_name)
|
|
227
224
|
end
|
|
228
225
|
end
|