chefspec 7.0.0 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -1
  3. data/Gemfile +6 -0
  4. data/README.md +43 -11
  5. data/Rakefile +48 -8
  6. data/chefspec.gemspec +0 -8
  7. data/examples/cab_package/spec/install_spec.rb +20 -18
  8. data/examples/cab_package/spec/remove_spec.rb +17 -15
  9. data/examples/cached/spec/default_spec.rb +1 -0
  10. data/examples/compile_time/spec/default_spec.rb +2 -0
  11. data/examples/custom_matcher/libraries/matcher.rb +1 -23
  12. data/examples/dnf_package/spec/install_spec.rb +20 -18
  13. data/examples/dnf_package/spec/purge_spec.rb +17 -15
  14. data/examples/dnf_package/spec/remove_spec.rb +17 -15
  15. data/examples/dnf_package/spec/upgrade_spec.rb +17 -15
  16. data/examples/heavy_provider_light_resource/spec/provider_service_spec.rb +1 -0
  17. data/examples/msu_package/spec/install_spec.rb +20 -18
  18. data/examples/msu_package/spec/remove_spec.rb +17 -15
  19. data/examples/server/spec/exotic_port_spec.rb +15 -2
  20. data/lib/chefspec.rb +1 -8
  21. data/lib/chefspec/api.rb +6 -84
  22. data/lib/chefspec/api/do_nothing.rb +18 -21
  23. data/lib/chefspec/api/include_recipe.rb +20 -23
  24. data/lib/chefspec/api/link.rb +20 -99
  25. data/lib/chefspec/api/notifications.rb +32 -35
  26. data/lib/chefspec/api/reboot.rb +5 -14
  27. data/lib/chefspec/api/render_file.rb +29 -32
  28. data/lib/chefspec/api/state_attrs.rb +22 -25
  29. data/lib/chefspec/api/subscriptions.rb +29 -32
  30. data/lib/chefspec/api/user.rb +216 -219
  31. data/lib/chefspec/extensions.rb +16 -0
  32. data/lib/chefspec/extensions/chef/resource.rb +90 -8
  33. data/lib/chefspec/version.rb +1 -1
  34. data/lib/chefspec/zero_server.rb +20 -18
  35. metadata +3 -313
  36. data/examples/custom_resource/libraries/matchers.rb +0 -5
  37. data/examples/use_inline_resources/libraries/matchers.rb +0 -5
  38. data/features/apt_package.feature +0 -14
  39. data/features/apt_repository.feature +0 -15
  40. data/features/apt_update.feature +0 -13
  41. data/features/attributes.feature +0 -7
  42. data/features/batch.feature +0 -10
  43. data/features/bff_package.feature +0 -12
  44. data/features/cab_package.feature +0 -21
  45. data/features/cached.feature +0 -7
  46. data/features/chef_gem.feature +0 -14
  47. data/features/chocolatey_package.feature +0 -14
  48. data/features/compile_time.feature +0 -7
  49. data/features/cookbook_file.feature +0 -13
  50. data/features/cron.feature +0 -11
  51. data/features/custom_matcher.feature +0 -11
  52. data/features/custom_resource.feature +0 -7
  53. data/features/deploy.feature +0 -12
  54. data/features/directory.feature +0 -11
  55. data/features/dnf_package.feature +0 -26
  56. data/features/do_nothing.feature +0 -10
  57. data/features/dpkg_package.feature +0 -12
  58. data/features/dsc_resource.feature +0 -10
  59. data/features/dsc_script.feature +0 -10
  60. data/features/env.feature +0 -12
  61. data/features/erl_call.feature +0 -10
  62. data/features/execute.feature +0 -10
  63. data/features/exotic_zero_port.feature +0 -7
  64. data/features/expect_exception.feature +0 -12
  65. data/features/file.feature +0 -13
  66. data/features/freebsd_package.feature +0 -11
  67. data/features/gem_package.feature +0 -14
  68. data/features/git.feature +0 -12
  69. data/features/group.feature +0 -13
  70. data/features/guards.feature +0 -10
  71. data/features/heavy_provider_light_resource.feature +0 -10
  72. data/features/homebrew_package.feature +0 -12
  73. data/features/http_request.feature +0 -15
  74. data/features/ifconfig.feature +0 -13
  75. data/features/include_recipe.feature +0 -10
  76. data/features/ips_package.feature +0 -12
  77. data/features/launchd.feature +0 -17
  78. data/features/link.feature +0 -12
  79. data/features/log.feature +0 -10
  80. data/features/macports_package.feature +0 -13
  81. data/features/mdadm.feature +0 -12
  82. data/features/mount.feature +0 -14
  83. data/features/msu_package.feature +0 -23
  84. data/features/multiple_actions.feature +0 -12
  85. data/features/multiple_run_action.feature +0 -7
  86. data/features/notifications.feature +0 -14
  87. data/features/ohai.feature +0 -10
  88. data/features/openbsd_package.feature +0 -12
  89. data/features/osx_profile.feature +0 -13
  90. data/features/package.feature +0 -14
  91. data/features/pacman_package.feature +0 -13
  92. data/features/paludis_package.feature +0 -12
  93. data/features/portage_package.feature +0 -13
  94. data/features/powershell_script.feature +0 -10
  95. data/features/reboot.feature +0 -12
  96. data/features/registry_key.feature +0 -13
  97. data/features/remote_directory.feature +0 -12
  98. data/features/remote_file.feature +0 -13
  99. data/features/render_file.feature +0 -11
  100. data/features/roles.feature +0 -7
  101. data/features/route.feature +0 -11
  102. data/features/rpm_package.feature +0 -12
  103. data/features/ruby_block.feature +0 -11
  104. data/features/script.feature +0 -16
  105. data/features/server.feature +0 -16
  106. data/features/server_on_disk.feature +0 -16
  107. data/features/service.feature +0 -15
  108. data/features/smartos_package.feature +0 -12
  109. data/features/solaris_package.feature +0 -12
  110. data/features/state_attrs.feature +0 -7
  111. data/features/step_definitions/background_steps.rb +0 -7
  112. data/features/step_into.feature +0 -7
  113. data/features/stub_command.feature +0 -7
  114. data/features/stub_data_bag.feature +0 -7
  115. data/features/stub_data_bag_item.feature +0 -7
  116. data/features/stub_node.feature +0 -7
  117. data/features/stub_search.feature +0 -7
  118. data/features/subscribes.feature +0 -14
  119. data/features/subversion.feature +0 -13
  120. data/features/support/env.rb +0 -38
  121. data/features/support/executor.rb +0 -20
  122. data/features/support/exotic_zero_port.rb +0 -3
  123. data/features/support/on_disk.rb +0 -7
  124. data/features/systemd_unit.feature +0 -27
  125. data/features/template.feature +0 -13
  126. data/features/use_inline_resources.feature +0 -7
  127. data/features/user.feature +0 -15
  128. data/features/windows_package.feature +0 -11
  129. data/features/windows_service.feature +0 -16
  130. data/features/yum_package.feature +0 -13
  131. data/features/yum_repository.feature +0 -23
  132. data/features/zypper_package.feature +0 -13
  133. data/lib/chefspec/api/apt_package.rb +0 -192
  134. data/lib/chefspec/api/apt_repository.rb +0 -56
  135. data/lib/chefspec/api/apt_update.rb +0 -53
  136. data/lib/chefspec/api/batch.rb +0 -43
  137. data/lib/chefspec/api/bff_package.rb +0 -154
  138. data/lib/chefspec/api/cab_package.rb +0 -80
  139. data/lib/chefspec/api/chef_gem.rb +0 -191
  140. data/lib/chefspec/api/chocolatey_package.rb +0 -107
  141. data/lib/chefspec/api/cookbook_file.rb +0 -166
  142. data/lib/chefspec/api/cron.rb +0 -80
  143. data/lib/chefspec/api/deploy.rb +0 -117
  144. data/lib/chefspec/api/directory.rb +0 -80
  145. data/lib/chefspec/api/dnf_package.rb +0 -154
  146. data/lib/chefspec/api/dpkg_package.rb +0 -117
  147. data/lib/chefspec/api/dsc_resource.rb +0 -49
  148. data/lib/chefspec/api/dsc_script.rb +0 -37
  149. data/lib/chefspec/api/easy_install_package.rb +0 -154
  150. data/lib/chefspec/api/env.rb +0 -117
  151. data/lib/chefspec/api/erl_call.rb +0 -43
  152. data/lib/chefspec/api/execute.rb +0 -43
  153. data/lib/chefspec/api/file.rb +0 -166
  154. data/lib/chefspec/api/freebsd_package.rb +0 -80
  155. data/lib/chefspec/api/gem_package.rb +0 -191
  156. data/lib/chefspec/api/git.rb +0 -117
  157. data/lib/chefspec/api/group.rb +0 -154
  158. data/lib/chefspec/api/homebrew_package.rb +0 -154
  159. data/lib/chefspec/api/http_request.rb +0 -228
  160. data/lib/chefspec/api/ifconfig.rb +0 -154
  161. data/lib/chefspec/api/ips_package.rb +0 -117
  162. data/lib/chefspec/api/launchd.rb +0 -151
  163. data/lib/chefspec/api/log.rb +0 -43
  164. data/lib/chefspec/api/macports_package.rb +0 -154
  165. data/lib/chefspec/api/mdadm.rb +0 -117
  166. data/lib/chefspec/api/mount.rb +0 -192
  167. data/lib/chefspec/api/msu_package.rb +0 -81
  168. data/lib/chefspec/api/ohai.rb +0 -43
  169. data/lib/chefspec/api/openbsd_package.rb +0 -155
  170. data/lib/chefspec/api/osx_profile.rb +0 -63
  171. data/lib/chefspec/api/package.rb +0 -192
  172. data/lib/chefspec/api/pacman_package.rb +0 -155
  173. data/lib/chefspec/api/paludis_package.rb +0 -155
  174. data/lib/chefspec/api/portage_package.rb +0 -155
  175. data/lib/chefspec/api/powershell_script.rb +0 -43
  176. data/lib/chefspec/api/registry_key.rb +0 -166
  177. data/lib/chefspec/api/remote_directory.rb +0 -120
  178. data/lib/chefspec/api/remote_file.rb +0 -166
  179. data/lib/chefspec/api/route.rb +0 -80
  180. data/lib/chefspec/api/rpm_package.rb +0 -117
  181. data/lib/chefspec/api/ruby_block.rb +0 -68
  182. data/lib/chefspec/api/script.rb +0 -278
  183. data/lib/chefspec/api/service.rb +0 -246
  184. data/lib/chefspec/api/smartos_package.rb +0 -117
  185. data/lib/chefspec/api/solaris_package.rb +0 -117
  186. data/lib/chefspec/api/subversion.rb +0 -154
  187. data/lib/chefspec/api/systemd_unit.rb +0 -353
  188. data/lib/chefspec/api/template.rb +0 -166
  189. data/lib/chefspec/api/windows_package.rb +0 -86
  190. data/lib/chefspec/api/windows_service.rb +0 -286
  191. data/lib/chefspec/api/yum_package.rb +0 -154
  192. data/lib/chefspec/api/yum_repository.rb +0 -130
  193. data/lib/chefspec/api/zypper_package.rb +0 -154
  194. data/spec/unit/api_spec.rb +0 -18
