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,38 +1,35 @@
1
1
  module ChefSpec::API
2
- # @since 0.9.0
3
- module NotificationsMatchers
4
- #
5
- # Assert that a resource notifies another. Given a Chef Recipe that
6
- # notifies a template resource to restart apache:
7
- #
8
- # template '/etc/apache2/config' do
9
- # notifies :restart, 'service[apache2]'
10
- # end
11
- #
12
- # The Examples section demonstrates the different ways to test an
13
- # notifications on a resource with ChefSpec.
14
- #
15
- # @example Assert the template notifies apache of something
16
- # template = chef_run.template('/etc/apache2.conf')
17
- # expect(template).to notify('service[apache2]')
18
- #
19
- # @example Assert the template notifies apache to restart
20
- # expect(template).to notify('service[apache2]').to(:restart)
21
- #
22
- # @example Assert the template notifies apache to restart immediately
23
- # expect(template).to notify('service[apache2]').to(:restart).immediately
24
- #
25
- # @example Assert the template notifies apache to restart delayed
26
- # expect(template).to notify('service[apache2]').to(:restart).delayed
27
- #
28
- #
29
- # @param [String] signature
30
- # the signature of the notification to match
31
- #
32
- # @return [ChefSpec::Matchers::NotificationsMatcher]
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
@@ -1,18 +1,9 @@
1
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
2
+ def now_reboot(resource_name)
3
+ ChefSpec::Matchers::ResourceMatcher.new(:reboot, :reboot_now, resource_name)
4
+ end
13
5
 
14
- def cancel_reboot(resource_name)
15
- ChefSpec::Matchers::ResourceMatcher.new(:reboot, :cancel, resource_name)
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
- # @since 3.0.0
3
- module RenderFileMatchers
4
- #
5
- # Assert that a file is rendered by the Chef run. This matcher works for
6
- # +template+, +file+, and +cookbook_file+ resources. The content from the
7
- # resource must be convertable to a string; verifying the content of a
8
- # binary file is not permissible at this time.
9
- #
10
- # @example Assert a template is rendered
11
- # expect(chef_run).to render_file('/etc/foo')
12
- #
13
- # @example Assert a template is rendered with certain content
14
- # expect(template).to render_file('/etc/foo').with_content('This is a file')
15
- #
16
- # @example Assert a template is rendered with matching content
17
- # expect(template).to render_file('/etc/foo').with_content(/^This(.+)$/)
18
- #
19
- # @example Assert a template is rendered with content matching any RSpec matcher
20
- # expect(template).to render_file('/etc/foo').with_content(starts_with('This'))
21
- #
22
- # @example Assert a partial path to a template is rendered with matching content
23
- # expect(template).to render_file(/\/etc\/foo-(\d+)$/).with_content(/^This(.+)$/)
24
- #
25
- #
26
- # @param [String] path
27
- # the path of the file to render
28
- #
29
- # @return [ChefSpec::Matchers::RenderFileMatcher]
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
- # @since 3.1.0
3
- module StateAttrsMatcher
4
- #
5
- # Assert that a Chef resource has certain state attributes (since Chef
6
- # 11.8.0):
7
- #
8
- # state_attrs :time, :temperature
9
- #
10
- # @see https://github.com/opscode/chef/blob/e43d7ebda/lib/chef/resource/file.rb#L32-L37
11
- #
12
- # The Examples section demonstrates the different ways to test a
13
- # resource's +state_attrs+ with ChefSpec.
14
- #
15
- # @example Assert the +lwrp+ resource has two state attributes
16
- # expect(lwrp).to have_state_attrs(:time, :temperature)
17
- #
18
- #
19
- # @param [Array] state_attrs
20
- # the list of state attributes to assert
21
- #
22
- # @return [ChefSpec::Matchers::StateAttrsMatcher]
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
- # @since 3.2.0
3
- module SubscriptionsMatchers
4
- #
5
- # Assert that a resource subscribes to another. Given a Chef Recipe that
6
- # subscribes a template resource to restart apache:
7
- #
8
- # service 'apache2' do
9
- # subscribes :create, 'template[/etc/apache2/config]'
10
- # end
11
- #
12
- # The Examples section demonstrates the different ways to test a
13
- # subscription on a resource with ChefSpec.
14
- #
15
- # @example Assert a basic subscription
16
- # service = chef_run.service('apache2')
17
- # expect(service).to subscribe_to('template[/etc/apache2/config]')
18
- #
19
- # @example Assert a subscription with specified action
20
- # expect(service).to subscribe_to('template[/etc/apache2/config]').on(:restart)
21
- #
22
- # @example Assert a subscription with specified action and timing
23
- # expect(service).to subscribe_to('template[/etc/apache2/config]').on(:restart).immediately
24
- #
25
- #
26
- # @param [String] signature
27
- # the signature of the notification to match
28
- #
29
- # @return [ChefSpec::Matchers::NotificationsMatcher]
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
@@ -1,228 +1,225 @@
1
1
  module ChefSpec::API
