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,22 +1,24 @@
|
|
|
1
1
|
require 'chefspec'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
if defined?(Chef::Resource::DnfPackage)
|
|
4
|
+
describe 'dnf_package::upgrade' do
|
|
5
|
+
let(:chef_run) do
|
|
6
|
+
ChefSpec::ServerRunner.new(platform: 'fedora', version: '25')
|
|
7
|
+
.converge(described_recipe)
|
|
8
|
+
end
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
it 'upgrades a dnf_package with an explicit action' do
|
|
11
|
+
expect(chef_run).to upgrade_dnf_package('explicit_action')
|
|
12
|
+
expect(chef_run).to_not upgrade_dnf_package('not_explicit_action')
|
|
13
|
+
end
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
it 'upgrades a dnf_package with attributes' do
|
|
16
|
+
expect(chef_run).to upgrade_dnf_package('with_attributes').with(version: '1.0.0')
|
|
17
|
+
expect(chef_run).to_not upgrade_dnf_package('with_attributes').with(version: '1.2.3')
|
|
18
|
+
end
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
it 'upgrades a dnf_package when specifying the identity attribute' do
|
|
21
|
+
expect(chef_run).to upgrade_dnf_package('identity_attribute')
|
|
22
|
+
end
|
|
21
23
|
end
|
|
22
24
|
end
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
require 'chefspec'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
if defined?(Chef::Resource::MsuPackage)
|
|
4
|
+
describe 'msu_package::install' do
|
|
5
|
+
let(:chef_run) do
|
|
6
|
+
ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
|
|
7
|
+
.converge(described_recipe)
|
|
8
|
+
end
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
it 'installs a msu_package with the default action' do
|
|
11
|
+
expect(chef_run).to install_msu_package('default_action')
|
|
12
|
+
expect(chef_run).to_not install_msu_package('not_default_action')
|
|
13
|
+
end
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
it 'installs a msu_package with an explicit action' do
|
|
16
|
+
expect(chef_run).to install_msu_package('explicit_action')
|
|
17
|
+
end
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
it 'installs a msu_package with attributes' do
|
|
20
|
+
expect(chef_run).to install_msu_package('with_attributes').with(version: '1.0.0')
|
|
21
|
+
expect(chef_run).to_not install_msu_package('with_attributes').with(version: '1.2.3')
|
|
22
|
+
end
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
it 'installs a msu_package when specifying the identity attribute' do
|
|
25
|
+
expect(chef_run).to install_msu_package('identity_attribute')
|
|
26
|
+
end
|
|
25
27
|
end
|
|
26
28
|
end
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
require 'chefspec'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
if defined?(Chef::Resource::MsuPackage)
|
|
4
|
+
describe 'msu_package::remove' do
|
|
5
|
+
let(:chef_run) do
|
|
6
|
+
ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
|
|
7
|
+
.converge(described_recipe)
|
|
8
|
+
end
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
it 'removes a msu_package with an explicit action' do
|
|
11
|
+
expect(chef_run).to remove_msu_package('explicit_action')
|
|
12
|
+
expect(chef_run).to_not remove_msu_package('not_explicit_action')
|
|
13
|
+
end
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
it 'removes a msu_package with attributes' do
|
|
16
|
+
expect(chef_run).to remove_msu_package('with_attributes').with(version: '1.0.0')
|
|
17
|
+
expect(chef_run).to_not remove_msu_package('with_attributes').with(version: '1.2.3')
|
|
18
|
+
end
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
it 'removes a msu_package when specifying the identity attribute' do
|
|
21
|
+
expect(chef_run).to remove_msu_package('identity_attribute')
|
|
22
|
+
end
|
|
21
23
|
end
|
|
22
24
|
end
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
require 'chefspec'
|
|
2
2
|
|
|
3
3
|
describe 'server::port' do
|
|
4
|
+
before(:all) do
|
|
5
|
+
@oldsetting = RSpec.configuration.server_runner_port
|
|
6
|
+
RSpec.configuration.server_runner_port = (8900..8910)
|
|
7
|
+
ChefSpec::ZeroServer.nuke!
|
|
8
|
+
ChefSpec::ZeroServer.setup!
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
after(:all) do
|
|
12
|
+
RSpec.configuration.server_runner_port = @oldsetting
|
|
13
|
+
ChefSpec::ZeroServer.nuke!
|
|
14
|
+
ChefSpec::ZeroServer.setup!
|
|
15
|
+
end
|
|
16
|
+
|
|
4
17
|
let(:chef_run) do
|
|
5
18
|
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04')
|
|
6
19
|
end
|
|
@@ -10,8 +23,8 @@ describe 'server::port' do
|
|
|
10
23
|
end
|
|
11
24
|
|
|
12
25
|
it 'creates a chef-zero listening on the right port' do
|
|
13
|
-
expect(ChefSpec::ZeroServer.server).to be_running
|
|
26
|
+
expect(ChefSpec::ZeroServer.server).to be_running
|
|
14
27
|
expect(ChefSpec::ZeroServer.server.port).to be_a(Integer)
|
|
15
|
-
expect(
|
|
28
|
+
expect(8890..9010).to include(ChefSpec::ZeroServer.server.port)
|
|
16
29
|
end
|
|
17
30
|
end
|
data/lib/chefspec.rb
CHANGED
|
@@ -42,14 +42,7 @@ module ChefSpec
|
|
|
42
42
|
module_function :matchers
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
require_relative 'chefspec/extensions
|
|
46
|
-
require_relative 'chefspec/extensions/chef/client'
|
|
47
|
-
require_relative 'chefspec/extensions/chef/conditional'
|
|
48
|
-
require_relative 'chefspec/extensions/chef/cookbook_uploader'
|
|
49
|
-
require_relative 'chefspec/extensions/chef/data_query'
|
|
50
|
-
require_relative 'chefspec/extensions/chef/lwrp_base'
|
|
51
|
-
require_relative 'chefspec/extensions/chef/resource'
|
|
52
|
-
require_relative 'chefspec/extensions/chef/resource/freebsd_package'
|
|
45
|
+
require_relative 'chefspec/extensions'
|
|
53
46
|
|
|
54
47
|
require_relative 'chefspec/mixins/normalize'
|
|
55
48
|
|
data/lib/chefspec/api.rb
CHANGED
|
@@ -1,96 +1,18 @@
|
|
|
1
1
|
module ChefSpec
|
|
2
2
|
module API
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def self.included(base)
|
|
6
|
-
submodules.each do |child|
|
|
7
|
-
base.send(:include, child)
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
#
|
|
14
|
-
# WARNING: This is metaprogramming madness. Find all modules who are
|
|
15
|
-
# nested beneath this module.
|
|
16
|
-
#
|
|
17
|
-
# @return [Array<Module>]
|
|
18
|
-
#
|
|
19
|
-
def submodules
|
|
20
|
-
self.constants
|
|
21
|
-
.map { |name| const_get(name) }
|
|
22
|
-
.select { |const| const.class == Module }
|
|
23
|
-
end
|
|
3
|
+
# empty container
|
|
24
4
|
end
|
|
25
5
|
end
|
|
26
6
|
|
|
27
|
-
|
|
28
|
-
require_relative 'api/apt_update'
|
|
29
|
-
require_relative 'api/apt_repository'
|
|
30
|
-
require_relative 'api/bff_package'
|
|
31
|
-
require_relative 'api/batch'
|
|
32
|
-
require_relative 'api/cab_package'
|
|
33
|
-
require_relative 'api/chef_gem'
|
|
34
|
-
require_relative 'api/chocolatey_package'
|
|
35
|
-
require_relative 'api/cookbook_file'
|
|
36
|
-
require_relative 'api/cron'
|
|
37
|
-
require_relative 'api/deploy'
|
|
38
|
-
require_relative 'api/directory'
|
|
39
|
-
require_relative 'api/dnf_package'
|
|
40
|
-
require_relative 'api/dpkg_package'
|
|
7
|
+
# non-resources
|
|
41
8
|
require_relative 'api/do_nothing'
|
|
42
|
-
require_relative 'api/dsc_resource'
|
|
43
|
-
require_relative 'api/dsc_script'
|
|
44
|
-
require_relative 'api/easy_install_package'
|
|
45
|
-
require_relative 'api/env'
|
|
46
|
-
require_relative 'api/erl_call'
|
|
47
|
-
require_relative 'api/execute'
|
|
48
|
-
require_relative 'api/file'
|
|
49
|
-
require_relative 'api/freebsd_package'
|
|
50
|
-
require_relative 'api/gem_package'
|
|
51
|
-
require_relative 'api/git'
|
|
52
|
-
require_relative 'api/group'
|
|
53
|
-
require_relative 'api/homebrew_package'
|
|
54
|
-
require_relative 'api/http_request'
|
|
55
|
-
require_relative 'api/ifconfig'
|
|
56
9
|
require_relative 'api/include_recipe'
|
|
57
|
-
require_relative 'api/ips_package'
|
|
58
|
-
require_relative 'api/launchd'
|
|
59
|
-
require_relative 'api/link'
|
|
60
|
-
require_relative 'api/log'
|
|
61
|
-
require_relative 'api/macports_package'
|
|
62
|
-
require_relative 'api/mdadm'
|
|
63
|
-
require_relative 'api/mount'
|
|
64
|
-
require_relative 'api/msu_package'
|
|
65
10
|
require_relative 'api/notifications'
|
|
66
|
-
require_relative 'api/ohai'
|
|
67
|
-
require_relative 'api/openbsd_package'
|
|
68
|
-
require_relative 'api/osx_profile'
|
|
69
|
-
require_relative 'api/package'
|
|
70
|
-
require_relative 'api/pacman_package'
|
|
71
|
-
require_relative 'api/paludis_package'
|
|
72
|
-
require_relative 'api/portage_package'
|
|
73
|
-
require_relative 'api/powershell_script'
|
|
74
|
-
require_relative 'api/reboot'
|
|
75
|
-
require_relative 'api/registry_key'
|
|
76
|
-
require_relative 'api/remote_directory'
|
|
77
|
-
require_relative 'api/remote_file'
|
|
78
11
|
require_relative 'api/render_file'
|
|
79
|
-
require_relative 'api/route'
|
|
80
|
-
require_relative 'api/rpm_package'
|
|
81
|
-
require_relative 'api/ruby_block'
|
|
82
|
-
require_relative 'api/script'
|
|
83
|
-
require_relative 'api/service'
|
|
84
|
-
require_relative 'api/smartos_package'
|
|
85
|
-
require_relative 'api/solaris_package'
|
|
86
12
|
require_relative 'api/state_attrs'
|
|
87
13
|
require_relative 'api/subscriptions'
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
require_relative 'api/template'
|
|
14
|
+
|
|
15
|
+
# hacks and sugar for resources that don't follow the normal pattern
|
|
91
16
|
require_relative 'api/user'
|
|
92
|
-
require_relative 'api/
|
|
93
|
-
require_relative 'api/
|
|
94
|
-
require_relative 'api/yum_package'
|
|
95
|
-
require_relative 'api/yum_repository'
|
|
96
|
-
require_relative 'api/zypper_package'
|
|
17
|
+
require_relative 'api/link'
|
|
18
|
+
require_relative 'api/reboot'
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
module ChefSpec::API
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def do_nothing
|
|
21
|
-
ChefSpec::Matchers::DoNothingMatcher.new
|
|
22
|
-
end
|
|
2
|
+
#
|
|
3
|
+
# Assert that a resource in the Chef run does not perform any actions. Given
|
|
4
|
+
# a resource with +action :nothing+:
|
|
5
|
+
#
|
|
6
|
+
# package 'apache2' do
|
|
7
|
+
# action :nothing
|
|
8
|
+
# end
|
|
9
|
+
#
|
|
10
|
+
# The Examples section demonstrates the different ways to test that no
|
|
11
|
+
# actions were performed on a resource in a Chef run.
|
|
12
|
+
#
|
|
13
|
+
# @example Assert the +package+ does not perform any actions
|
|
14
|
+
#
|
|
15
|
+
#
|
|
16
|
+
# @return [ChefSpec::Matchers::DoNothingMatcher]
|
|
17
|
+
#
|
|
18
|
+
def do_nothing
|
|
19
|
+
ChefSpec::Matchers::DoNothingMatcher.new
|
|
23
20
|
end
|
|
24
21
|
end
|
|
@@ -1,26 +1,23 @@
|
|
|
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
|
-
def include_recipe(recipe_name)
|
|
23
|
-
ChefSpec::Matchers::IncludeRecipeMatcher.new(recipe_name)
|
|
24
|
-
end
|
|
2
|
+
#
|
|
3
|
+
# Assert that a Chef run includes a certain recipe. Given a Chef Recipe
|
|
4
|
+
# that calls +include_recipe+:
|
|
5
|
+
#
|
|
6
|
+
# include_recipe 'apache2::default'
|
|
7
|
+
#
|
|
8
|
+
# The Examples section demonstrates the different ways to test an
|
|
9
|
+
# +include_recipe+ directive with ChefSpec.
|
|
10
|
+
#
|
|
11
|
+
# @example Assert the +apache2::default+ recipe is included in the Chef run
|
|
12
|
+
# expect(chef_run).to include_recipe('apache2::default')
|
|
13
|
+
#
|
|
14
|
+
#
|
|
15
|
+
# @param [String] recipe_name
|
|
16
|
+
# the name of the recipe to be included
|
|
17
|
+
#
|
|
18
|
+
# @return [ChefSpec::Matchers::IncludeRecipeMatcher]
|
|
19
|
+
#
|
|
20
|
+
def include_recipe(recipe_name)
|
|
21
|
+
ChefSpec::Matchers::IncludeRecipeMatcher.new(recipe_name)
|
|
25
22
|
end
|
|
26
23
|
end
|
data/lib/chefspec/api/link.rb
CHANGED
|
@@ -1,102 +1,23 @@
|
|
|
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
|
-
# expect(chef_run).to create_link('/tmp').with_link_type(:hard)
|
|
23
|
-
#
|
|
24
|
-
# @example Assert that a +link+ was created with attributes
|
|
25
|
-
# expect(chef_run).to create_link('/tmp').with(link_type: :hard)
|
|
26
|
-
#
|
|
27
|
-
# @example Assert that a +link+ was created using a regex
|
|
28
|
-
# expect(chef_run).to create_link('/tmp').with(link_type: Symbol)
|
|
29
|
-
#
|
|
30
|
-
# @example Assert that a +link+ was _not_ created
|
|
31
|
-
# expect(chef_run).to_not create_link('/tmp')
|
|
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_link(resource_name)
|
|
40
|
-
ChefSpec::Matchers::ResourceMatcher.new(:link, :create, resource_name)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
#
|
|
44
|
-
# Assert that a +link+ resource exists in the Chef run with the
|
|
45
|
-
# action +:delete+. Given a Chef Recipe that deletes "/tmp" as a
|
|
46
|
-
# +link+:
|
|
47
|
-
#
|
|
48
|
-
# link '/tmp' do
|
|
49
|
-
# action :delete
|
|
50
|
-
# end
|
|
51
|
-
#
|
|
52
|
-
# The Examples section demonstrates the different ways to test a
|
|
53
|
-
# +link+ resource with ChefSpec.
|
|
54
|
-
#
|
|
55
|
-
# @example Assert that a +link+ was deleted
|
|
56
|
-
# expect(chef_run).to delete_link('/tmp')
|
|
57
|
-
#
|
|
58
|
-
# @example Assert that a +link+ was deleted with predicate matchers
|
|
59
|
-
# expect(chef_run).to delete_link('/tmp').with_link_type(:hard)
|
|
60
|
-
#
|
|
61
|
-
# @example Assert that a +link+ was deleted with attributes
|
|
62
|
-
# expect(chef_run).to delete_link('/tmp').with(link_type: :hard)
|
|
63
|
-
#
|
|
64
|
-
# @example Assert that a +link+ was deleted using a regex
|
|
65
|
-
# expect(chef_run).to delete_link('/tmp').with(link_type: Symbol)
|
|
66
|
-
#
|
|
67
|
-
# @example Assert that a +link+ was _not_ deleted
|
|
68
|
-
# expect(chef_run).to_not delete_link('/tmp')
|
|
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_link(resource_name)
|
|
77
|
-
ChefSpec::Matchers::ResourceMatcher.new(:link, :delete, resource_name)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
#
|
|
81
|
-
# Assert that a symlink links to a specific path. This is really
|
|
82
|
-
# syntactic sugar for the following:
|
|
83
|
-
#
|
|
84
|
-
# expect(chef_run).to create_link('/tmp/thing').with(to: '/tmp/other_thing')
|
|
85
|
-
#
|
|
86
|
-
# @example Using +link_to+ with a String path
|
|
87
|
-
# link = chef_run.link('/tmp/thing')
|
|
88
|
-
# expect(link).to link_to('/tmp/other_thing')
|
|
89
|
-
#
|
|
90
|
-
# @example Using +link_to+ with a regular expression
|
|
91
|
-
# expect(link).to link_to(/\/tmp/(.+)/)
|
|
92
|
-
#
|
|
93
|
-
# @param [String, Regex] path
|
|
94
|
-
# the path to link to
|
|
95
|
-
#
|
|
96
|
-
# @return [ChefSpec::Matchers::LinkToMatcher]
|
|
97
|
-
#
|
|
98
|
-
def link_to(path)
|
|
99
|
-
ChefSpec::Matchers::LinkToMatcher.new(path)
|
|
100
|
-
end
|
|
2
|
+
#
|
|
3
|
+
# Assert that a symlink links to a specific path. This is really
|
|
4
|
+
# syntactic sugar for the following:
|
|
5
|
+
#
|
|
6
|
+
# expect(chef_run).to create_link('/tmp/thing').with(to: '/tmp/other_thing')
|
|
7
|
+
#
|
|
8
|
+
# @example Using +link_to+ with a String path
|
|
9
|
+
# link = chef_run.link('/tmp/thing')
|
|
10
|
+
# expect(link).to link_to('/tmp/other_thing')
|
|
11
|
+
#
|
|
12
|
+
# @example Using +link_to+ with a regular expression
|
|
13
|
+
# expect(link).to link_to(/\/tmp/(.+)/)
|
|
14
|
+
#
|
|
15
|
+
# @param [String, Regex] path
|
|
16
|
+
# the path to link to
|
|
17
|
+
#
|
|
18
|
+
# @return [ChefSpec::Matchers::LinkToMatcher]
|
|
19
|
+
#
|
|
20
|
+
def link_to(path)
|
|
21
|
+
ChefSpec::Matchers::LinkToMatcher.new(path)
|
|
101
22
|
end
|
|
102
23
|
end
|