chefspec 7.0.0 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,49 +0,0 @@
1
- module ChefSpec::API
2
- # @since 4.3.0
3
- module DscResourceMatchers
4
- ChefSpec.define_matcher :dsc_resource
5
-
6
- #
7
- # Assert that a +dsc_resource+ resource exists in the Chef run with the
8
- # action +:run+. Given a Chef Recipe that installs "zip" as a
9
- # +dsc_resource+:
10
- #
11
- # dsc_resource 'zip' do
12
- # resource :archive
13
- # property :ensure, 'Present'
14
- # property :path, "C:\Users\Public\Documents\example.zip"
15
- # property :destination, "C:\Users\Public\Documents\ExtractionPath"
16
- # end
17
- #
18
- # To test the content rendered by a +dsc_resource+, see
19
- # {ChefSpec::API::RenderFileMatchers}.
20
- #
21
- # The Examples section demonstrates the different ways to test a
22
- # +dsc_resource+ resource with ChefSpec.
23
- #
24
- # @example Assert that a +dsc_resource+ was installed
25
- # expect(chef_run).to run_dsc_resource('zip')
26
- #
27
- # @example Assert that a +dsc_resource+ was installed with predicate matchers
28
- # expect(chef_run).to run_dsc_resource('zip').with_resource(:archive)
29
- #
30
- # @example Assert that a +dsc_resource+ was installed with attributes
31
- # expect(chef_run).to run_dsc_resource('zip').with(resource: :archive)
32
- #
33
- # @example Assert that a +dsc_resource+ was installed using a regex
34
- # expect(chef_run).to run_dsc_resource('zip').with(resource: /:arch(.+)/)
35
- #
36
- # @example Assert that a +dsc_resource+ was _not_ installed
37
- # expect(chef_run).to_not run_dsc_resource('zip')
38
- #
39
- #
40
- # @param [String, Regex] resource_name
41
- # the name of the resource to match
42
- #
43
- # @return [ChefSpec::Matchers::ResourceMatcher]
44
- #
45
- def run_dsc_resource(resource_name)
46
- ChefSpec::Matchers::ResourceMatcher.new(:dsc_resource, :run, resource_name)
47
- end
48
- end
49
- end
@@ -1,37 +0,0 @@
1
- module ChefSpec::API
2
- # @since 5.1.0
3
- module DscScriptMatchers
4
- ChefSpec.define_matcher :dsc_script
5
-
6
- #
7
- # Assert that a +dsc_script+ resource exists in the Chef run with
8
- # the action +:run+. Given a Chef Recipe that runs "something" using
9
- # +dsc_script+:
10
- #
11
- # dsc_script 'something' do
12
- # code <<-EOH
13
- # something
14
- # EOH
15
- # action :run
16
- # end
17
- #
18
- # The Examples section demonstrates the different ways to test a
19
- # +dsc_script+ resource with ChefSpec.
20
- #
21
- # @example Assert that a +dsc_script+ was run
22
- # expect(chef_run).to dsc_script('something')
23
- #
24
- # @example Assert that a +dsc_script+ was _not_ run
25
- # expect(chef_run).to_not dsc_script('something')
26
- #
27
- #
28
- # @param [String, Regex] resource_name
29
- # the name of the resource to match
30
- #
31
- # @return [ChefSpec::Matchers::ResourceMatcher]
32
- #
33
- def run_dsc_script(resource_name)
34
- ChefSpec::Matchers::ResourceMatcher.new(:dsc_script, :run, resource_name)
35
- end
36
- end
37
- end
@@ -1,154 +0,0 @@
1
- module ChefSpec::API
2
- # @since 3.0.0
3
- module EasyInstallPackageMatchers
4
- ChefSpec.define_matcher :easy_install_package
5
-
6
- #
7
- # Assert that an +easy_install_package+ resource exists in the Chef run
8
- # with the action +:install+. Given a Chef Recipe that installs "pygments" as a
9
- # +easy_install_package+:
10
- #
11
- # easy_install_package 'pygments' do
12
- # action :install
13
- # end
14
- #
15
- # The Examples section demonstrates the different ways to test a
16
- # +easy_install_package+ resource with ChefSpec.
17
- #
18
- # @example Assert that an +easy_install_package+ was installed
19
- # expect(chef_run).to install_easy_install_package('pygments')
20
- #
21
- # @example Assert that an +easy_install_package+ was installed with predicate matchers
22
- # expect(chef_run).to install_easy_install_package('pygments').with_version('1.2.3')
23
- #
24
- # @example Assert that an +easy_install_package+ was installed with attributes
25
- # expect(chef_run).to install_easy_install_package('pygments').with(version: '1.2.3')
26
- #
27
- # @example Assert that an +easy_install_package+ was installed using a regex
28
- # expect(chef_run).to install_easy_install_package('pygments').with(version: /(\d+\.){2}\.\d+/)
29
- #
30
- # @example Assert that an +easy_install_package+ was _not_ installed
31
- # expect(chef_run).to_not install_easy_install_package('pygments')
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 install_easy_install_package(resource_name)
40
- ChefSpec::Matchers::ResourceMatcher.new(:easy_install_package, :install, resource_name)
41
- end
42
-
43
- #
44
- # Assert that an +easy_install_package+ resource exists in the Chef run
45
- # with the action +:purge+. Given a Chef Recipe that purges "pygments" as a
46
- # +easy_install_package+:
47
- #
48
- # easy_install_package 'pygments' do
49
- # action :purge
50
- # end
51
- #
52
- # The Examples section demonstrates the different ways to test a
53
- # +easy_install_package+ resource with ChefSpec.
54
- #
55
- # @example Assert that an +easy_install_package+ was purged
56
- # expect(chef_run).to purge_easy_install_package('pygments')
57
- #
58
- # @example Assert that an +easy_install_package+ was purged with predicate matchers
59
- # expect(chef_run).to purge_easy_install_package('pygments').with_version('1.2.3')
60
- #
61
- # @example Assert that an +easy_install_package+ was purged with attributes
62
- # expect(chef_run).to purge_easy_install_package('pygments').with(version: '1.2.3')
63
- #
64
- # @example Assert that an +easy_install_package+ was purged using a regex
65
- # expect(chef_run).to purge_easy_install_package('pygments').with(version: /(\d+\.){2}\.\d+/)
66
- #
67
- # @example Assert that an +easy_install_package+ was _not_ purged
68
- # expect(chef_run).to_not purge_easy_install_package('pygments')
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 purge_easy_install_package(resource_name)
77
- ChefSpec::Matchers::ResourceMatcher.new(:easy_install_package, :purge, resource_name)
78
- end
79
-
80
- #
81
- # Assert that an +easy_install_package+ resource exists in the Chef run
82
- # with the action +:remove+. Given a Chef Recipe that removes "pygments" as a
83
- # +easy_install_package+:
84
- #
85
- # easy_install_package 'pygments' do
86
- # action :remove
87
- # end
88
- #
89
- # The Examples section demonstrates the different ways to test a
90
- # +easy_install_package+ resource with ChefSpec.
91
- #
92
- # @example Assert that an +easy_install_package+ was removed
93
- # expect(chef_run).to remove_easy_install_package('pygments')
94
- #
95
- # @example Assert that an +easy_install_package+ was removed with predicate matchers
96
- # expect(chef_run).to remove_easy_install_package('pygments').with_version('1.2.3')
97
- #
98
- # @example Assert that an +easy_install_package+ was removed with attributes
99
- # expect(chef_run).to remove_easy_install_package('pygments').with(version: '1.2.3')
100
- #
101
- # @example Assert that an +easy_install_package+ was removed using a regex
102
- # expect(chef_run).to remove_easy_install_package('pygments').with(version: /(\d+\.){2}\.\d+/)
103
- #
104
- # @example Assert that an +easy_install_package+ was _not_ removed
105
- # expect(chef_run).to_not remove_easy_install_package('pygments')
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 remove_easy_install_package(resource_name)
114
- ChefSpec::Matchers::ResourceMatcher.new(:easy_install_package, :remove, resource_name)
115
- end
116
-
117
- #
118
- # Assert that an +easy_install_package+ resource exists in the Chef run
119
- # with the action +:upgrade+. Given a Chef Recipe that upgrades "pygments" as a
120
- # +easy_install_package+:
121
- #
122
- # easy_install_package 'pygments' do
123
- # action :upgrade
124
- # end
125
- #
126
- # The Examples section demonstrates the different ways to test a
127
- # +easy_install_package+ resource with ChefSpec.
128
- #
129
- # @example Assert that an +easy_install_package+ was upgraded
130
- # expect(chef_run).to upgrade_easy_install_package('pygments')
131
- #
132
- # @example Assert that an +easy_install_package+ was upgraded with predicate matchers
133
- # expect(chef_run).to upgrade_easy_install_package('pygments').with_version('1.2.3')
134
- #
135
- # @example Assert that an +easy_install_package+ was upgraded with attributes
136
- # expect(chef_run).to upgrade_easy_install_package('pygments').with(version: '1.2.3')
137
- #
138
- # @example Assert that an +easy_install_package+ was upgraded using a regex
139
- # expect(chef_run).to upgrade_easy_install_package('pygments').with(version: /(\d+\.){2}\.\d+/)
140
- #
141
- # @example Assert that an +easy_install_package+ was _not_ upgraded
142
- # expect(chef_run).to_not upgrade_easy_install_package('pygments')
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 upgrade_easy_install_package(resource_name)
151
- ChefSpec::Matchers::ResourceMatcher.new(:easy_install_package, :upgrade, resource_name)
152
- end
153
- end
154
- end
@@ -1,117 +0,0 @@
1
- module ChefSpec::API
2
- # @since 0.9.0
3
- module EnvMatchers
4
- ChefSpec.define_matcher :env
5
-
6
- #
7
- # Assert that an +env+ resource exists in the Chef run with the
8
- # action +:create+. Given a Chef Recipe that creates "HOME" as an
9
- # +env+:
10
- #
11
- # env 'HOME' do
12
- # action :create
13
- # end
14
- #
15
- # The Examples section demonstrates the different ways to test an
16
- # +env+ resource with ChefSpec.
17
- #
18
- # @example Assert that an +env+ was created
19
- # expect(chef_run).to create_env('HOME')
20
- #
21
- # @example Assert that an +env+ was created with predicate matchers
22
- # expect(chef_run).to create_env('HOME').with_value('/home')
23
- #
24
- # @example Assert that an +env+ was created with attributes
25
- # expect(chef_run).to create_env('HOME').with(value: 'home')
26
- #
27
- # @example Assert that an +env+ was created using a regex
28
- # expect(chef_run).to create_env('HOME').with(value: /\/ho(.+)/)
29
- #
30
- # @example Assert that an +env+ was _not_ created
31
- # expect(chef_run).to_not create_env('HOME')
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_env(resource_name)
40
- ChefSpec::Matchers::ResourceMatcher.new(:env, :create, resource_name)
41
- end
42
-
43
- #
44
- # Assert that an +env+ resource exists in the Chef run with the
45
- # action +:delete+. Given a Chef Recipe that deletes "HOME" as an
46
- # +env+:
47
- #
48
- # env 'HOME' do
49
- # action :delete
50
- # end
51
- #
52
- # The Examples section demonstrates the different ways to test an
53
- # +env+ resource with ChefSpec.
54
- #
55
- # @example Assert that an +env+ was deleted
56
- # expect(chef_run).to delete_env('HOME')
57
- #
58
- # @example Assert that an +env+ was deleted with predicate matchers
59
- # expect(chef_run).to delete_env('HOME').with_value('/home')
60
- #
61
- # @example Assert that an +env+ was deleted with attributes
62
- # expect(chef_run).to delete_env('HOME').with(value: 'home')
63
- #
64
- # @example Assert that an +env+ was deleted using a regex
65
- # expect(chef_run).to delete_env('HOME').with(value: /\/ho(.+)/)
66
- #
67
- # @example Assert that an +env+ was _not_ deleted
68
- # expect(chef_run).to_not delete_env('HOME')
69
- #
70
- #
71
- # @param [String, Regex] resource_name
72
- # the name of the resource to match
73
- #
74
- # @return [ChefSpec::Matchers::ResourceMatcher]
75
- #
76
- def delete_env(resource_name)
77
- ChefSpec::Matchers::ResourceMatcher.new(:env, :delete, resource_name)
78
- end
79
-
80
- #
81
- # Assert that an +env+ resource exists in the Chef run with the
82
- # action +:modify+. Given a Chef Recipe that modifies "HOME" as an
83
- # +env+:
84
- #
85
- # env 'HOME' do
86
- # action :modify
87
- # end
88
- #
89
- # The Examples section demonstrates the different ways to test an
90
- # +env+ resource with ChefSpec.
91
- #
92
- # @example Assert that an +env+ was modified
93
- # expect(chef_run).to modify_env('HOME')
94
- #
95
- # @example Assert that an +env+ was modified with predicate matchers
96
- # expect(chef_run).to modify_env('HOME').with_value('/home')
97
- #
98
- # @example Assert that an +env+ was modified with attributes
99
- # expect(chef_run).to modify_env('HOME').with(value: 'home')
100
- #
101
- # @example Assert that an +env+ was modified using a regex
102
- # expect(chef_run).to modify_env('HOME').with(value: /\/ho(.+)/)
103
- #
104
- # @example Assert that an +env+ was _not_ modified
105
- # expect(chef_run).to_not modify_env('HOME')
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_env(resource_name)
114
- ChefSpec::Matchers::ResourceMatcher.new(:env, :modify, resource_name)
115
- end
116
- end
117
- end
@@ -1,43 +0,0 @@
1
- module ChefSpec::API
2
- # @since 3.0.0
3
- module ErlCallMatchers
4
- ChefSpec.define_matcher :erl_call
5
-
6
- #
7
- # Assert that an +erl_call+ resource exists in the Chef run with the
8
- # action +:run+. Given a Chef Recipe that runs "net_adm:names()" as an
9
- # +erl_call+:
10
- #
11
- # erl_call 'net_adm:names()' do
12
- # action :run
13
- # end
14
- #
15
- # The Examples section demonstrates the different ways to test an
16
- # +erl_call+ resource with ChefSpec.
17
- #
18
- # @example Assert that an +erl_call+ was run
19
- # expect(chef_run).to run_erl_call('net_adm:names()')
20
- #
21
- # @example Assert that an +erl_call+ was run with predicate matchers
22
- # expect(chef_run).to run_erl_call('net_adm:names()').with_node_name('example')
23
- #
24
- # @example Assert that an +erl_call+ was run with attributes
25
- # expect(chef_run).to run_erl_call('net_adm:names()').with(node_name: 'example')
26
- #
27
- # @example Assert that an +erl_call+ was run using a regex
28
- # expect(chef_run).to run_erl_call('net_adm:names()').with(node_name: /[a-z]+/)
29
- #
30
- # @example Assert that an +erl_call+ was _not_ run
31
- # expect(chef_run).to_not run_erl_call('net_adm:names()')
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 run_erl_call(resource_name)
40
- ChefSpec::Matchers::ResourceMatcher.new(:erl_call, :run, resource_name)
41
- end
42
- end
43
- end
@@ -1,43 +0,0 @@
1
- module ChefSpec::API
2
- # @since 0.0.1
3
- module ExecuteMatchers
4
- ChefSpec.define_matcher :execute
5
-
6
- #
7
- # Assert that an +execute+ resource exists in the Chef run with the
8
- # action +:run+. Given a Chef Recipe that runs "echo "hello"" as an
9
- # +execute+:
10
- #
11
- # execute 'echo "hello"' do
12
- # action :run
13
- # end
14
- #
15
- # The Examples section demonstrates the different ways to test an
16
- # +execute+ resource with ChefSpec.
17
- #
18
- # @example Assert that an +execute+ was run
19
- # expect(chef_run).to run_execute('echo "hello"')
20
- #
21
- # @example Assert that an +execute+ was run with predicate matchers
22
- # expect(chef_run).to run_execute('echo "hello"').with_user('svargo')
23
- #
24
- # @example Assert that an +execute+ was run with attributes
25
- # expect(chef_run).to run_execute('echo "hello"').with(user: 'svargo')
26
- #
27
- # @example Assert that an +execute+ was run using a regex
28
- # expect(chef_run).to run_execute('echo "hello"').with(user: /sva(.+)/)
29
- #
30
- # @example Assert that an +execute+ was _not_ run
31
- # expect(chef_run).to_not run_execute('echo "hello"')
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 run_execute(resource_name)
40
- ChefSpec::Matchers::ResourceMatcher.new(:execute, :run, resource_name)
41
- end
42
- end
43
- end