chefspec 2.0.1 → 3.0.0.beta.1

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 (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,166 @@
1
+ module ChefSpec::API
2
+ # @since 0.0.1
3
+ module CookbookFileMatchers
4
+ ChefSpec::Runner.define_runner_method :cookbook_file
5
+
6
+ #
7
+ # Assert that a +cookbook_file+ resource exists in the Chef run with the
8
+ # action +:create+. Given a Chef Recipe that creates "/tmp/config" as a
9
+ # +cookbook_file+:
10
+ #
11
+ # cookbook_file '/tmp/config' do
12
+ # action :create
13
+ # end
14
+ #
15
+ # To test the content rendered by a +cookbook_file+, see
16
+ # {ChefSpec::API::RenderFileMatchers}.
17
+ #
18
+ # The Examples section demonstrates the different ways to test a
19
+ # +cookbook_file+ resource with ChefSpec.
20
+ #
21
+ # @example Assert that a +cookbook_file+ was created
22
+ # expect(chef_run).to create_cookbook_file('/tmp/config')
23
+ #
24
+ # @example Assert that a +cookbook_file+ was created with predicate matchers
25
+ # expect(chef_run).to create_cookbook_file('/tmp/config').with_backup(false)
26
+ #
27
+ # @example Assert that a +cookbook_file+ was created with attributes
28
+ # expect(chef_run).to create_cookbook_file('/tmp/config').with(backup: false)
29
+ #
30
+ # @example Assert that a +cookbook_file+ was created using a regex
31
+ # expect(chef_run).to create_cookbook_file('/tmp/config').with(user: /apa(.+)/)
32
+ #
33
+ # @example Assert that a +cookbook_file+ was _not_ created
34
+ # expect(chef_run).to_not create_cookbook_file('/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_cookbook_file(resource_name)
43
+ ChefSpec::Matchers::ResourceMatcher.new(:cookbook_file, :create, resource_name)
44
+ end
45
+
46
+ #
47
+ # Assert that a +cookbook_file+ 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 +cookbook_file+:
50
+ #
51
+ # cookbook_file '/tmp/config' do
52
+ # action :create_if_missing
53
+ # end
54
+ #
55
+ # To test the content rendered by a +cookbook_file+, see
56
+ # {ChefSpec::API::RenderFileMatchers}.
57
+ #
58
+ # The Examples section demonstrates the different ways to test a
59
+ # +cookbook_file+ resource with ChefSpec.
60
+ #
61
+ # @example Assert that a +cookbook_file+ was created if missing
62
+ # expect(chef_run).to create_cookbook_file_if_missing('/tmp/config')
63
+ #
64
+ # @example Assert that a +cookbook_file+ was created if missing with predicate matchers
65
+ # expect(chef_run).to create_cookbook_file_if_missing('/tmp/config').with_backup(false)
66
+ #
67
+ # @example Assert that a +cookbook_file+ was created if missing with attributes
68
+ # expect(chef_run).to create_cookbook_file_if_missing('/tmp/config').with(backup: false)
69
+ #
70
+ # @example Assert that a +cookbook_file+ was created if missing using a regex
71
+ # expect(chef_run).to create_cookbook_file_if_missing('/tmp/config').with(user: /apa(.+)/)
72
+ #
73
+ # @example Assert that a +cookbook_file+ was _not_ created if missing
74
+ # expect(chef_run).to_not create_cookbook_file('/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_cookbook_file_if_missing(resource_name)
83
+ ChefSpec::Matchers::ResourceMatcher.new(:cookbook_file, :create_if_missing, resource_name)
84
+ end
85
+
86
+ #
87
+ # Assert that a +cookbook_file+ resource exists in the Chef run with the
88
+ # action +:delete+. Given a Chef Recipe that deletes "/tmp/config" as a
89
+ # +cookbook_file+:
90
+ #
91
+ # cookbook_file '/tmp/config' do
92
+ # action :delete
93
+ # end
94
+ #
95
+ # To test the content rendered by a +cookbook_file+, see
96
+ # {ChefSpec::API::RenderFileMatchers}.
97
+ #
98
+ # The Examples section demonstrates the different ways to test a
99
+ # +cookbook_file+ resource with ChefSpec.
100
+ #
101
+ # @example Assert that a +cookbook_file+ was deleted
102
+ # expect(chef_run).to delete_cookbook_file('/tmp/config')
103
+ #
104
+ # @example Assert that a +cookbook_file+ was deleted with predicate matchers
105
+ # expect(chef_run).to delete_cookbook_file('/tmp/config').with_backup(false)
106
+ #
107
+ # @example Assert that a +cookbook_file+ was deleted with attributes
108
+ # expect(chef_run).to delete_cookbook_file('/tmp/config').with(backup: false)
109
+ #
110
+ # @example Assert that a +cookbook_file+ was deleted using a regex
111
+ # expect(chef_run).to delete_cookbook_file('/tmp/config').with(user: /apa(.+)/)
112
+ #
113
+ # @example Assert that a +cookbook_file+ was _not_ deleted
114
+ # expect(chef_run).to_not delete_cookbook_file('/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_cookbook_file(resource_name)
123
+ ChefSpec::Matchers::ResourceMatcher.new(:cookbook_file, :delete, resource_name)
124
+ end
125
+
126
+ #
127
+ # Assert that a +cookbook_file+ resource exists in the Chef run with the
128
+ # action +:touch+. Given a Chef Recipe that touches "/tmp/config" as a
129
+ # +cookbook_file+:
130
+ #
131
+ # cookbook_file '/tmp/config' do
132
+ # action :touch
133
+ # end
134
+ #
135
+ # To test the content rendered by a +cookbook_file+, see
136
+ # {ChefSpec::API::RenderFileMatchers}.
137
+ #
138
+ # The Examples section demonstrates the different ways to test a
139
+ # +cookbook_file+ resource with ChefSpec.
140
+ #
141
+ # @example Assert that a +cookbook_file+ was touched
142
+ # expect(chef_run).to touch_cookbook_file('/tmp/config')
143
+ #
144
+ # @example Assert that a +cookbook_file+ was touched with predicate matchers
145
+ # expect(chef_run).to touch_cookbook_file('/tmp/config').with_backup(false)
146
+ #
147
+ # @example Assert that a +cookbook_file+ was touched with attributes
148
+ # expect(chef_run).to touch_cookbook_file('/tmp/config').with(backup: false)
149
+ #
150
+ # @example Assert that a +cookbook_file+ was touched using a regex
151
+ # expect(chef_run).to touch_cookbook_file('/tmp/config').with(user: /apa(.+)/)
152
+ #
153
+ # @example Assert that a +cookbook_file+ was _not_ touched
154
+ # expect(chef_run).to_not touch_cookbook_file('/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_cookbook_file(resource_name)
163
+ ChefSpec::Matchers::ResourceMatcher.new(:cookbook_file, :touch, resource_name)
164
+ end
165
+ end
166
+ end
@@ -0,0 +1,80 @@
1
+ module ChefSpec::API
2
+ # @since 0.7.0
3
+ module CronMatchers
4
+ ChefSpec::Runner.define_runner_method :cron
5
+
6
+ #
7
+ # Assert that a +cron+ resource exists in the Chef run with the
8
+ # action +:create+. Given a Chef Recipe that creates "ping nagios" as a
9
+ # +cron+:
10
+ #
11
+ # cron 'ping nagios' do
12
+ # action :create
13
+ # end
14
+ #
15
+ # The Examples section demonstrates the different ways to test a
16
+ # +cron+ resource with ChefSpec.
17
+ #
18
+ # @example Assert that a +cron+ was created
19
+ # expect(chef_run).to create_cron('ping nagios')
20
+ #
21
+ # @example Assert that a +cron+ was created with predicate matchers
22
+ # expect(chef_run).to create_cron('ping nagios').with_home('/home')
23
+ #
24
+ # @example Assert that a +cron+ was created with attributes
25
+ # expect(chef_run).to create_cron('ping nagios').with(home: '/home')
26
+ #
27
+ # @example Assert that a +cron+ was created using a regex
28
+ # expect(chef_run).to create_cron('ping nagios').with(home: /\/home/)
29
+ #
30
+ # @example Assert that a +cron+ was _not_ created
31
+ # expect(chef_run).to_not create_cron('ping nagios')
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_cron(resource_name)
40
+ ChefSpec::Matchers::ResourceMatcher.new(:cron, :create, resource_name)
41
+ end
42
+
43
+ #
44
+ # Assert that a +cron+ resource exists in the Chef run with the
45
+ # action +:delete+. Given a Chef Recipe that deletes "ping nagios" as a
46
+ # +cron+:
47
+ #
48
+ # cron 'ping nagios' do
49
+ # action :delete
50
+ # end
51
+ #
52
+ # The Examples section demonstrates the different ways to test a
53
+ # +cron+ resource with ChefSpec.
54
+ #
55
+ # @example Assert that a +cron+ was deleted
56
+ # expect(chef_run).to delete_cron('ping nagios')
57
+ #
58
+ # @example Assert that a +cron+ was deleted with predicate matchers
59
+ # expect(chef_run).to delete_cron('ping nagios').with_home('/home')
60
+ #
61
+ # @example Assert that a +cron+ was deleted with attributes
62
+ # expect(chef_run).to delete_cron('ping nagios').with(home: '/home')
63
+ #
64
+ # @example Assert that a +cron+ was deleted using a regex
65
+ # expect(chef_run).to delete_cron('ping nagios').with(home: /\/home/)
66
+ #
67
+ # @example Assert that a +cron+ was _not_ deleted
68
+ # expect(chef_run).to_not delete_cron('ping nagios')
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_cron(resource_name)
77
+ ChefSpec::Matchers::ResourceMatcher.new(:cron, :delete, resource_name)
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,117 @@
1
+ module ChefSpec::API
2
+ # @since 3.0.0
3
+ module DeployMatchers
4
+ ChefSpec::Runner.define_runner_method :deploy
5
+
6
+ #
7
+ # Assert that a +deploy+ resource exists in the Chef run with the
8
+ # action +:deploy+. Given a Chef Recipe that deploys "/tmp/path" as a
9
+ # +deploy+:
10
+ #
11
+ # deploy '/tmp/path' do
12
+ # action :deploy
13
+ # end
14
+ #
15
+ # The Examples section demonstrates the different ways to test a
16
+ # +deploy+ resource with ChefSpec.
17
+ #
18
+ # @example Assert that a +deploy+ was deployed
19
+ # expect(chef_run).to deploy_deploy('/tmp/path')
20
+ #
21
+ # @example Assert that a +deploy+ was deployed with predicate matchers
22
+ # expect(chef_run).to deploy_deploy('/tmp/path').with_repo('ssh://...')
23
+ #
24
+ # @example Assert that a +deploy+ was deployed with attributes
25
+ # expect(chef_run).to deploy_deploy('/tmp/path').with(repo: 'ssh://...')
26
+ #
27
+ # @example Assert that a +deploy+ was deployed using a regex
28
+ # expect(chef_run).to deploy_deploy('/tmp/path').with(repo: /ssh:(.+)/)
29
+ #
30
+ # @example Assert that a +deploy+ was _not_ deployed
31
+ # expect(chef_run).to_not deploy_deploy('/tmp/path')
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 deploy_deploy(resource_name)
40
+ ChefSpec::Matchers::ResourceMatcher.new(:deploy, :deploy, resource_name)
41
+ end
42
+
43
+ #
44
+ # Assert that a +deploy+ resource exists in the Chef run with the
45
+ # action +:force_deploy+. Given a Chef Recipe that force_deploys "/tmp/path" as a
46
+ # +deploy+:
47
+ #
48
+ # deploy '/tmp/path' do
49
+ # action :force_deploy
50
+ # end
51
+ #
52
+ # The Examples section demonstrates the different ways to test a
53
+ # +deploy+ resource with ChefSpec.
54
+ #
55
+ # @example Assert that a +deploy+ was force_deployed
56
+ # expect(chef_run).to force_deploy_deploy('/tmp/path')
57
+ #
58
+ # @example Assert that a +deploy+ was force_deployed with predicate matchers
59
+ # expect(chef_run).to force_deploy_deploy('/tmp/path').with_repo('ssh://...')
60
+ #
61
+ # @example Assert that a +deploy+ was force_deployed with attributes
62
+ # expect(chef_run).to force_deploy_deploy('/tmp/path').with(repo: 'ssh://...')
63
+ #
64
+ # @example Assert that a +deploy+ was force_deployed using a regex
65
+ # expect(chef_run).to force_deploy_deploy('/tmp/path').with(repo: /ssh:(.+)/)
66
+ #
67
+ # @example Assert that a +deploy+ was _not_ force_deployed
68
+ # expect(chef_run).to_not force_deploy_deploy('/tmp/path')
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 force_deploy_deploy(resource_name)
77
+ ChefSpec::Matchers::ResourceMatcher.new(:deploy, :force_deploy, resource_name)
78
+ end
79
+
80
+ #
81
+ # Assert that a +deploy+ resource exists in the Chef run with the
82
+ # action +:rollback+. Given a Chef Recipe that rolls back "/tmp/path" as a
83
+ # +deploy+:
84
+ #
85
+ # deploy '/tmp/path' do
86
+ # action :rollback
87
+ # end
88
+ #
89
+ # The Examples section demonstrates the different ways to test a
90
+ # +deploy+ resource with ChefSpec.
91
+ #
92
+ # @example Assert that a +deploy+ was rolled back
93
+ # expect(chef_run).to rollback_deploy('/tmp/path')
94
+ #
95
+ # @example Assert that a +deploy+ was rolled back with predicate matchers
96
+ # expect(chef_run).to rollback_deploy('/tmp/path').with_repo('ssh://...')
97
+ #
98
+ # @example Assert that a +deploy+ was rolled back with attributes
99
+ # expect(chef_run).to rollback_deploy('/tmp/path').with(repo: 'ssh://...')
100
+ #
101
+ # @example Assert that a +deploy+ was rolled back using a regex
102
+ # expect(chef_run).to rollback_deploy('/tmp/path').with(repo: /ssh:(.+)/)
103
+ #
104
+ # @example Assert that a +deploy+ was _not_ rolled back
105
+ # expect(chef_run).to_not rollback_deploy('/tmp/path')
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 rollback_deploy(resource_name)
114
+ ChefSpec::Matchers::ResourceMatcher.new(:deploy, :rollback, resource_name)
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,80 @@
1
+ module ChefSpec::API
2
+ # @since 0.0.1
3
+ module DirectoryMatchers
4
+ ChefSpec::Runner.define_runner_method :directory
5
+
6
+ #
7
+ # Assert that a +directory+ resource exists in the Chef run with the
8
+ # action +:create+. Given a Chef Recipe that creates "/tmp" as a
9
+ # +directory+:
10
+ #
11
+ # directory '/tmp' do
12
+ # action :create
13
+ # end
14
+ #
15
+ # The Examples section demonstrates the different ways to test a
16
+ # +directory+ resource with ChefSpec.
17
+ #
18
+ # @example Assert that a +directory+ was createed
19
+ # expect(chef_run).to create_directory('/tmp')
20
+ #
21
+ # @example Assert that a +directory+ was createed with predicate matchers
22
+ # expect(chef_run).to create_directory('/tmp').with_user('svargo')
23
+ #
24
+ # @example Assert that a +directory+ was createed with attributes
25
+ # expect(chef_run).to create_directory('/tmp').with(user: 'svargo')
26
+ #
27
+ # @example Assert that a +directory+ was createed using a regex
28
+ # expect(chef_run).to create_directory('/tmp').with(user: /sva(.+)/)
29
+ #
30
+ # @example Assert that a +directory+ was _not_ createed
31
+ # expect(chef_run).to_not create_directory('/tmp')
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_directory(resource_name)
40
+ ChefSpec::Matchers::ResourceMatcher.new(:directory, :create, resource_name)
41
+ end
42
+
43
+ #
44
+ # Assert that a +directory+ resource exists in the Chef run with the
45
+ # action +:delete+. Given a Chef Recipe that deletes "/tmp" as a
46
+ # +directory+:
47
+ #
48
+ # directory '/tmp' do
49
+ # action :delete
50
+ # end
51
+ #
52
+ # The Examples section demonstrates the different ways to test a
53
+ # +directory+ resource with ChefSpec.
54
+ #
55
+ # @example Assert that a +directory+ was deleteed
56
+ # expect(chef_run).to delete_directory('/tmp')
57
+ #
58
+ # @example Assert that a +directory+ was deleteed with predicate matchers
59
+ # expect(chef_run).to delete_directory('/tmp').with_user('svargo')
60
+ #
61
+ # @example Assert that a +directory+ was deleteed with attributes
62
+ # expect(chef_run).to delete_directory('/tmp').with(user: 'svargo')
63
+ #
64
+ # @example Assert that a +directory+ was deleteed using a regex
65
+ # expect(chef_run).to delete_directory('/tmp').with(user: /sva(.+)/)
66
+ #
67
+ # @example Assert that a +directory+ was _not_ deleteed
68
+ # expect(chef_run).to_not delete_directory('/tmp')
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_directory(resource_name)
77
+ ChefSpec::Matchers::ResourceMatcher.new(:directory, :delete, resource_name)
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,117 @@
1
+ module ChefSpec::API
2
+ # @since 3.0.0
3
+ module DpkgPackageMatchers
4
+ ChefSpec::Runner.define_runner_method :dpkg_package
5
+
6
+ #
7
+ # Assert that a +dpkg_package+ resource exists in the Chef run with the
8
+ # action +:install+. Given a Chef Recipe that installs "apache2" as a
9
+ # +dpkg_package+:
10
+ #
11
+ # dpkg_package 'apache2' do
12
+ # action :install
13
+ # end
14
+ #
15
+ # The Examples section demonstrates the different ways to test a
16
+ # +dpkg_package+ resource with ChefSpec.
17
+ #
18
+ # @example Assert that a +dpkg_package+ was installed
19
+ # expect(chef_run).to install_dpkg_package('apache2')
20
+ #
21
+ # @example Assert that a +dpkg_package+ was installed with predicate matchers
22
+ # expect(chef_run).to install_dpkg_package('apache2').with_version('1.2.3')
23
+ #
24
+ # @example Assert that a +dpkg_package+ was installed with attributes
25
+ # expect(chef_run).to install_dpkg_package('apache2').with(version: '1.2.3')
26
+ #
27
+ # @example Assert that a +dpkg_package+ was installed using a regex
28
+ # expect(chef_run).to install_dpkg_package('apache2').with(version: /(\d+\.){2}\.\d+/)
29
+ #
30
+ # @example Assert that a +dpkg_package+ was _not_ installed
31
+ # expect(chef_run).to_not install_dpkg_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_dpkg_package(resource_name)
40
+ ChefSpec::Matchers::ResourceMatcher.new(:dpkg_package, :install, resource_name)
41
+ end
42
+
43
+ #
44
+ # Assert that a +dpkg_package+ resource exists in the Chef run with the
45
+ # action +:purge+. Given a Chef Recipe that purges "apache2" as a
46
+ # +dpkg_package+:
47
+ #
48
+ # dpkg_package 'apache2' do
49
+ # action :purge
50
+ # end
51
+ #
52
+ # The Examples section demonstrates the different ways to test a
53
+ # +dpkg_package+ resource with ChefSpec.
54
+ #
55
+ # @example Assert that a +dpkg_package+ was purged
56
+ # expect(chef_run).to purge_dpkg_package('apache2')
57
+ #
58
+ # @example Assert that a +dpkg_package+ was purged with predicate matchers
59
+ # expect(chef_run).to purge_dpkg_package('apache2').with_version('1.2.3')
60
+ #
61
+ # @example Assert that a +dpkg_package+ was purged with attributes
62
+ # expect(chef_run).to purge_dpkg_package('apache2').with(version: '1.2.3')
63
+ #
64
+ # @example Assert that a +dpkg_package+ was purged using a regex
65
+ # expect(chef_run).to purge_dpkg_package('apache2').with(version: /(\d+\.){2}\.\d+/)
66
+ #
67
+ # @example Assert that a +dpkg_package+ was _not_ purged
68
+ # expect(chef_run).to_not purge_dpkg_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 purge_dpkg_package(resource_name)
77
+ ChefSpec::Matchers::ResourceMatcher.new(:dpkg_package, :purge, resource_name)
78
+ end
79
+
80
+ #
81
+ # Assert that a +dpkg_package+ resource exists in the Chef run with the
82
+ # action +:remove+. Given a Chef Recipe that removes "apache2" as a
83
+ # +dpkg_package+:
84
+ #
85
+ # dpkg_package 'apache2' do
86
+ # action :remove
87
+ # end
88
+ #
89
+ # The Examples section demonstrates the different ways to test a
90
+ # +dpkg_package+ resource with ChefSpec.
91
+ #
92
+ # @example Assert that a +dpkg_package+ was removed
93
+ # expect(chef_run).to remove_dpkg_package('apache2')
94
+ #
95
+ # @example Assert that a +dpkg_package+ was removed with predicate matchers
96
+ # expect(chef_run).to remove_dpkg_package('apache2').with_version('1.2.3')
97
+ #
98
+ # @example Assert that a +dpkg_package+ was removed with attributes
99
+ # expect(chef_run).to remove_dpkg_package('apache2').with(version: '1.2.3')
100
+ #
101
+ # @example Assert that a +dpkg_package+ was removed using a regex
102
+ # expect(chef_run).to remove_dpkg_package('apache2').with(version: /(\d+\.){2}\.\d+/)
103
+ #
104
+ # @example Assert that a +dpkg_package+ was _not_ removed
105
+ # expect(chef_run).to_not remove_dpkg_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 remove_dpkg_package(resource_name)
114
+ ChefSpec::Matchers::ResourceMatcher.new(:dpkg_package, :remove, resource_name)
115
+ end
116
+ end
117
+ end