chefspec 4.2.0 → 4.7.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/.gitignore +1 -0
- data/.travis.yml +39 -16
- data/CHANGELOG.md +136 -72
- data/README.md +187 -13
- data/chefspec.gemspec +5 -5
- data/examples/batch/spec/run_spec.rb +5 -0
- data/examples/chef_gem/recipes/install.rb +8 -3
- data/examples/chef_gem/recipes/purge.rb +6 -3
- data/examples/chef_gem/recipes/reconfig.rb +6 -3
- data/examples/chef_gem/recipes/remove.rb +6 -3
- data/examples/chef_gem/recipes/upgrade.rb +6 -3
- data/examples/chocolatey_package/recipes/install.rb +6 -0
- data/examples/chocolatey_package/recipes/remove.rb +8 -0
- data/examples/chocolatey_package/recipes/upgrade.rb +8 -0
- data/examples/chocolatey_package/spec/install_spec.rb +21 -0
- data/examples/chocolatey_package/spec/remove_spec.rb +20 -0
- data/examples/chocolatey_package/spec/upgrade_spec.rb +20 -0
- data/examples/directory/recipes/create.rb +4 -0
- data/examples/directory/spec/create_spec.rb +4 -0
- data/examples/dpkg_package/spec/install_spec.rb +5 -0
- data/examples/dpkg_package/spec/purge_spec.rb +5 -0
- data/examples/dpkg_package/spec/remove_spec.rb +5 -0
- data/examples/dsc_resource/recipes/default.rb +20 -0
- data/examples/dsc_resource/spec/default_spec.rb +40 -0
- data/examples/env/spec/create_spec.rb +5 -0
- data/examples/env/spec/delete_spec.rb +5 -0
- data/examples/env/spec/modify_spec.rb +5 -0
- data/examples/ips_package/spec/install_spec.rb +5 -0
- data/examples/ips_package/spec/remove_spec.rb +5 -0
- data/examples/ips_package/spec/upgrade_spec.rb +5 -0
- data/examples/package/recipes/install.rb +4 -0
- data/examples/package/recipes/purge.rb +4 -0
- data/examples/package/recipes/reconfig.rb +4 -0
- data/examples/package/recipes/remove.rb +4 -0
- data/examples/package/recipes/upgrade.rb +4 -0
- data/examples/package/spec/install_spec.rb +4 -0
- data/examples/package/spec/purge_spec.rb +4 -0
- data/examples/package/spec/reconfig_spec.rb +4 -0
- data/examples/package/spec/remove_spec.rb +4 -0
- data/examples/package/spec/upgrade_spec.rb +4 -0
- data/examples/pacman_package/spec/install_spec.rb +5 -0
- data/examples/pacman_package/spec/purge_spec.rb +5 -0
- data/examples/pacman_package/spec/remove_spec.rb +5 -0
- data/examples/pacman_package/spec/upgrade_spec.rb +5 -0
- data/examples/powershell_script/spec/run_spec.rb +5 -0
- data/examples/reboot/recipes/cancel.rb +3 -0
- data/examples/reboot/recipes/now.rb +3 -0
- data/examples/reboot/recipes/request.rb +3 -0
- data/examples/reboot/spec/cancel_spec.rb +10 -0
- data/examples/reboot/spec/now_spec.rb +10 -0
- data/examples/reboot/spec/request_spec.rb +10 -0
- data/examples/render_file/spec/default_spec.rb +40 -0
- data/examples/rpm_package/spec/install_spec.rb +5 -0
- data/examples/rpm_package/spec/remove_spec.rb +5 -0
- data/examples/rpm_package/spec/upgrade_spec.rb +5 -0
- data/examples/server/spec/node_spec.rb +1 -1
- data/examples/server/spec/search_spec.rb +4 -0
- data/examples/step_into/providers/provides.rb +3 -0
- data/examples/step_into/recipes/default.rb +2 -0
- data/examples/step_into/resources/lwrp.rb +1 -1
- data/examples/step_into/resources/provides.rb +6 -0
- data/examples/step_into/spec/default_spec.rb +10 -2
- data/examples/windows_package/recipes/install.rb +13 -0
- data/examples/windows_package/recipes/remove.rb +13 -0
- data/examples/windows_package/spec/install_spec.rb +24 -0
- data/examples/windows_package/spec/remove_spec.rb +24 -0
- data/examples/windows_service/recipes/configure_startup.rb +13 -0
- data/examples/windows_service/recipes/disable.rb +13 -0
- data/examples/windows_service/recipes/enable.rb +13 -0
- data/examples/windows_service/recipes/reload.rb +13 -0
- data/examples/windows_service/recipes/restart.rb +13 -0
- data/examples/windows_service/recipes/start.rb +13 -0
- data/examples/windows_service/recipes/stop.rb +13 -0
- data/examples/windows_service/spec/configure_startup_spec.rb +24 -0
- data/examples/windows_service/spec/disable_spec.rb +24 -0
- data/examples/windows_service/spec/enable_spec.rb +24 -0
- data/examples/windows_service/spec/reload_spec.rb +24 -0
- data/examples/windows_service/spec/restart_spec.rb +24 -0
- data/examples/windows_service/spec/start_spec.rb +24 -0
- data/examples/windows_service/spec/stop_spec.rb +24 -0
- data/features/chocolatey_package.feature +29 -0
- data/features/dsc_resource.feature +18 -0
- data/features/reboot.feature +19 -0
- data/features/step_definitions/background_steps.rb +4 -1
- data/features/step_into.feature +7 -0
- data/features/support/env.rb +5 -4
- data/features/windows_package.feature +24 -0
- data/features/windows_service.feature +23 -0
- data/gemfiles/chefspec.gemfile +9 -0
- data/lib/chefspec/api/chocolatey_package.rb +107 -0
- data/lib/chefspec/api/directory.rb +10 -10
- data/lib/chefspec/api/dsc_resource.rb +49 -0
- data/lib/chefspec/api/group.rb +5 -5
- data/lib/chefspec/api/link.rb +10 -10
- data/lib/chefspec/api/mdadm.rb +5 -5
- data/lib/chefspec/api/reboot.rb +18 -0
- data/lib/chefspec/api/remote_directory.rb +10 -10
- data/lib/chefspec/api/route.rb +5 -5
- data/lib/chefspec/api/user.rb +5 -5
- data/lib/chefspec/api/windows_package.rb +86 -0
- data/lib/chefspec/api/windows_service.rb +286 -0
- data/lib/chefspec/api.rb +5 -0
- data/lib/chefspec/berkshelf.rb +7 -1
- data/lib/chefspec/coverage/filters.rb +2 -1
- data/lib/chefspec/coverage.rb +1 -1
- data/lib/chefspec/deprecations.rb +6 -2
- data/lib/chefspec/errors.rb +4 -0
- data/lib/chefspec/extensions/chef/lwrp_base.rb +23 -0
- data/lib/chefspec/file_cache_path_proxy.rb +15 -0
- data/lib/chefspec/matchers/render_file_matcher.rb +20 -2
- data/lib/chefspec/matchers/resource_matcher.rb +9 -2
- data/lib/chefspec/mixins/normalize.rb +7 -1
- data/lib/chefspec/policyfile.rb +62 -0
- data/lib/chefspec/renderer.rb +2 -4
- data/lib/chefspec/rspec.rb +3 -0
- data/lib/chefspec/server_methods.rb +1 -0
- data/lib/chefspec/server_runner.rb +9 -0
- data/lib/chefspec/solo_runner.rb +13 -3
- data/lib/chefspec/version.rb +1 -1
- data/lib/chefspec.rb +1 -1
- data/spec/unit/coverage/filters_spec.rb +60 -0
- data/spec/unit/deprecations_spec.rb +3 -1
- data/spec/unit/macros_spec.rb +1 -1
- data/spec/unit/matchers/render_file_matcher_spec.rb +11 -0
- data/spec/unit/renderer_spec.rb +20 -2
- data/spec/unit/server_runner_spec.rb +28 -0
- data/spec/unit/solo_runner_spec.rb +3 -1
- data/templates/errors/invalid_berkshelf_options.erb +4 -0
- data/templates/errors/may_need_to_specify_platform.erb +25 -0
- metadata +72 -18
- data/gemfiles/chef-11.14.0.gemfile +0 -5
- data/gemfiles/chef-11.16.0.gemfile +0 -5
- data/gemfiles/chef-12.0.0.gemfile +0 -5
- data/gemfiles/chef-master.gemfile +0 -5
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module ChefSpec::API
|
|
2
|
+
# @since 0.5.0
|
|
3
|
+
module RebootMatchers
|
|
4
|
+
ChefSpec.define_matcher :reboot
|
|
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
|
|
13
|
+
|
|
14
|
+
def cancel_reboot(resource_name)
|
|
15
|
+
ChefSpec::Matchers::ResourceMatcher.new(:reboot, :cancel, resource_name)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -15,19 +15,19 @@ module ChefSpec::API
|
|
|
15
15
|
# The Examples section demonstrates the different ways to test a
|
|
16
16
|
# +remote_directory+ resource with ChefSpec.
|
|
17
17
|
#
|
|
18
|
-
# @example Assert that a +remote_directory+ was
|
|
18
|
+
# @example Assert that a +remote_directory+ was created
|
|
19
19
|
# expect(chef_run).to create_remote_directory('/tmp')
|
|
20
20
|
#
|
|
21
|
-
# @example Assert that a +remote_directory+ was
|
|
21
|
+
# @example Assert that a +remote_directory+ was created with predicate matchers
|
|
22
22
|
# expect(chef_run).to create_remote_directory('/tmp').with_overwrite(true)
|
|
23
23
|
#
|
|
24
|
-
# @example Assert that a +remote_directory+ was
|
|
24
|
+
# @example Assert that a +remote_directory+ was created with attributes
|
|
25
25
|
# expect(chef_run).to create_remote_directory('/tmp').with(overwrite: true)
|
|
26
26
|
#
|
|
27
|
-
# @example Assert that a +remote_directory+ was
|
|
27
|
+
# @example Assert that a +remote_directory+ was created using a regex
|
|
28
28
|
# expect(chef_run).to create_remote_directory('/tmp').with(overwrite: /true/)
|
|
29
29
|
#
|
|
30
|
-
# @example Assert that a +remote_directory+ was _not_
|
|
30
|
+
# @example Assert that a +remote_directory+ was _not_ created
|
|
31
31
|
# expect(chef_run).to_not create_remote_directory('/tmp')
|
|
32
32
|
#
|
|
33
33
|
#
|
|
@@ -92,19 +92,19 @@ module ChefSpec::API
|
|
|
92
92
|
# The Examples section demonstrates the different ways to test a
|
|
93
93
|
# +remote_directory+ resource with ChefSpec.
|
|
94
94
|
#
|
|
95
|
-
# @example Assert that a +remote_directory+ was
|
|
95
|
+
# @example Assert that a +remote_directory+ was deleted
|
|
96
96
|
# expect(chef_run).to delete_remote_directory('/tmp')
|
|
97
97
|
#
|
|
98
|
-
# @example Assert that a +remote_directory+ was
|
|
98
|
+
# @example Assert that a +remote_directory+ was deleted with predicate matchers
|
|
99
99
|
# expect(chef_run).to delete_remote_directory('/tmp').with_overwrite(true)
|
|
100
100
|
#
|
|
101
|
-
# @example Assert that a +remote_directory+ was
|
|
101
|
+
# @example Assert that a +remote_directory+ was deleted with attributes
|
|
102
102
|
# expect(chef_run).to delete_remote_directory('/tmp').with(overwrite: true)
|
|
103
103
|
#
|
|
104
|
-
# @example Assert that a +remote_directory+ was
|
|
104
|
+
# @example Assert that a +remote_directory+ was deleted using a regex
|
|
105
105
|
# expect(chef_run).to delete_remote_directory('/tmp').with(overwrite: /true/)
|
|
106
106
|
#
|
|
107
|
-
# @example Assert that a +remote_directory+ was _not_
|
|
107
|
+
# @example Assert that a +remote_directory+ was _not_ deleted
|
|
108
108
|
# expect(chef_run).to_not delete_remote_directory('/tmp')
|
|
109
109
|
#
|
|
110
110
|
#
|
data/lib/chefspec/api/route.rb
CHANGED
|
@@ -52,19 +52,19 @@ module ChefSpec::API
|
|
|
52
52
|
# The Examples section demonstrates the different ways to test a
|
|
53
53
|
# +route+ resource with ChefSpec.
|
|
54
54
|
#
|
|
55
|
-
# @example Assert that a +route+ was
|
|
55
|
+
# @example Assert that a +route+ was deleted
|
|
56
56
|
# expect(chef_run).to delete_route('10.0.0.10/32')
|
|
57
57
|
#
|
|
58
|
-
# @example Assert that a +route+ was
|
|
58
|
+
# @example Assert that a +route+ was deleted with predicate matchers
|
|
59
59
|
# expect(chef_run).to delete_route('10.0.0.10/32').with_device('eth0')
|
|
60
60
|
#
|
|
61
|
-
# @example Assert that a +route+ was
|
|
61
|
+
# @example Assert that a +route+ was deleted with attributes
|
|
62
62
|
# expect(chef_run).to delete_route('10.0.0.10/32').with(device: 'eth0')
|
|
63
63
|
#
|
|
64
|
-
# @example Assert that a +route+ was
|
|
64
|
+
# @example Assert that a +route+ was deleted using a regex
|
|
65
65
|
# expect(chef_run).to delete_route('10.0.0.10/32').with(device: /eth(\d+)/)
|
|
66
66
|
#
|
|
67
|
-
# @example Assert that a +route+ was _not_
|
|
67
|
+
# @example Assert that a +route+ was _not_ deleted
|
|
68
68
|
# expect(chef_run).to_not delete_route('10.0.0.10/32')
|
|
69
69
|
#
|
|
70
70
|
#
|
data/lib/chefspec/api/user.rb
CHANGED
|
@@ -15,19 +15,19 @@ module ChefSpec::API
|
|
|
15
15
|
# The Examples section demonstrates the different ways to test a
|
|
16
16
|
# +user+ resource with ChefSpec.
|
|
17
17
|
#
|
|
18
|
-
# @example Assert that a +user+ was
|
|
18
|
+
# @example Assert that a +user+ was created
|
|
19
19
|
# expect(chef_run).to create_user('apache2')
|
|
20
20
|
#
|
|
21
|
-
# @example Assert that a +user+ was
|
|
21
|
+
# @example Assert that a +user+ was created with predicate matchers
|
|
22
22
|
# expect(chef_run).to create_user('apache2').with_uid(1234)
|
|
23
23
|
#
|
|
24
|
-
# @example Assert that a +user+ was
|
|
24
|
+
# @example Assert that a +user+ was created with attributes
|
|
25
25
|
# expect(chef_run).to create_user('apache2').with(uid: 1234)
|
|
26
26
|
#
|
|
27
|
-
# @example Assert that a +user+ was
|
|
27
|
+
# @example Assert that a +user+ was created using a regex
|
|
28
28
|
# expect(chef_run).to create_user('apache2').with(uid: /\d+/)
|
|
29
29
|
#
|
|
30
|
-
# @example Assert that a +user+ was _not_
|
|
30
|
+
# @example Assert that a +user+ was _not_ created
|
|
31
31
|
# expect(chef_run).to_not create_user('apache2')
|
|
32
32
|
#
|
|
33
33
|
#
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
module ChefSpec::API
|
|
2
|
+
# @since 0.5.0
|
|
3
|
+
module WindowsPackageMatchers
|
|
4
|
+
ChefSpec.define_matcher :windows_package
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
# Assert that a +windows_package+ resource exists in the Chef run with the
|
|
8
|
+
# action +:install+. Given a Chef Recipe that installs "7zip" as a
|
|
9
|
+
# +windows_package+:
|
|
10
|
+
#
|
|
11
|
+
# windows_package '7zip' do
|
|
12
|
+
# action :install
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# To test the content rendered by a +windows_package+, see
|
|
16
|
+
# {ChefSpec::API::RenderFileMatchers}.
|
|
17
|
+
#
|
|
18
|
+
# The Examples section demonstrates the different ways to test a
|
|
19
|
+
# +windows_package+ resource with ChefSpec.
|
|
20
|
+
#
|
|
21
|
+
# @example Assert that a +windows_package+ was installed
|
|
22
|
+
# expect(chef_run).to install_windows_package('7zip')
|
|
23
|
+
#
|
|
24
|
+
# @example Assert that a +windows_package+ was installed with predicate matchers
|
|
25
|
+
# expect(chef_run).to install_windows_package('7zip').with_pattern('BI*')
|
|
26
|
+
#
|
|
27
|
+
# @example Assert that a +windows_package+ was installed with attributes
|
|
28
|
+
# expect(chef_run).to install_windows_package('7zip').with(pattern: 'BI*')
|
|
29
|
+
#
|
|
30
|
+
# @example Assert that a +windows_package+ was installed using a regex
|
|
31
|
+
# expect(chef_run).to install_windows_package('7zip').with(pattern: /(.+)/)
|
|
32
|
+
#
|
|
33
|
+
# @example Assert that a +windows_package+ was _not_ installed
|
|
34
|
+
# expect(chef_run).to_not install_windows_package('7zip')
|
|
35
|
+
#
|
|
36
|
+
#
|
|
37
|
+
# @param [String, Regex] resource_name
|
|
38
|
+
# the name of the resource to match
|
|
39
|
+
#
|
|
40
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
41
|
+
#
|
|
42
|
+
def install_windows_package(resource_name)
|
|
43
|
+
ChefSpec::Matchers::ResourceMatcher.new(:windows_package, :install, resource_name)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
#
|
|
47
|
+
# Assert that a +windows_package+ resource exists in the Chef run with the
|
|
48
|
+
# action +:remove+. Given a Chef Recipe that removes "7zip" as a
|
|
49
|
+
# +windows_package+:
|
|
50
|
+
#
|
|
51
|
+
# windows_package '7zip' do
|
|
52
|
+
# action :remove
|
|
53
|
+
# end
|
|
54
|
+
#
|
|
55
|
+
# To test the content rendered by a +windows_package+, see
|
|
56
|
+
# {ChefSpec::API::RenderFileMatchers}.
|
|
57
|
+
#
|
|
58
|
+
# The Examples section demonstrates the different ways to test a
|
|
59
|
+
# +windows_package+ resource with ChefSpec.
|
|
60
|
+
#
|
|
61
|
+
# @example Assert that a +windows_package+ was removeped
|
|
62
|
+
# expect(chef_run).to remove_windows_package('7zip')
|
|
63
|
+
#
|
|
64
|
+
# @example Assert that a +windows_package+ was removeped with predicate matchers
|
|
65
|
+
# expect(chef_run).to remove_windows_package('7zip').with_pattern('BI*')
|
|
66
|
+
#
|
|
67
|
+
# @example Assert that a +windows_package+ was removeped with attributes
|
|
68
|
+
# expect(chef_run).to remove_windows_package('7zip').with(pattern: 'BI*')
|
|
69
|
+
#
|
|
70
|
+
# @example Assert that a +windows_package+ was removeped using a regex
|
|
71
|
+
# expect(chef_run).to remove_windows_package('7zip').with(pattern: /(.+)/)
|
|
72
|
+
#
|
|
73
|
+
# @example Assert that a +windows_package+ was _not_ removeped
|
|
74
|
+
# expect(chef_run).to_not remove_windows_package('7zip')
|
|
75
|
+
#
|
|
76
|
+
#
|
|
77
|
+
# @param [String, Regex] resource_name
|
|
78
|
+
# the name of the resource to match
|
|
79
|
+
#
|
|
80
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
81
|
+
#
|
|
82
|
+
def remove_windows_package(resource_name)
|
|
83
|
+
ChefSpec::Matchers::ResourceMatcher.new(:windows_package, :remove, resource_name)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
module ChefSpec::API
|
|
2
|
+
# @since 0.5.0
|
|
3
|
+
module WindowsServiceMatchers
|
|
4
|
+
ChefSpec.define_matcher :windows_service
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
# Assert that a +windows_service+ resource exists in the Chef run with the
|
|
8
|
+
# action +:configure_startup+. Given a Chef Recipe that configures startup for "BITS" as a
|
|
9
|
+
# +windows_service+:
|
|
10
|
+
#
|
|
11
|
+
# windows_service 'BITS' do
|
|
12
|
+
# action :configure_startup
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# To test the content rendered by a +windows_service+, see
|
|
16
|
+
# {ChefSpec::API::RenderFileMatchers}.
|
|
17
|
+
#
|
|
18
|
+
# The Examples section demonstrates the different ways to test a
|
|
19
|
+
# +windows_service+ resource with ChefSpec.
|
|
20
|
+
#
|
|
21
|
+
# @example Assert that a +windows_service+ had its startup configured
|
|
22
|
+
# expect(chef_run).to disable_windows_service('BITS')
|
|
23
|
+
#
|
|
24
|
+
# @example Assert that a +windows_service+ had its startup configured with predicate matchers
|
|
25
|
+
# expect(chef_run).to disable_windows_service('BITS').with_pattern('BI*')
|
|
26
|
+
#
|
|
27
|
+
# @example Assert that a +windows_service+ had its startup configured with attributes
|
|
28
|
+
# expect(chef_run).to disable_windows_service('BITS').with(pattern: 'BI*')
|
|
29
|
+
#
|
|
30
|
+
# @example Assert that a +windows_service+ had its startup configured using a regex
|
|
31
|
+
# expect(chef_run).to disable_windows_service('BITS').with(pattern: /(.+)/)
|
|
32
|
+
#
|
|
33
|
+
# @example Assert that a +windows_service+ did _not_ have its startup configured
|
|
34
|
+
# expect(chef_run).to_not disable_windows_service('BITS')
|
|
35
|
+
#
|
|
36
|
+
#
|
|
37
|
+
# @param [String, Regex] resource_name
|
|
38
|
+
# the name of the resource to match
|
|
39
|
+
#
|
|
40
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
41
|
+
#
|
|
42
|
+
def configure_startup_windows_service(resource_name)
|
|
43
|
+
ChefSpec::Matchers::ResourceMatcher.new(:windows_service, :configure_startup, resource_name)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
#
|
|
47
|
+
# Assert that a +windows_service+ resource exists in the Chef run with the
|
|
48
|
+
# action +:disable+. Given a Chef Recipe that disables "BITS" as a
|
|
49
|
+
# +windows_service+:
|
|
50
|
+
#
|
|
51
|
+
# windows_service 'BITS' do
|
|
52
|
+
# action :disable
|
|
53
|
+
# end
|
|
54
|
+
#
|
|
55
|
+
# To test the content rendered by a +windows_service+, see
|
|
56
|
+
# {ChefSpec::API::RenderFileMatchers}.
|
|
57
|
+
#
|
|
58
|
+
# The Examples section demonstrates the different ways to test a
|
|
59
|
+
# +windows_service+ resource with ChefSpec.
|
|
60
|
+
#
|
|
61
|
+
# @example Assert that a +windows_service+ was disabled
|
|
62
|
+
# expect(chef_run).to disable_windows_service('BITS')
|
|
63
|
+
#
|
|
64
|
+
# @example Assert that a +windows_service+ was disabled with predicate matchers
|
|
65
|
+
# expect(chef_run).to disable_windows_service('BITS').with_pattern('BI*')
|
|
66
|
+
#
|
|
67
|
+
# @example Assert that a +windows_service+ was disabled with attributes
|
|
68
|
+
# expect(chef_run).to disable_windows_service('BITS').with(pattern: 'BI*')
|
|
69
|
+
#
|
|
70
|
+
# @example Assert that a +windows_service+ was disabled using a regex
|
|
71
|
+
# expect(chef_run).to disable_windows_service('BITS').with(pattern: /(.+)/)
|
|
72
|
+
#
|
|
73
|
+
# @example Assert that a +windows_service+ was _not_ disabled
|
|
74
|
+
# expect(chef_run).to_not disable_windows_service('BITS')
|
|
75
|
+
#
|
|
76
|
+
#
|
|
77
|
+
# @param [String, Regex] resource_name
|
|
78
|
+
# the name of the resource to match
|
|
79
|
+
#
|
|
80
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
81
|
+
#
|
|
82
|
+
def disable_windows_service(resource_name)
|
|
83
|
+
ChefSpec::Matchers::ResourceMatcher.new(:windows_service, :disable, resource_name)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
#
|
|
87
|
+
# Assert that a +windows_service+ resource exists in the Chef run with the
|
|
88
|
+
# action +:enable+. Given a Chef Recipe that enables "BITS" as a
|
|
89
|
+
# +windows_service+:
|
|
90
|
+
#
|
|
91
|
+
# windows_service 'BITS' do
|
|
92
|
+
# action :enable
|
|
93
|
+
# end
|
|
94
|
+
#
|
|
95
|
+
# To test the content rendered by a +windows_service+, see
|
|
96
|
+
# {ChefSpec::API::RenderFileMatchers}.
|
|
97
|
+
#
|
|
98
|
+
# The Examples section demonstrates the different ways to test a
|
|
99
|
+
# +windows_service+ resource with ChefSpec.
|
|
100
|
+
#
|
|
101
|
+
# @example Assert that a +windows_service+ was enabled
|
|
102
|
+
# expect(chef_run).to enable_windows_service('BITS')
|
|
103
|
+
#
|
|
104
|
+
# @example Assert that a +windows_service+ was enabled with predicate matchers
|
|
105
|
+
# expect(chef_run).to enable_windows_service('BITS').with_pattern('BI*')
|
|
106
|
+
#
|
|
107
|
+
# @example Assert that a +windows_service+ was enabled with attributes
|
|
108
|
+
# expect(chef_run).to enable_windows_service('BITS').with(pattern: 'BI*')
|
|
109
|
+
#
|
|
110
|
+
# @example Assert that a +windows_service+ was enabled using a regex
|
|
111
|
+
# expect(chef_run).to enable_windows_service('BITS').with(pattern: /(.+)/)
|
|
112
|
+
#
|
|
113
|
+
# @example Assert that a +windows_service+ was _not_ enabled
|
|
114
|
+
# expect(chef_run).to_not enable_windows_service('BITS')
|
|
115
|
+
#
|
|
116
|
+
#
|
|
117
|
+
# @param [String, Regex] resource_name
|
|
118
|
+
# the name of the resource to match
|
|
119
|
+
#
|
|
120
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
121
|
+
#
|
|
122
|
+
def enable_windows_service(resource_name)
|
|
123
|
+
ChefSpec::Matchers::ResourceMatcher.new(:windows_service, :enable, resource_name)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
#
|
|
127
|
+
# Assert that a +windows_service+ resource exists in the Chef run with the
|
|
128
|
+
# action +:reload+. Given a Chef Recipe that reloads "BITS" as a
|
|
129
|
+
# +windows_service+:
|
|
130
|
+
#
|
|
131
|
+
# windows_service 'BITS' do
|
|
132
|
+
# action :reload
|
|
133
|
+
# end
|
|
134
|
+
#
|
|
135
|
+
# To test the content rendered by a +windows_service+, see
|
|
136
|
+
# {ChefSpec::API::RenderFileMatchers}.
|
|
137
|
+
#
|
|
138
|
+
# The Examples section demonstrates the different ways to test a
|
|
139
|
+
# +windows_service+ resource with ChefSpec.
|
|
140
|
+
#
|
|
141
|
+
# @example Assert that a +windows_service+ was reload
|
|
142
|
+
# expect(chef_run).to reload_windows_service('BITS')
|
|
143
|
+
#
|
|
144
|
+
# @example Assert that a +windows_service+ was reload with predicate matchers
|
|
145
|
+
# expect(chef_run).to reload_windows_service('BITS').with_pattern('BI*')
|
|
146
|
+
#
|
|
147
|
+
# @example Assert that a +windows_service+ was reload with attributes
|
|
148
|
+
# expect(chef_run).to reload_windows_service('BITS').with(pattern: 'BI*')
|
|
149
|
+
#
|
|
150
|
+
# @example Assert that a +windows_service+ was reload using a regex
|
|
151
|
+
# expect(chef_run).to reload_windows_service('BITS').with(pattern: /(.+)/)
|
|
152
|
+
#
|
|
153
|
+
# @example Assert that a +windows_service+ was _not_ reload
|
|
154
|
+
# expect(chef_run).to_not reload_windows_service('BITS')
|
|
155
|
+
#
|
|
156
|
+
#
|
|
157
|
+
# @param [String, Regex] resource_name
|
|
158
|
+
# the name of the resource to match
|
|
159
|
+
#
|
|
160
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
161
|
+
#
|
|
162
|
+
def reload_windows_service(resource_name)
|
|
163
|
+
ChefSpec::Matchers::ResourceMatcher.new(:windows_service, :reload, resource_name)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
#
|
|
167
|
+
# Assert that a +windows_service+ resource exists in the Chef run with the
|
|
168
|
+
# action +:restart+. Given a Chef Recipe that restarts "BITS" as a
|
|
169
|
+
# +windows_service+:
|
|
170
|
+
#
|
|
171
|
+
# windows_service 'BITS' do
|
|
172
|
+
# action :restart
|
|
173
|
+
# end
|
|
174
|
+
#
|
|
175
|
+
# To test the content rendered by a +windows_service+, see
|
|
176
|
+
# {ChefSpec::API::RenderFileMatchers}.
|
|
177
|
+
#
|
|
178
|
+
# The Examples section demonstrates the different ways to test a
|
|
179
|
+
# +windows_service+ resource with ChefSpec.
|
|
180
|
+
#
|
|
181
|
+
# @example Assert that a +windows_service+ was restarted
|
|
182
|
+
# expect(chef_run).to restart_windows_service('BITS')
|
|
183
|
+
#
|
|
184
|
+
# @example Assert that a +windows_service+ was restarted with predicate matchers
|
|
185
|
+
# expect(chef_run).to restart_windows_service('BITS').with_pattern('BI*')
|
|
186
|
+
#
|
|
187
|
+
# @example Assert that a +windows_service+ was restarted with attributes
|
|
188
|
+
# expect(chef_run).to restart_windows_service('BITS').with(pattern: 'BI*')
|
|
189
|
+
#
|
|
190
|
+
# @example Assert that a +windows_service+ was restarted using a regex
|
|
191
|
+
# expect(chef_run).to restart_windows_service('BITS').with(pattern: /(.+)/)
|
|
192
|
+
#
|
|
193
|
+
# @example Assert that a +windows_service+ was _not_ restarted
|
|
194
|
+
# expect(chef_run).to_not restart_windows_service('BITS')
|
|
195
|
+
#
|
|
196
|
+
#
|
|
197
|
+
# @param [String, Regex] resource_name
|
|
198
|
+
# the name of the resource to match
|
|
199
|
+
#
|
|
200
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
201
|
+
#
|
|
202
|
+
def restart_windows_service(resource_name)
|
|
203
|
+
ChefSpec::Matchers::ResourceMatcher.new(:windows_service, :restart, resource_name)
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
#
|
|
207
|
+
# Assert that a +windows_service+ resource exists in the Chef run with the
|
|
208
|
+
# action +:start+. Given a Chef Recipe that starts "BITS" as a
|
|
209
|
+
# +windows_service+:
|
|
210
|
+
#
|
|
211
|
+
# windows_service 'BITS' do
|
|
212
|
+
# action :start
|
|
213
|
+
# end
|
|
214
|
+
#
|
|
215
|
+
# To test the content rendered by a +windows_service+, see
|
|
216
|
+
# {ChefSpec::API::RenderFileMatchers}.
|
|
217
|
+
#
|
|
218
|
+
# The Examples section demonstrates the different ways to test a
|
|
219
|
+
# +windows_service+ resource with ChefSpec.
|
|
220
|
+
#
|
|
221
|
+
# @example Assert that a +windows_service+ was started
|
|
222
|
+
# expect(chef_run).to start_windows_service('BITS')
|
|
223
|
+
#
|
|
224
|
+
# @example Assert that a +windows_service+ was started with predicate matchers
|
|
225
|
+
# expect(chef_run).to start_windows_service('BITS').with_pattern('BI*')
|
|
226
|
+
#
|
|
227
|
+
# @example Assert that a +windows_service+ was started with attributes
|
|
228
|
+
# expect(chef_run).to start_windows_service('BITS').with(pattern: 'BI*')
|
|
229
|
+
#
|
|
230
|
+
# @example Assert that a +windows_service+ was started using a regex
|
|
231
|
+
# expect(chef_run).to start_windows_service('BITS').with(pattern: /(.+)/)
|
|
232
|
+
#
|
|
233
|
+
# @example Assert that a +windows_service+ was _not_ started
|
|
234
|
+
# expect(chef_run).to_not start_windows_service('BITS')
|
|
235
|
+
#
|
|
236
|
+
#
|
|
237
|
+
# @param [String, Regex] resource_name
|
|
238
|
+
# the name of the resource to match
|
|
239
|
+
#
|
|
240
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
241
|
+
#
|
|
242
|
+
def start_windows_service(resource_name)
|
|
243
|
+
ChefSpec::Matchers::ResourceMatcher.new(:windows_service, :start, resource_name)
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
#
|
|
247
|
+
# Assert that a +windows_service+ resource exists in the Chef run with the
|
|
248
|
+
# action +:stop+. Given a Chef Recipe that stops "BITS" as a
|
|
249
|
+
# +windows_service+:
|
|
250
|
+
#
|
|
251
|
+
# windows_service 'BITS' do
|
|
252
|
+
# action :stop
|
|
253
|
+
# end
|
|
254
|
+
#
|
|
255
|
+
# To test the content rendered by a +windows_service+, see
|
|
256
|
+
# {ChefSpec::API::RenderFileMatchers}.
|
|
257
|
+
#
|
|
258
|
+
# The Examples section demonstrates the different ways to test a
|
|
259
|
+
# +windows_service+ resource with ChefSpec.
|
|
260
|
+
#
|
|
261
|
+
# @example Assert that a +windows_service+ was stopped
|
|
262
|
+
# expect(chef_run).to stop_windows_service('BITS')
|
|
263
|
+
#
|
|
264
|
+
# @example Assert that a +windows_service+ was stopped with predicate matchers
|
|
265
|
+
# expect(chef_run).to stop_windows_service('BITS').with_pattern('BI*')
|
|
266
|
+
#
|
|
267
|
+
# @example Assert that a +windows_service+ was stopped with attributes
|
|
268
|
+
# expect(chef_run).to stop_windows_service('BITS').with(pattern: 'BI*')
|
|
269
|
+
#
|
|
270
|
+
# @example Assert that a +windows_service+ was stopped using a regex
|
|
271
|
+
# expect(chef_run).to stop_windows_service('BITS').with(pattern: /(.+)/)
|
|
272
|
+
#
|
|
273
|
+
# @example Assert that a +windows_service+ was _not_ stopped
|
|
274
|
+
# expect(chef_run).to_not stop_windows_service('BITS')
|
|
275
|
+
#
|
|
276
|
+
#
|
|
277
|
+
# @param [String, Regex] resource_name
|
|
278
|
+
# the name of the resource to match
|
|
279
|
+
#
|
|
280
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
281
|
+
#
|
|
282
|
+
def stop_windows_service(resource_name)
|
|
283
|
+
ChefSpec::Matchers::ResourceMatcher.new(:windows_service, :stop, resource_name)
|
|
284
|
+
end
|
|
285
|
+
end
|
|
286
|
+
end
|
data/lib/chefspec/api.rb
CHANGED
|
@@ -27,12 +27,14 @@ end
|
|
|
27
27
|
require_relative 'api/apt_package'
|
|
28
28
|
require_relative 'api/batch'
|
|
29
29
|
require_relative 'api/chef_gem'
|
|
30
|
+
require_relative 'api/chocolatey_package'
|
|
30
31
|
require_relative 'api/cookbook_file'
|
|
31
32
|
require_relative 'api/cron'
|
|
32
33
|
require_relative 'api/deploy'
|
|
33
34
|
require_relative 'api/directory'
|
|
34
35
|
require_relative 'api/dpkg_package'
|
|
35
36
|
require_relative 'api/do_nothing'
|
|
37
|
+
require_relative 'api/dsc_resource'
|
|
36
38
|
require_relative 'api/easy_install_package'
|
|
37
39
|
require_relative 'api/env'
|
|
38
40
|
require_relative 'api/erl_call'
|
|
@@ -57,6 +59,7 @@ require_relative 'api/package'
|
|
|
57
59
|
require_relative 'api/pacman_package'
|
|
58
60
|
require_relative 'api/portage_package'
|
|
59
61
|
require_relative 'api/powershell_script'
|
|
62
|
+
require_relative 'api/reboot'
|
|
60
63
|
require_relative 'api/registry_key'
|
|
61
64
|
require_relative 'api/remote_directory'
|
|
62
65
|
require_relative 'api/remote_file'
|
|
@@ -73,4 +76,6 @@ require_relative 'api/subscriptions'
|
|
|
73
76
|
require_relative 'api/subversion'
|
|
74
77
|
require_relative 'api/template'
|
|
75
78
|
require_relative 'api/user'
|
|
79
|
+
require_relative 'api/windows_package'
|
|
80
|
+
require_relative 'api/windows_service'
|
|
76
81
|
require_relative 'api/yum_package'
|
data/lib/chefspec/berkshelf.rb
CHANGED
|
@@ -21,7 +21,13 @@ module ChefSpec
|
|
|
21
21
|
# Setup and install the necessary dependencies in the temporary directory.
|
|
22
22
|
#
|
|
23
23
|
def setup!
|
|
24
|
-
|
|
24
|
+
# Get the list of Berkshelf options
|
|
25
|
+
opts = RSpec.configuration.berkshelf_options
|
|
26
|
+
if !opts.is_a?(Hash)
|
|
27
|
+
raise InvalidBerkshelfOptions(value: opts.inspect)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
berksfile = ::Berkshelf::Berksfile.from_file('Berksfile', opts)
|
|
25
31
|
|
|
26
32
|
# Grab a handle to tmpdir, since Berkshelf 2 modifies it a bit
|
|
27
33
|
tmpdir = File.join(@tmpdir, 'cookbooks')
|
|
@@ -71,7 +71,8 @@ module ChefSpec
|
|
|
71
71
|
|
|
72
72
|
def matches?(resource)
|
|
73
73
|
return true if resource.source_line.nil?
|
|
74
|
-
resource.source_line
|
|
74
|
+
normalized_source_line = resource.source_line.gsub("\\", "/")
|
|
75
|
+
normalized_source_line=~ /cookbooks\/(?!#{@metadatas.join('|')})/
|
|
75
76
|
end
|
|
76
77
|
end
|
|
77
78
|
end
|
data/lib/chefspec/coverage.rb
CHANGED
|
@@ -8,8 +8,12 @@ module Kernel
|
|
|
8
8
|
def deprecated(*messages)
|
|
9
9
|
messages.each do |message|
|
|
10
10
|
calling_spec = caller.find { |line| line =~ /(\/spec)|(_spec\.rb)/ }
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
if calling_spec
|
|
12
|
+
calling_spec = 'spec/' + calling_spec.split('/spec/').last
|
|
13
|
+
warn "[DEPRECATION] #{message} (called from #{calling_spec})"
|
|
14
|
+
else
|
|
15
|
+
warn "[DEPRECATION] #{message}"
|
|
16
|
+
end
|
|
13
17
|
end
|
|
14
18
|
end
|
|
15
19
|
end
|
data/lib/chefspec/errors.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
class Chef
|
|
3
3
|
class Provider
|
|
4
4
|
class LWRPBase < Provider
|
|
5
|
+
# 12.4 version of inline resources
|
|
5
6
|
module InlineResources
|
|
6
7
|
module ClassMethods
|
|
7
8
|
#
|
|
@@ -19,5 +20,27 @@ class Chef
|
|
|
19
20
|
end
|
|
20
21
|
end
|
|
21
22
|
end
|
|
23
|
+
|
|
24
|
+
# 12.5 version of inline resources
|
|
25
|
+
module InlineResources
|
|
26
|
+
#
|
|
27
|
+
# For LWRPs that call +use_inline_resources+, do not create another
|
|
28
|
+
# +resource_collection+ so that everything is added to the parent
|
|
29
|
+
# +resource_collection+.
|
|
30
|
+
#
|
|
31
|
+
# @param [String] name
|
|
32
|
+
#
|
|
33
|
+
def initialize(resource, run_context)
|
|
34
|
+
super
|
|
35
|
+
@run_context = run_context
|
|
36
|
+
@resource_collection = run_context.resource_collection
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
module ClassMethods
|
|
40
|
+
def action(name, &block)
|
|
41
|
+
define_method("action_#{name}", &block)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
22
45
|
end
|
|
23
46
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
require 'singleton'
|
|
3
|
+
|
|
4
|
+
module ChefSpec
|
|
5
|
+
class FileCachePathProxy
|
|
6
|
+
include Singleton
|
|
7
|
+
|
|
8
|
+
attr_reader :file_cache_path
|
|
9
|
+
|
|
10
|
+
def initialize
|
|
11
|
+
@file_cache_path = Dir.mktmpdir(["chefspec", "file_cache_path"])
|
|
12
|
+
at_exit { FileUtils.rm_rf(@file_cache_path) }
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|