chefspec 2.0.1 → 3.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chefspec.rb +30 -44
  3. data/lib/chefspec/api.rb +74 -0
  4. data/lib/chefspec/api/apt_package.rb +192 -0
  5. data/lib/chefspec/api/batch.rb +43 -0
  6. data/lib/chefspec/api/chef_gem.rb +191 -0
  7. data/lib/chefspec/api/cookbook_file.rb +166 -0
  8. data/lib/chefspec/api/cron.rb +80 -0
  9. data/lib/chefspec/api/deploy.rb +117 -0
  10. data/lib/chefspec/api/directory.rb +80 -0
  11. data/lib/chefspec/api/dpkg_package.rb +117 -0
  12. data/lib/chefspec/api/easy_install_package.rb +154 -0
  13. data/lib/chefspec/api/env.rb +117 -0
  14. data/lib/chefspec/api/erl_call.rb +43 -0
  15. data/lib/chefspec/api/execute.rb +43 -0
  16. data/lib/chefspec/api/file.rb +166 -0
  17. data/lib/chefspec/api/freebsd_package.rb +80 -0
  18. data/lib/chefspec/api/gem_package.rb +191 -0
  19. data/lib/chefspec/api/git.rb +117 -0
  20. data/lib/chefspec/api/group.rb +154 -0
  21. data/lib/chefspec/api/http_request.rb +228 -0
  22. data/lib/chefspec/api/ifconfig.rb +154 -0
  23. data/lib/chefspec/api/include_recipe.rb +26 -0
  24. data/lib/chefspec/api/ips_package.rb +117 -0
  25. data/lib/chefspec/api/link.rb +102 -0
  26. data/lib/chefspec/api/log.rb +43 -0
  27. data/lib/chefspec/api/macports_package.rb +154 -0
  28. data/lib/chefspec/api/mdadm.rb +117 -0
  29. data/lib/chefspec/api/mount.rb +192 -0
  30. data/lib/chefspec/api/notifications.rb +38 -0
  31. data/lib/chefspec/api/ohai.rb +43 -0
  32. data/lib/chefspec/api/package.rb +192 -0
  33. data/lib/chefspec/api/pacman_package.rb +155 -0
  34. data/lib/chefspec/api/portage_package.rb +155 -0
  35. data/lib/chefspec/api/powershell_script.rb +43 -0
  36. data/lib/chefspec/api/registry_key.rb +166 -0
  37. data/lib/chefspec/api/remote_directory.rb +120 -0
  38. data/lib/chefspec/api/remote_file.rb +166 -0
  39. data/lib/chefspec/api/render_file.rb +32 -0
  40. data/lib/chefspec/api/route.rb +80 -0
  41. data/lib/chefspec/api/rpm_package.rb +117 -0
  42. data/lib/chefspec/api/ruby_block.rb +37 -0
  43. data/lib/chefspec/api/script.rb +228 -0
  44. data/lib/chefspec/api/service.rb +246 -0
  45. data/lib/chefspec/api/smartos_package.rb +117 -0
  46. data/lib/chefspec/api/solaris_package.rb +80 -0
  47. data/lib/chefspec/api/subversion.rb +154 -0
  48. data/lib/chefspec/api/template.rb +166 -0
  49. data/lib/chefspec/api/user.rb +228 -0
  50. data/lib/chefspec/api/yum_package.rb +154 -0
  51. data/lib/chefspec/berkshelf.rb +37 -0
  52. data/lib/chefspec/deprecations.rb +151 -0
  53. data/lib/chefspec/errors.rb +99 -0
  54. data/lib/chefspec/expect_exception.rb +45 -0
  55. data/lib/chefspec/extensions/chef/client.rb +15 -0
  56. data/lib/chefspec/extensions/chef/conditional.rb +11 -0
  57. data/lib/chefspec/extensions/chef/data_query.rb +29 -0
  58. data/lib/chefspec/extensions/chef/lwrp_base.rb +44 -0
  59. data/lib/chefspec/extensions/chef/resource.rb +27 -0
  60. data/lib/chefspec/extensions/chef/securable.rb +19 -0
  61. data/lib/chefspec/formatter.rb +270 -0
  62. data/lib/chefspec/macros.rb +217 -0
  63. data/lib/chefspec/matchers.rb +9 -0
  64. data/lib/chefspec/matchers/include_recipe_matcher.rb +45 -0
  65. data/lib/chefspec/matchers/link_to_matcher.rb +28 -0
  66. data/lib/chefspec/matchers/notifications_matcher.rb +92 -0
  67. data/lib/chefspec/matchers/render_file_matcher.rb +72 -0
  68. data/lib/chefspec/matchers/resource_matcher.rb +143 -0
  69. data/lib/chefspec/renderer.rb +137 -0
  70. data/lib/chefspec/rspec.rb +17 -0
  71. data/lib/chefspec/runner.rb +274 -0
  72. data/lib/chefspec/stubs/command_registry.rb +11 -0
  73. data/lib/chefspec/stubs/command_stub.rb +37 -0
  74. data/lib/chefspec/stubs/data_bag_item_registry.rb +13 -0
  75. data/lib/chefspec/stubs/data_bag_item_stub.rb +25 -0
  76. data/lib/chefspec/stubs/data_bag_registry.rb +13 -0
  77. data/lib/chefspec/stubs/data_bag_stub.rb +23 -0
  78. data/lib/chefspec/stubs/registry.rb +32 -0
  79. data/lib/chefspec/stubs/search_registry.rb +13 -0
  80. data/lib/chefspec/stubs/search_stub.rb +25 -0
  81. data/lib/chefspec/stubs/stub.rb +37 -0
  82. data/lib/chefspec/version.rb +1 -2
  83. metadata +100 -103
  84. data/lib/chef/expect_exception.rb +0 -34
  85. data/lib/chef/formatters/chefspec.rb +0 -233
  86. data/lib/chef/knife/cookbook_create_specs.rb +0 -107
  87. data/lib/chefspec/chef_runner.rb +0 -275
  88. data/lib/chefspec/helpers/describe.rb +0 -17
  89. data/lib/chefspec/matchers/cron.rb +0 -7
  90. data/lib/chefspec/matchers/env.rb +0 -8
  91. data/lib/chefspec/matchers/execute.rb +0 -33
  92. data/lib/chefspec/matchers/file.rb +0 -83
  93. data/lib/chefspec/matchers/file_content.rb +0 -32
  94. data/lib/chefspec/matchers/group.rb +0 -8
  95. data/lib/chefspec/matchers/include_recipe.rb +0 -20
  96. data/lib/chefspec/matchers/link.rb +0 -14
  97. data/lib/chefspec/matchers/log.rb +0 -21
  98. data/lib/chefspec/matchers/notifications.rb +0 -43
  99. data/lib/chefspec/matchers/package.rb +0 -39
  100. data/lib/chefspec/matchers/python.rb +0 -7
  101. data/lib/chefspec/matchers/ruby_block.rb +0 -13
  102. data/lib/chefspec/matchers/script.rb +0 -34
  103. data/lib/chefspec/matchers/service.rb +0 -25
  104. data/lib/chefspec/matchers/shared.rb +0 -132
  105. data/lib/chefspec/matchers/user.rb +0 -8
  106. data/lib/chefspec/minitest.rb +0 -195
  107. data/lib/chefspec/monkey_patches/conditional.rb +0 -19
  108. data/lib/chefspec/monkey_patches/hash.rb +0 -23
  109. data/lib/chefspec/monkey_patches/lwrp_base.rb +0 -45
  110. data/lib/chefspec/monkey_patches/provider.rb +0 -43