@@ -1,166 +0,0 @@
1
- module ChefSpec::API
2
- # @since 0.0.1
3
- module TemplateMatchers
4
- ChefSpec.define_matcher :template
5
-
6
- #
7
- # Assert that a +template+ resource exists in the Chef run with the
8
- # action +:create+. Given a Chef Recipe that creates "/tmp/config" as a
9
- # +template+:
10
- #
11
- # template '/tmp/config' do
12
- # action :create
13
- # end
14
- #
15
- # To test the content rendered by a +template+, see
16
- # {ChefSpec::API::RenderFileMatchers}.
17
- #
18
- # The Examples section demonstrates the different ways to test a
19
- # +template+ resource with ChefSpec.
20
- #
21
- # @example Assert that a +template+ was created
22
- # expect(chef_run).to create_template('/tmp/config')
23
- #
24
- # @example Assert that a +template+ was created with predicate matchers
25
- # expect(chef_run).to create_template('/tmp/config').with_user('svargo')
26
- #
27
- # @example Assert that a +template+ was created with attributes
28
- # expect(chef_run).to create_template('/tmp/config').with(user: 'svargo')
29
- #
30
- # @example Assert that a +template+ was created using a regex
31
- # expect(chef_run).to create_template('/tmp/config').with(user: /sva(.+)/)
32
- #
33
- # @example Assert that a +template+ was _not_ created
34
- # expect(chef_run).to_not create_template('/tmp/config')
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 create_template(resource_name)
43
- ChefSpec::Matchers::ResourceMatcher.new(:template, :create, resource_name)
44
- end
45
-
46
- #
47
- # Assert that a +template+ resource exists in the Chef run with the
48
- # action +:create_if_missing+. Given a Chef Recipe that creates "/tmp/config"
49
- # if missing as a +template+:
50
- #
51
- # template '/tmp/config' do
52
- # action :create_if_missing
53
- # end
54
- #
55
- # To test the content rendered by a +template+, see
56
- # {ChefSpec::API::RenderFileMatchers}.
57
- #
58
- # The Examples section demonstrates the different ways to test a
59
- # +template+ resource with ChefSpec.
60
- #
61
- # @example Assert that a +template+ was created if missing
62
- # expect(chef_run).to create_template_if_missing('/tmp/config')
63
- #
64
- # @example Assert that a +template+ was created if missing with predicate matchers
65
- # expect(chef_run).to create_template_if_missing('/tmp/config').with_user('svargo')
66
- #
67
- # @example Assert that a +template+ was created if missing with attributes
68
- # expect(chef_run).to create_template_if_missing('/tmp/config').with(user: 'svargo')
69
- #
70
- # @example Assert that a +template+ was created if missing using a regex
71
- # expect(chef_run).to create_template_if_missing('/tmp/config').with(user: /sva(.+)/)
72
- #
73
- # @example Assert that a +template+ was _not_ created if missing
74
- # expect(chef_run).to_not create_template('/tmp/config')
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 create_template_if_missing(resource_name)
83
- ChefSpec::Matchers::ResourceMatcher.new(:template, :create_if_missing, resource_name)
84
- end
85
-
86
- #
87
- # Assert that a +template+ resource exists in the Chef run with the
88
- # action +:delete+. Given a Chef Recipe that deletes "/tmp/config" as a
89
- # +template+:
90
- #
91
- # template '/tmp/config' do
92
- # action :delete
93
- # end
94
- #
95
- # To test the content rendered by a +template+, see
96
- # {ChefSpec::API::RenderFileMatchers}.
97
- #
98
- # The Examples section demonstrates the different ways to test a
99
- # +template+ resource with ChefSpec.
100
- #
101
- # @example Assert that a +template+ was deleted
102
- # expect(chef_run).to delete_template('/tmp/config')
103
- #
104
- # @example Assert that a +template+ was deleted with predicate matchers
105
- # expect(chef_run).to delete_template('/tmp/config').with_user('svargo')
106
- #
107
- # @example Assert that a +template+ was deleted with attributes
108
- # expect(chef_run).to delete_template('/tmp/config').with(user: 'svargo')
109
- #
110
- # @example Assert that a +template+ was deleted using a regex
111
- # expect(chef_run).to delete_template('/tmp/config').with(user: /sva(.+)/)
112
- #
113
- # @example Assert that a +template+ was _not_ deleted
114
- # expect(chef_run).to_not delete_template('/tmp/config')
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 delete_template(resource_name)
123
- ChefSpec::Matchers::ResourceMatcher.new(:template, :delete, resource_name)
124
- end
125
-
126
- #
127
- # Assert that a +template+ resource exists in the Chef run with the
128
- # action +:touch+. Given a Chef Recipe that touches "/tmp/config" as a
129
- # +template+:
130
- #
131
- # template '/tmp/config' do
132
- # action :touch
133
- # end
134
- #
135
- # To test the content rendered by a +template+, see
136
- # {ChefSpec::API::RenderFileMatchers}.
137
- #
138
- # The Examples section demonstrates the different ways to test a
139
- # +template+ resource with ChefSpec.
140
- #
141
- # @example Assert that a +template+ was touched
142
- # expect(chef_run).to touch_template('/tmp/config')
143
- #
144
- # @example Assert that a +template+ was touched with predicate matchers
145
- # expect(chef_run).to touch_template('/tmp/config').with_user('svargo')
146
- #
147
- # @example Assert that a +template+ was touched with attributes
148
- # expect(chef_run).to touch_template('/tmp/config').with(user: 'svargo')
149
- #
150
- # @example Assert that a +template+ was touched using a regex
151
- # expect(chef_run).to touch_template('/tmp/config').with(user: /sva(.+)/)
152
- #
153
- # @example Assert that a +template+ was _not_ touched
154
- # expect(chef_run).to_not touch_template('/tmp/config')
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 touch_template(resource_name)
163
- ChefSpec::Matchers::ResourceMatcher.new(:template, :touch, resource_name)
164
- end
165
- end
166
- end
@@ -1,86 +0,0 @@
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
@@ -1,286 +0,0 @@
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