2
- # @since 0.3.0
3
- module UserMatchers
4
- ChefSpec.define_matcher :user
2
+ ChefSpec.define_matcher :user
5
3
 
6
- #
7
- # Assert that a +user+ resource exists in the Chef run with the
8
- # action +:create+. Given a Chef Recipe that creates "apache2" as a
9
- # +user+:
10
- #
11
- # user 'apache2' do
12
- # action :create
13
- # end
14
- #
15
- # The Examples section demonstrates the different ways to test a
16
- # +user+ resource with ChefSpec.
17
- #
18
- # @example Assert that a +user+ was created
19
- # expect(chef_run).to create_user('apache2')
20
- #
21
- # @example Assert that a +user+ was created with predicate matchers
22
- # expect(chef_run).to create_user('apache2').with_uid(1234)
23
- #
24
- # @example Assert that a +user+ was created with attributes
25
- # expect(chef_run).to create_user('apache2').with(uid: 1234)
26
- #
27
- # @example Assert that a +user+ was created using a regex
28
- # expect(chef_run).to create_user('apache2').with(uid: /\d+/)
29
- #
30
- # @example Assert that a +user+ was _not_ created
31
- # expect(chef_run).to_not create_user('apache2')
32
- #
33
- #
34
- # @param [String, Regex] resource_name
35
- # the name of the resource to match
36
- #
37
- # @return [ChefSpec::Matchers::ResourceMatcher]
38
- #
39
- def create_user(resource_name)
40
- ChefSpec::Matchers::ResourceMatcher.new(:user, :create, resource_name)
41
- end
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
- # Assert that a +user+ resource exists in the Chef run with the
45
- # action +:remove+. Given a Chef Recipe that removes "apache2" as a
46
- # +user+:
47
- #
48
- # user 'apache2' do
49
- # action :remove
50
- # end
51
- #
52
- # The Examples section demonstrates the different ways to test a
53
- # +user+ resource with ChefSpec.
54
- #
55
- # @example Assert that a +user+ was remove
56
- # expect(chef_run).to remove_user('apache2')
57
- #
58
- # @example Assert that a +user+ was remove with predicate matchers
59
- # expect(chef_run).to remove_user('apache2').with_uid(1234)
60
- #
61
- # @example Assert that a +user+ was remove with attributes
62
- # expect(chef_run).to remove_user('apache2').with(uid: 1234)
63
- #
64
- # @example Assert that a +user+ was remove using a regex
65
- # expect(chef_run).to remove_user('apache2').with(uid: /\d+/)
66
- #
67
- # @example Assert that a +user+ was _not_ remove
68
- # expect(chef_run).to_not remove_user('apache2')
69
- #
70
- #
71
- # @param [String, Regex] resource_name
72
- # the name of the resource to match
73
- #
74
- # @return [ChefSpec::Matchers::ResourceMatcher]
75
- #
76
- def remove_user(resource_name)
77
- ChefSpec::Matchers::ResourceMatcher.new(:user, :remove, resource_name)
78
- end
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
- # Assert that a +user+ resource exists in the Chef run with the
82
- # action +:modify+. Given a Chef Recipe that modifies "apache2" as a
83
- # +user+:
84
- #
85
- # user 'apache2' do
86
- # action :modify
87
- # end
88
- #
89
- # The Examples section demonstrates the different ways to test a
90
- # +user+ resource with ChefSpec.
91
- #
92
- # @example Assert that a +user+ was modified
93
- # expect(chef_run).to modify_user('apache2')
94
- #
95
- # @example Assert that a +user+ was modified with predicate matchers
96
- # expect(chef_run).to modify_user('apache2').with_uid(1234)
97
- #
98
- # @example Assert that a +user+ was modified with attributes
99
- # expect(chef_run).to modify_user('apache2').with(uid: 1234)
100
- #
101
- # @example Assert that a +user+ was modified using a regex
102
- # expect(chef_run).to modify_user('apache2').with(uid: /\d+/)
103
- #
104
- # @example Assert that a +user+ was _not_ modified
105
- # expect(chef_run).to_not modify_user('apache2')
106
- #
107
- #
108
- # @param [String, Regex] resource_name
109
- # the name of the resource to match
110
- #
111
- # @return [ChefSpec::Matchers::ResourceMatcher]
112
- #
113
- def modify_user(resource_name)
114
- ChefSpec::Matchers::ResourceMatcher.new(:user, :modify, resource_name)
115
- end
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
- # Assert that a +user+ resource exists in the Chef run with the
119
- # action +:manage+. Given a Chef Recipe that manages "apache2" as a
120
- # +user+:
121
- #
122
- # user 'apache2' do
123
- # action :manage
124
- # end
125
- #
126
- # The Examples section demonstrates the different ways to test a
127
- # +user+ resource with ChefSpec.
128
- #
129
- # @example Assert that a +user+ was managed
130
- # expect(chef_run).to manage_user('apache2')
131
- #
132
- # @example Assert that a +user+ was managed with predicate matchers
133
- # expect(chef_run).to manage_user('apache2').with_uid(1234)
134
- #
135
- # @example Assert that a +user+ was managed with attributes
136
- # expect(chef_run).to manage_user('apache2').with(uid: 1234)
137
- #
138
- # @example Assert that a +user+ was managed using a regex
139
- # expect(chef_run).to manage_user('apache2').with(uid: /\d+/)
140
- #
141
- # @example Assert that a +user+ was _not_ managed
142
- # expect(chef_run).to_not manage_user('apache2')
143
- #
144
- #
145
- # @param [String, Regex] resource_name
146
- # the name of the resource to match
147
- #
148
- # @return [ChefSpec::Matchers::ResourceMatcher]
149
- #
150
- def manage_user(resource_name)
151
- ChefSpec::Matchers::ResourceMatcher.new(:user, :manage, resource_name)
152
- end
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
- # Assert that a +user+ resource exists in the Chef run with the
156
- # action +:lock+. Given a Chef Recipe that locks "apache2" as a
157
- # +user+:
158
- #
159
- # user 'apache2' do
160
- # action :lock
161
- # end
162
- #
163
- # The Examples section demonstrates the different ways to test a
164
- # +user+ resource with ChefSpec.
165
- #
166
- # @example Assert that a +user+ was locked
167
- # expect(chef_run).to lock_user('apache2')
168
- #
169
- # @example Assert that a +user+ was locked with predicate matchers
170
- # expect(chef_run).to lock_user('apache2').with_uid(1234)
171
- #
172
- # @example Assert that a +user+ was locked with attributes
173
- # expect(chef_run).to lock_user('apache2').with(uid: 1234)
174
- #
175
- # @example Assert that a +user+ was locked using a regex
176
- # expect(chef_run).to lock_user('apache2').with(uid: /\d+/)
177
- #
178
- # @example Assert that a +user+ was _not_ locked
179
- # expect(chef_run).to_not lock_user('apache2')
180
- #
181
- #
182
- # @param [String, Regex] resource_name
183
- # the name of the resource to match
184
- #
185
- # @return [ChefSpec::Matchers::ResourceMatcher]
186
- #
187
- def lock_user(resource_name)
188
- ChefSpec::Matchers::ResourceMatcher.new(:user, :lock, resource_name)
189
- end
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
- # Assert that a +user+ resource exists in the Chef run with the
193
- # action +:unlock+. Given a Chef Recipe that unlocks "apache2" as a
194
- # +user+:
195
- #
196
- # user 'apache2' do
197
- # action :unlock
198
- # end
199
- #
200
- # The Examples section demonstrates the different ways to test a
201
- # +user+ resource with ChefSpec.
202
- #
203
- # @example Assert that a +user+ was unlocked
204
- # expect(chef_run).to unlock_user('apache2')
205
- #
206
- # @example Assert that a +user+ was unlocked with predicate matchers
207
- # expect(chef_run).to unlock_user('apache2').with_uid(1234)
208
- #
209
- # @example Assert that a +user+ was unlocked with attributes
210
- # expect(chef_run).to unlock_user('apache2').with(uid: 1234)
211
- #
212
- # @example Assert that a +user+ was unlocked using a regex
213
- # expect(chef_run).to unlock_user('apache2').with(uid: /\d+/)
214
- #
215
- # @example Assert that a +user+ was _not_ unlocked
216
- # expect(chef_run).to_not unlock_user('apache2')
217
- #
218
- #
219
- # @param [String, Regex] resource_name
220
- # the name of the resource to match
221
- #
222
- # @return [ChefSpec::Matchers::ResourceMatcher]
223
- #
224
- def unlock_user(resource_name)
225
- ChefSpec::Matchers::ResourceMatcher.new(:user, :unlock, resource_name)
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