@@ -0,0 +1,32 @@
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 partial path to a template is rendered with matching content
20
+ # expect(template).to render_file(/\/etc\/foo-(\d+)$/).with_content(/^This(.+)$/)
21
+ #
22
+ #
23
+ # @param [String] path
24
+ # the path of the file to render
25
+ #
26
+ # @return [ChefSpec::Matchers::RenderFileMatcher]
27
+ #
28
+ def render_file(path)
29
+ ChefSpec::Matchers::RenderFileMatcher.new(path)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,80 @@
1
+ module ChefSpec::API
2
+ # @since 3.0.0
3
+ module RouteMatchers
4
+ ChefSpec::Runner.define_runner_method :route
5
+
6
+ #
7
+ # Assert that a +route+ resource exists in the Chef run with the
8
+ # action +:add+. Given a Chef Recipe that adds "10.0.0.10/32" as a
9
+ # +route+:
10
+ #
11
+ # route '10.0.0.10/32' do
12
+ # action :add
13
+ # end
14
+ #
15
+ # The Examples section demonstrates the different ways to test a
16
+ # +route+ resource with ChefSpec.
17
+ #
18
+ # @example Assert that a +route+ was added
19
+ # expect(chef_run).to add_route('10.0.0.10/32')
20
+ #
21
+ # @example Assert that a +route+ was added with predicate matchers
22
+ # expect(chef_run).to add_route('10.0.0.10/32').with_device('eth0')
23
+ #
24
+ # @example Assert that a +route+ was added with attributes
25
+ # expect(chef_run).to add_route('10.0.0.10/32').with(device: 'eth0')
26
+ #
27
+ # @example Assert that a +route+ was added using a regex
28
+ # expect(chef_run).to add_route('10.0.0.10/32').with(device: /eth(\d+)/)
29
+ #
30
+ # @example Assert that a +route+ was _not_ added
31
+ # expect(chef_run).to_not add_route('10.0.0.10/32')
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 add_route(resource_name)
40
+ ChefSpec::Matchers::ResourceMatcher.new(:route, :add, resource_name)
41
+ end
42
+
43
+ #
44
+ # Assert that a +route+ resource exists in the Chef run with the
45
+ # action +:delete+. Given a Chef Recipe that deletes "10.0.0.10/32" as a
46
+ # +route+:
47
+ #
48
+ # route '10.0.0.10/32' do
49
+ # action :delete
50
+ # end
51
+ #
52
+ # The Examples section demonstrates the different ways to test a
53
+ # +route+ resource with ChefSpec.
54
+ #
55
+ # @example Assert that a +route+ was deleteed
56
+ # expect(chef_run).to delete_route('10.0.0.10/32')
57
+ #
58
+ # @example Assert that a +route+ was deleteed with predicate matchers
59
+ # expect(chef_run).to delete_route('10.0.0.10/32').with_device('eth0')
60
+ #
61
+ # @example Assert that a +route+ was deleteed with attributes
62
+ # expect(chef_run).to delete_route('10.0.0.10/32').with(device: 'eth0')
63
+ #
64
+ # @example Assert that a +route+ was deleteed using a regex
65
+ # expect(chef_run).to delete_route('10.0.0.10/32').with(device: /eth(\d+)/)
66
+ #
67
+ # @example Assert that a +route+ was _not_ deleteed
68
+ # expect(chef_run).to_not delete_route('10.0.0.10/32')
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_route(resource_name)
77
+ ChefSpec::Matchers::ResourceMatcher.new(:route, :delete, resource_name)
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,117 @@
1
+ module ChefSpec::API
2
+ # @since 3.0.0
3
+ module RpmPackageMatchers
4
+ ChefSpec::Runner.define_runner_method :rpm_package
5
+
6
+ #
7
+ # Assert that a +rpm_package+ resource exists in the Chef run with the
8
+ # action +:install+. Given a Chef Recipe that installs "apache2" as a
9
+ # +rpm_package+:
10
+ #
11
+ # rpm_package 'apache2' do
12
+ # action :install
13
+ # end
14
+ #
15
+ # The Examples section demonstrates the different ways to test a
16
+ # +rpm_package+ resource with ChefSpec.
17
+ #
18
+ # @example Assert that a +rpm_package+ was installed
19
+ # expect(chef_run).to install_rpm_package('apache2')
20
+ #
21
+ # @example Assert that a +rpm_package+ was installed with predicate matchers
22
+ # expect(chef_run).to install_rpm_package('apache2').with_version('1.2.3')
23
+ #
24
+ # @example Assert that a +rpm_package+ was installed with attributes
25
+ # expect(chef_run).to install_rpm_package('apache2').with(version: '1.2.3')
26
+ #
27
+ # @example Assert that a +rpm_package+ was installed using a regex
28
+ # expect(chef_run).to install_rpm_package('apache2').with(version: /(\d+\.){2}\.\d+/)
29
+ #
30
+ # @example Assert that a +rpm_package+ was _not_ installed
31
+ # expect(chef_run).to_not install_rpm_package('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 install_rpm_package(resource_name)
40
+ ChefSpec::Matchers::ResourceMatcher.new(:rpm_package, :install, resource_name)
41
+ end
42
+
43
+ #
44
+ # Assert that a +rpm_package+ resource exists in the Chef run with the
45
+ # action +:remove+. Given a Chef Recipe that removes "apache2" as a
46
+ # +rpm_package+:
47
+ #
48
+ # rpm_package 'apache2' do
49
+ # action :remove
50
+ # end
51
+ #
52
+ # The Examples section demonstrates the different ways to test a
53
+ # +rpm_package+ resource with ChefSpec.
54
+ #
55
+ # @example Assert that a +rpm_package+ was removed
56
+ # expect(chef_run).to remove_rpm_package('apache2')
57
+ #
58
+ # @example Assert that a +rpm_package+ was removed with predicate matchers
59
+ # expect(chef_run).to remove_rpm_package('apache2').with_version('1.2.3')
60
+ #
61
+ # @example Assert that a +rpm_package+ was removed with attributes
62
+ # expect(chef_run).to remove_rpm_package('apache2').with(version: '1.2.3')
63
+ #
64
+ # @example Assert that a +rpm_package+ was removed using a regex
65
+ # expect(chef_run).to remove_rpm_package('apache2').with(version: /(\d+\.){2}\.\d+/)
66
+ #
67
+ # @example Assert that a +rpm_package+ was _not_ removed
68
+ # expect(chef_run).to_not remove_rpm_package('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_rpm_package(resource_name)
77
+ ChefSpec::Matchers::ResourceMatcher.new(:rpm_package, :remove, resource_name)
78
+ end
79
+
80
+ #
81
+ # Assert that a +rpm_package+ resource exists in the Chef run with the
82
+ # action +:upgrade+. Given a Chef Recipe that upgrades "apache2" as a
83
+ # +rpm_package+:
84
+ #
85
+ # rpm_package 'apache2' do
86
+ # action :upgrade
87
+ # end
88
+ #
89
+ # The Examples section demonstrates the different ways to test a
90
+ # +rpm_package+ resource with ChefSpec.
91
+ #
92
+ # @example Assert that a +rpm_package+ was upgraded
93
+ # expect(chef_run).to upgrade_rpm_package('apache2')
94
+ #
95
+ # @example Assert that a +rpm_package+ was upgraded with predicate matchers
96
+ # expect(chef_run).to upgrade_rpm_package('apache2').with_version('1.2.3')
97
+ #
98
+ # @example Assert that a +rpm_package+ was upgraded with attributes
99
+ # expect(chef_run).to upgrade_rpm_package('apache2').with(version: '1.2.3')
100
+ #
101
+ # @example Assert that a +rpm_package+ was upgraded using a regex
102
+ # expect(chef_run).to upgrade_rpm_package('apache2').with(version: /(\d+\.){2}\.\d+/)
103
+ #
104
+ # @example Assert that a +rpm_package+ was _not_ upgraded
105
+ # expect(chef_run).to_not upgrade_rpm_package('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 upgrade_rpm_package(resource_name)
114
+ ChefSpec::Matchers::ResourceMatcher.new(:rpm_package, :upgrade, resource_name)
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,37 @@
1
+ module ChefSpec::API
2
+ # @since 0.5.0
3
+ module RubyBlockMatchers
4
+ ChefSpec::Runner.define_runner_method :ruby_block
5
+
6
+ #
7
+ # Assert that a +ruby_block+ resource exists in the Chef run with the
8
+ # action +:run+. Given a Chef Recipe that runs "do_something" as a
9
+ # +ruby_block+:
10
+ #
11
+ # ruby_block 'do_something' do
12
+ # block do
13
+ # # ...
14
+ # end
15
+ # action :run
16
+ # end
17
+ #
18
+ # The Examples section demonstrates the different ways to test a
19
+ # +ruby_block+ resource with ChefSpec.
20
+ #
21
+ # @example Assert that a +ruby_block+ was runed
22
+ # expect(chef_run).to run_ruby_block('do_something')
23
+ #
24
+ # @example Assert that a +ruby_block+ was _not_ runed
25
+ # expect(chef_run).to_not run_ruby_block('do_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_ruby_block(resource_name)
34
+ ChefSpec::Matchers::ResourceMatcher.new(:ruby_block, :run, resource_name)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,228 @@
1
+ module ChefSpec::API
2
+ # @since 1.0.0
3
+ module ScriptMatchers
4
+ ChefSpec::Runner.define_runner_method :script
5
+
6
+ #
7
+ # Assert that a +bash+ resource exists in the Chef run with the
8
+ # action +:run+. Given a Chef Recipe that runs "command" using
9
+ # +bash+:
10
+ #
11
+ # bash 'command' do
12
+ # action :run
13
+ # end
14
+ #
15
+ # The Examples section demonstrates the different ways to test a
16
+ # +bash+ resource with ChefSpec.
17
+ #
18
+ # @example Assert that a +bash+ was run
19
+ # expect(chef_run).to run_bash('command')
20
+ #
21
+ # @example Assert that a +bash+ was run with predicate matchers
22
+ # expect(chef_run).to run_bash('command').with_cwd('/home')
23
+ #
24
+ # @example Assert that a +bash+ was run with attributes
25
+ # expect(chef_run).to run_bash('command').with(cwd: '/home')
26
+ #
27
+ # @example Assert that a +bash+ was run using a regex
28
+ # expect(chef_run).to run_bash('command').with(cwd: /\/(.+)/)
29
+ #
30
+ # @example Assert that a +bash+ was _not_ run
31
+ # expect(chef_run).to_not run_bash('command')
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_bash(resource_name)
40
+ ChefSpec::Matchers::ResourceMatcher.new(:bash, :run, resource_name)
41
+ end
42
+
43
+ #
44
+ # Assert that a +csh+ resource exists in the Chef run with the
45
+ # action +:run+. Given a Chef Recipe that runs "command" using
46
+ # +csh+:
47
+ #
48
+ # csh 'command' do
49
+ # action :run
50
+ # end
51
+ #
52
+ # The Examples section demonstrates the different ways to test a
53
+ # +csh+ resource with ChefSpec.
54
+ #
55
+ # @example Assert that a +csh+ was run
56
+ # expect(chef_run).to run_csh('command')
57
+ #
58
+ # @example Assert that a +csh+ was run with predicate matchers
59
+ # expect(chef_run).to run_csh('command').with_cwd('/home')
60
+ #
61
+ # @example Assert that a +csh+ was run with attributes
62
+ # expect(chef_run).to run_csh('command').with(cwd: '/home')
63
+ #
64
+ # @example Assert that a +csh+ was run using a regex
65
+ # expect(chef_run).to run_csh('command').with(cwd: /\/(.+)/)
66
+ #
67
+ # @example Assert that a +csh+ was _not_ run
68
+ # expect(chef_run).to_not run_csh('command')
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 run_csh(resource_name)
77
+ ChefSpec::Matchers::ResourceMatcher.new(:csh, :run, resource_name)
78
+ end
79
+
80
+ #
81
+ # Assert that a +perl+ resource exists in the Chef run with the
82
+ # action +:run+. Given a Chef Recipe that runs "command" using
83
+ # +perl+:
84
+ #
85
+ # perl 'command' do
86
+ # action :run
87
+ # end
88
+ #
89
+ # The Examples section demonstrates the different ways to test a
90
+ # +perl+ resource with ChefSpec.
91
+ #
92
+ # @example Assert that a +perl+ was run
93
+ # expect(chef_run).to run_perl('command')
94
+ #
95
+ # @example Assert that a +perl+ was run with predicate matchers
96
+ # expect(chef_run).to run_perl('command').with_cwd('/home')
97
+ #
98
+ # @example Assert that a +perl+ was run with attributes
99
+ # expect(chef_run).to run_perl('command').with(cwd: '/home')
100
+ #
101
+ # @example Assert that a +perl+ was run using a regex
102
+ # expect(chef_run).to run_perl('command').with(cwd: /\/(.+)/)
103
+ #
104
+ # @example Assert that a +perl+ was _not_ run
105
+ # expect(chef_run).to_not run_perl('command')
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 run_perl(resource_name)
114
+ ChefSpec::Matchers::ResourceMatcher.new(:perl, :run, resource_name)
115
+ end
116
+
117
+ #
118
+ # Assert that a +python+ resource exists in the Chef run with the
119
+ # action +:run+. Given a Chef Recipe that runs "command" using
120
+ # +python+:
121
+ #
122
+ # python 'command' do
123
+ # action :run
124
+ # end
125
+ #
126
+ # The Examples section demonstrates the different ways to test a
127
+ # +python+ resource with ChefSpec.
128
+ #
129
+ # @example Assert that a +python+ was run
130
+ # expect(chef_run).to run_python('command')
131
+ #
132
+ # @example Assert that a +python+ was run with predicate matchers
133
+ # expect(chef_run).to run_python('command').with_cwd('/home')
134
+ #
135
+ # @example Assert that a +python+ was run with attributes
136
+ # expect(chef_run).to run_python('command').with(cwd: '/home')
137
+ #
138
+ # @example Assert that a +python+ was run using a regex
139
+ # expect(chef_run).to run_python('command').with(cwd: /\/(.+)/)
140
+ #
141
+ # @example Assert that a +python+ was _not_ run
142
+ # expect(chef_run).to_not run_python('command')
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 run_python(resource_name)
151
+ ChefSpec::Matchers::ResourceMatcher.new(:python, :run, resource_name)
152
+ end
153
+
154
+ #
155
+ # Assert that a +ruby+ resource exists in the Chef run with the
156
+ # action +:run+. Given a Chef Recipe that runs "command" using
157
+ # +ruby+:
158
+ #
159
+ # ruby 'command' do
160
+ # action :run
161
+ # end
162
+ #
163
+ # The Examples section demonstrates the different ways to test a
164
+ # +ruby+ resource with ChefSpec.
165
+ #
166
+ # @example Assert that a +ruby+ was run
167
+ # expect(chef_run).to run_ruby('command')
168
+ #
169
+ # @example Assert that a +ruby+ was run with predicate matchers
170
+ # expect(chef_run).to run_ruby('command').with_cwd('/home')
171
+ #
172
+ # @example Assert that a +ruby+ was run with attributes
173
+ # expect(chef_run).to run_ruby('command').with(cwd: '/home')
174
+ #
175
+ # @example Assert that a +ruby+ was run using a regex
176
+ # expect(chef_run).to run_ruby('command').with(cwd: /\/(.+)/)
177
+ #
178
+ # @example Assert that a +ruby+ was _not_ run
179
+ # expect(chef_run).to_not run_ruby('command')
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 run_ruby(resource_name)
188
+ ChefSpec::Matchers::ResourceMatcher.new(:ruby, :run, resource_name)
189
+ end
190
+
191
+ #
192
+ # Assert that a +script+ resource exists in the Chef run with the
193
+ # action +:run+. Given a Chef Recipe that runs "command" using
194
+ # +script+:
195
+ #
196
+ # script 'command' do
197
+ # action :run
198
+ # end
199
+ #
200
+ # The Examples section demonstrates the different ways to test a
201
+ # +script+ resource with ChefSpec.
202
+ #
203
+ # @example Assert that a +script+ was run
204
+ # expect(chef_run).to run_script('command')
205
+ #
206
+ # @example Assert that a +script+ was run with predicate matchers
207
+ # expect(chef_run).to run_script('command').with_cwd('/home')
208
+ #
209
+ # @example Assert that a +script+ was run with attributes
210
+ # expect(chef_run).to run_script('command').with(cwd: '/home')
211
+ #
212
+ # @example Assert that a +script+ was run using a regex
213
+ # expect(chef_run).to run_script('command').with(cwd: /\/(.+)/)
214
+ #
215
+ # @example Assert that a +script+ was _not_ run
216
+ # expect(chef_run).to_not run_script('command')
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 run_script(resource_name)
225
+ ChefSpec::Matchers::ResourceMatcher.new(:script, :run, resource_name)
226
+ end
227
+ end
228
+ end