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.
- checksums.yaml +4 -4
- data/lib/chefspec.rb +30 -44
- data/lib/chefspec/api.rb +74 -0
- data/lib/chefspec/api/apt_package.rb +192 -0
- data/lib/chefspec/api/batch.rb +43 -0
- data/lib/chefspec/api/chef_gem.rb +191 -0
- data/lib/chefspec/api/cookbook_file.rb +166 -0
- data/lib/chefspec/api/cron.rb +80 -0
- data/lib/chefspec/api/deploy.rb +117 -0
- data/lib/chefspec/api/directory.rb +80 -0
- data/lib/chefspec/api/dpkg_package.rb +117 -0
- data/lib/chefspec/api/easy_install_package.rb +154 -0
- data/lib/chefspec/api/env.rb +117 -0
- data/lib/chefspec/api/erl_call.rb +43 -0
- data/lib/chefspec/api/execute.rb +43 -0
- data/lib/chefspec/api/file.rb +166 -0
- data/lib/chefspec/api/freebsd_package.rb +80 -0
- data/lib/chefspec/api/gem_package.rb +191 -0
- data/lib/chefspec/api/git.rb +117 -0
- data/lib/chefspec/api/group.rb +154 -0
- data/lib/chefspec/api/http_request.rb +228 -0
- data/lib/chefspec/api/ifconfig.rb +154 -0
- data/lib/chefspec/api/include_recipe.rb +26 -0
- data/lib/chefspec/api/ips_package.rb +117 -0
- data/lib/chefspec/api/link.rb +102 -0
- data/lib/chefspec/api/log.rb +43 -0
- data/lib/chefspec/api/macports_package.rb +154 -0
- data/lib/chefspec/api/mdadm.rb +117 -0
- data/lib/chefspec/api/mount.rb +192 -0
- data/lib/chefspec/api/notifications.rb +38 -0
- data/lib/chefspec/api/ohai.rb +43 -0
- data/lib/chefspec/api/package.rb +192 -0
- data/lib/chefspec/api/pacman_package.rb +155 -0
- data/lib/chefspec/api/portage_package.rb +155 -0
- data/lib/chefspec/api/powershell_script.rb +43 -0
- data/lib/chefspec/api/registry_key.rb +166 -0
- data/lib/chefspec/api/remote_directory.rb +120 -0
- data/lib/chefspec/api/remote_file.rb +166 -0
- data/lib/chefspec/api/render_file.rb +32 -0
- data/lib/chefspec/api/route.rb +80 -0
- data/lib/chefspec/api/rpm_package.rb +117 -0
- data/lib/chefspec/api/ruby_block.rb +37 -0
- data/lib/chefspec/api/script.rb +228 -0
- data/lib/chefspec/api/service.rb +246 -0
- data/lib/chefspec/api/smartos_package.rb +117 -0
- data/lib/chefspec/api/solaris_package.rb +80 -0
- data/lib/chefspec/api/subversion.rb +154 -0
- data/lib/chefspec/api/template.rb +166 -0
- data/lib/chefspec/api/user.rb +228 -0
- data/lib/chefspec/api/yum_package.rb +154 -0
- data/lib/chefspec/berkshelf.rb +37 -0
- data/lib/chefspec/deprecations.rb +151 -0
- data/lib/chefspec/errors.rb +99 -0
- data/lib/chefspec/expect_exception.rb +45 -0
- data/lib/chefspec/extensions/chef/client.rb +15 -0
- data/lib/chefspec/extensions/chef/conditional.rb +11 -0
- data/lib/chefspec/extensions/chef/data_query.rb +29 -0
- data/lib/chefspec/extensions/chef/lwrp_base.rb +44 -0
- data/lib/chefspec/extensions/chef/resource.rb +27 -0
- data/lib/chefspec/extensions/chef/securable.rb +19 -0
- data/lib/chefspec/formatter.rb +270 -0
- data/lib/chefspec/macros.rb +217 -0
- data/lib/chefspec/matchers.rb +9 -0
- data/lib/chefspec/matchers/include_recipe_matcher.rb +45 -0
- data/lib/chefspec/matchers/link_to_matcher.rb +28 -0
- data/lib/chefspec/matchers/notifications_matcher.rb +92 -0
- data/lib/chefspec/matchers/render_file_matcher.rb +72 -0
- data/lib/chefspec/matchers/resource_matcher.rb +143 -0
- data/lib/chefspec/renderer.rb +137 -0
- data/lib/chefspec/rspec.rb +17 -0
- data/lib/chefspec/runner.rb +274 -0
- data/lib/chefspec/stubs/command_registry.rb +11 -0
- data/lib/chefspec/stubs/command_stub.rb +37 -0
- data/lib/chefspec/stubs/data_bag_item_registry.rb +13 -0
- data/lib/chefspec/stubs/data_bag_item_stub.rb +25 -0
- data/lib/chefspec/stubs/data_bag_registry.rb +13 -0
- data/lib/chefspec/stubs/data_bag_stub.rb +23 -0
- data/lib/chefspec/stubs/registry.rb +32 -0
- data/lib/chefspec/stubs/search_registry.rb +13 -0
- data/lib/chefspec/stubs/search_stub.rb +25 -0
- data/lib/chefspec/stubs/stub.rb +37 -0
- data/lib/chefspec/version.rb +1 -2
- metadata +100 -103
- data/lib/chef/expect_exception.rb +0 -34
- data/lib/chef/formatters/chefspec.rb +0 -233
- data/lib/chef/knife/cookbook_create_specs.rb +0 -107
- data/lib/chefspec/chef_runner.rb +0 -275
- data/lib/chefspec/helpers/describe.rb +0 -17
- data/lib/chefspec/matchers/cron.rb +0 -7
- data/lib/chefspec/matchers/env.rb +0 -8
- data/lib/chefspec/matchers/execute.rb +0 -33
- data/lib/chefspec/matchers/file.rb +0 -83
- data/lib/chefspec/matchers/file_content.rb +0 -32
- data/lib/chefspec/matchers/group.rb +0 -8
- data/lib/chefspec/matchers/include_recipe.rb +0 -20
- data/lib/chefspec/matchers/link.rb +0 -14
- data/lib/chefspec/matchers/log.rb +0 -21
- data/lib/chefspec/matchers/notifications.rb +0 -43
- data/lib/chefspec/matchers/package.rb +0 -39
- data/lib/chefspec/matchers/python.rb +0 -7
- data/lib/chefspec/matchers/ruby_block.rb +0 -13
- data/lib/chefspec/matchers/script.rb +0 -34
- data/lib/chefspec/matchers/service.rb +0 -25
- data/lib/chefspec/matchers/shared.rb +0 -132
- data/lib/chefspec/matchers/user.rb +0 -8
- data/lib/chefspec/minitest.rb +0 -195
- data/lib/chefspec/monkey_patches/conditional.rb +0 -19
- data/lib/chefspec/monkey_patches/hash.rb +0 -23
- data/lib/chefspec/monkey_patches/lwrp_base.rb +0 -45
- data/lib/chefspec/monkey_patches/provider.rb +0 -43
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 804fd5cc6af81945c28e0e0e65d94e935ff0bb82
|
|
4
|
+
data.tar.gz: d9d195301868641521b6159d67106e3ac7a6abd2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5f951adb7cdac28459d0e0df5172e6a2e1124776a4335dcc62a6ff06c80264ca7b39290de15df21cea551b51528252e304249c2fcf45ad3888ec3fe67b2970f5
|
|
7
|
+
data.tar.gz: 7165b07393a29850245dd0fdff9d21f9222816acb723e9e381b5c195ff180f6e87be26e8013b9e5d99b73458fdde7861c510da479f7cd089f7cda21a327abf3a
|
data/lib/chefspec.rb
CHANGED
|
@@ -1,48 +1,34 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require 'chef/formatters/chefspec'
|
|
3
|
-
require 'chef/expect_exception'
|
|
4
|
-
require 'chefspec/chef_runner'
|
|
5
|
-
require 'chefspec/version'
|
|
1
|
+
require 'rspec'
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
require 'chefspec/matchers/package'
|
|
14
|
-
require 'chefspec/matchers/ruby_block'
|
|
15
|
-
require 'chefspec/matchers/service'
|
|
16
|
-
require 'chefspec/matchers/shared'
|
|
17
|
-
require 'chefspec/matchers/notifications'
|
|
18
|
-
require 'chefspec/matchers/file_content'
|
|
19
|
-
require 'chefspec/matchers/user'
|
|
20
|
-
require 'chefspec/matchers/group'
|
|
21
|
-
require 'chefspec/matchers/env'
|
|
22
|
-
require 'chefspec/matchers/include_recipe'
|
|
23
|
-
require 'chefspec/matchers/script'
|
|
24
|
-
require 'chefspec/matchers/python'
|
|
3
|
+
require_relative 'chefspec/extensions/chef/client'
|
|
4
|
+
require_relative 'chefspec/extensions/chef/conditional'
|
|
5
|
+
require_relative 'chefspec/extensions/chef/data_query'
|
|
6
|
+
require_relative 'chefspec/extensions/chef/lwrp_base'
|
|
7
|
+
require_relative 'chefspec/extensions/chef/resource'
|
|
8
|
+
require_relative 'chefspec/extensions/chef/securable'
|
|
25
9
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
10
|
+
require_relative 'chefspec/stubs/command_registry'
|
|
11
|
+
require_relative 'chefspec/stubs/command_stub'
|
|
12
|
+
require_relative 'chefspec/stubs/data_bag_item_registry'
|
|
13
|
+
require_relative 'chefspec/stubs/data_bag_item_stub'
|
|
14
|
+
require_relative 'chefspec/stubs/data_bag_registry'
|
|
15
|
+
require_relative 'chefspec/stubs/data_bag_stub'
|
|
16
|
+
require_relative 'chefspec/stubs/registry'
|
|
17
|
+
require_relative 'chefspec/stubs/stub'
|
|
18
|
+
require_relative 'chefspec/stubs/search_registry'
|
|
19
|
+
require_relative 'chefspec/stubs/search_stub'
|
|
31
20
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
21
|
+
require_relative 'chefspec/api'
|
|
22
|
+
require_relative 'chefspec/errors'
|
|
23
|
+
require_relative 'chefspec/expect_exception'
|
|
24
|
+
require_relative 'chefspec/formatter'
|
|
25
|
+
require_relative 'chefspec/macros'
|
|
26
|
+
require_relative 'chefspec/matchers'
|
|
27
|
+
require_relative 'chefspec/renderer'
|
|
28
|
+
require_relative 'chefspec/rspec'
|
|
29
|
+
require_relative 'chefspec/runner'
|
|
30
|
+
require_relative 'chefspec/version'
|
|
37
31
|
|
|
38
|
-
module
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Gem::Requirement.new('~> 11.0').satisfied_by?(Gem::Version.new(Chef::VERSION))
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def chef_10?
|
|
45
|
-
Gem::Requirement.new('~> 10.0').satisfied_by?(Gem::Version.new(Chef::VERSION))
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
32
|
+
# Load deprecations module last, so it can monkey patch and print out nasty
|
|
33
|
+
# deprecation warnings for us :)
|
|
34
|
+
require_relative 'chefspec/deprecations'
|
data/lib/chefspec/api.rb
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require_relative 'runner'
|
|
2
|
+
|
|
3
|
+
module ChefSpec
|
|
4
|
+
module API
|
|
5
|
+
extend self
|
|
6
|
+
|
|
7
|
+
def self.included(base)
|
|
8
|
+
submodules.each do |child|
|
|
9
|
+
base.send(:include, child)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
#
|
|
15
|
+
# WARNING: This is metaprogramming madness. Find all modules who are
|
|
16
|
+
# nested beneath this module.
|
|
17
|
+
#
|
|
18
|
+
# @return [Array<Module>]
|
|
19
|
+
#
|
|
20
|
+
def submodules
|
|
21
|
+
self.constants
|
|
22
|
+
.map { |name| const_get(name) }
|
|
23
|
+
.select { |const| const.class == Module }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
require_relative 'api/apt_package'
|
|
29
|
+
require_relative 'api/batch'
|
|
30
|
+
require_relative 'api/chef_gem'
|
|
31
|
+
require_relative 'api/cookbook_file'
|
|
32
|
+
require_relative 'api/cron'
|
|
33
|
+
require_relative 'api/deploy'
|
|
34
|
+
require_relative 'api/directory'
|
|
35
|
+
require_relative 'api/dpkg_package'
|
|
36
|
+
require_relative 'api/easy_install_package'
|
|
37
|
+
require_relative 'api/env'
|
|
38
|
+
require_relative 'api/erl_call'
|
|
39
|
+
require_relative 'api/execute'
|
|
40
|
+
require_relative 'api/file'
|
|
41
|
+
require_relative 'api/freebsd_package'
|
|
42
|
+
require_relative 'api/gem_package'
|
|
43
|
+
require_relative 'api/git'
|
|
44
|
+
require_relative 'api/group'
|
|
45
|
+
require_relative 'api/http_request'
|
|
46
|
+
require_relative 'api/ifconfig'
|
|
47
|
+
require_relative 'api/include_recipe'
|
|
48
|
+
require_relative 'api/ips_package'
|
|
49
|
+
require_relative 'api/link'
|
|
50
|
+
require_relative 'api/log'
|
|
51
|
+
require_relative 'api/macports_package'
|
|
52
|
+
require_relative 'api/mdadm'
|
|
53
|
+
require_relative 'api/mount'
|
|
54
|
+
require_relative 'api/notifications'
|
|
55
|
+
require_relative 'api/ohai'
|
|
56
|
+
require_relative 'api/package'
|
|
57
|
+
require_relative 'api/pacman_package'
|
|
58
|
+
require_relative 'api/portage_package'
|
|
59
|
+
require_relative 'api/powershell_script'
|
|
60
|
+
require_relative 'api/registry_key'
|
|
61
|
+
require_relative 'api/remote_directory'
|
|
62
|
+
require_relative 'api/remote_file'
|
|
63
|
+
require_relative 'api/render_file'
|
|
64
|
+
require_relative 'api/route'
|
|
65
|
+
require_relative 'api/rpm_package'
|
|
66
|
+
require_relative 'api/ruby_block'
|
|
67
|
+
require_relative 'api/script'
|
|
68
|
+
require_relative 'api/service'
|
|
69
|
+
require_relative 'api/smartos_package'
|
|
70
|
+
require_relative 'api/solaris_package'
|
|
71
|
+
require_relative 'api/subversion'
|
|
72
|
+
require_relative 'api/template'
|
|
73
|
+
require_relative 'api/user'
|
|
74
|
+
require_relative 'api/yum_package'
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
module ChefSpec::API
|
|
2
|
+
# @since 3.0.0
|
|
3
|
+
module AptPackageMatchers
|
|
4
|
+
ChefSpec::Runner.define_runner_method :apt_package
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
# Assert that an +apt_package+ resource exists in the Chef run with the
|
|
8
|
+
# action +:install+. Given a Chef Recipe that installs "apache2" as an
|
|
9
|
+
# +apt_package+:
|
|
10
|
+
#
|
|
11
|
+
# apt_package 'apache2' do
|
|
12
|
+
# action :install
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# The Examples section demonstrates the different ways to test an
|
|
16
|
+
# +apt_package+ resource with ChefSpec.
|
|
17
|
+
#
|
|
18
|
+
# @example Assert that an +apt_package+ was installed
|
|
19
|
+
# expect(chef_run).to install_apt_package('apache2')
|
|
20
|
+
#
|
|
21
|
+
# @example Assert that an +apt_package+ was installed with predicate matchers
|
|
22
|
+
# expect(chef_run).to install_apt_package('apache2').with_version('1.2.3')
|
|
23
|
+
#
|
|
24
|
+
# @example Assert that an +apt_package+ was installed with attributes
|
|
25
|
+
# expect(chef_run).to install_apt_package('apache2').with(version: '1.2.3')
|
|
26
|
+
#
|
|
27
|
+
# @example Assert that an +apt_package+ was installed using a regex
|
|
28
|
+
# expect(chef_run).to install_apt_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
|
29
|
+
#
|
|
30
|
+
# @example Assert that an +apt_package+ was _not_ installed
|
|
31
|
+
# expect(chef_run).to_not install_apt_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_apt_package(resource_name)
|
|
40
|
+
ChefSpec::Matchers::ResourceMatcher.new(:apt_package, :install, resource_name)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# Assert that an +apt_package+ resource exists in the Chef run with the
|
|
45
|
+
# action +:purge+. Given a Chef Recipe that purges "apache2" as an
|
|
46
|
+
# +apt_package+:
|
|
47
|
+
#
|
|
48
|
+
# apt_package 'apache2' do
|
|
49
|
+
# action :purge
|
|
50
|
+
# end
|
|
51
|
+
#
|
|
52
|
+
# The Examples section demonstrates the different ways to test an
|
|
53
|
+
# +apt_package+ resource with ChefSpec.
|
|
54
|
+
#
|
|
55
|
+
# @example Assert that an +apt_package+ was purged
|
|
56
|
+
# expect(chef_run).to purge_apt_package('apache2')
|
|
57
|
+
#
|
|
58
|
+
# @example Assert that an +apt_package+ was purged with predicate matchers
|
|
59
|
+
# expect(chef_run).to purge_apt_package('apache2').with_version('1.2.3')
|
|
60
|
+
#
|
|
61
|
+
# @example Assert that an +apt_package+ was purged with attributes
|
|
62
|
+
# expect(chef_run).to purge_apt_package('apache2').with(version: '1.2.3')
|
|
63
|
+
#
|
|
64
|
+
# @example Assert that an +apt_package+ was purged using a regex
|
|
65
|
+
# expect(chef_run).to purge_apt_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
|
66
|
+
#
|
|
67
|
+
# @example Assert that an +apt_package+ was _not_ purged
|
|
68
|
+
# expect(chef_run).to_not purge_apt_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_apt_package(resource_name)
|
|
77
|
+
ChefSpec::Matchers::ResourceMatcher.new(:apt_package, :purge, resource_name)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
#
|
|
81
|
+
# Assert that an +apt_package+ resource exists in the Chef run with the
|
|
82
|
+
# action +:reconfig+. Given a Chef Recipe that reconfigures "apache2" as an
|
|
83
|
+
# +apt_package+:
|
|
84
|
+
#
|
|
85
|
+
# apt_package 'apache2' do
|
|
86
|
+
# action :reconfig
|
|
87
|
+
# end
|
|
88
|
+
#
|
|
89
|
+
# The Examples section demonstrates the different ways to test an
|
|
90
|
+
# +apt_package+ resource with ChefSpec.
|
|
91
|
+
#
|
|
92
|
+
# @example Assert that an +apt_package+ was reconfigured
|
|
93
|
+
# expect(chef_run).to reconfig_apt_package('apache2')
|
|
94
|
+
#
|
|
95
|
+
# @example Assert that an +apt_package+ was reconfigured with predicate matchers
|
|
96
|
+
# expect(chef_run).to reconfig_apt_package('apache2').with_version('1.2.3')
|
|
97
|
+
#
|
|
98
|
+
# @example Assert that an +apt_package+ was reconfigured with attributes
|
|
99
|
+
# expect(chef_run).to reconfig_apt_package('apache2').with(version: '1.2.3')
|
|
100
|
+
#
|
|
101
|
+
# @example Assert that an +apt_package+ was reconfigured using a regex
|
|
102
|
+
# expect(chef_run).to reconfig_apt_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
|
103
|
+
#
|
|
104
|
+
# @example Assert that an +apt_package+ was _not_ reconfigured
|
|
105
|
+
# expect(chef_run).to_not reconfig_apt_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 reconfig_apt_package(resource_name)
|
|
114
|
+
ChefSpec::Matchers::ResourceMatcher.new(:apt_package, :reconfig, resource_name)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
#
|
|
118
|
+
# Assert that an +apt_package+ resource exists in the Chef run with the
|
|
119
|
+
# action +:remove+. Given a Chef Recipe that removes "apache2" as an
|
|
120
|
+
# +apt_package+:
|
|
121
|
+
#
|
|
122
|
+
# apt_package 'apache2' do
|
|
123
|
+
# action :remove
|
|
124
|
+
# end
|
|
125
|
+
#
|
|
126
|
+
# The Examples section demonstrates the different ways to test an
|
|
127
|
+
# +apt_package+ resource with ChefSpec.
|
|
128
|
+
#
|
|
129
|
+
# @example Assert that an +apt_package+ was removed
|
|
130
|
+
# expect(chef_run).to remove_apt_package('apache2')
|
|
131
|
+
#
|
|
132
|
+
# @example Assert that an +apt_package+ was removed with predicate matchers
|
|
133
|
+
# expect(chef_run).to remove_apt_package('apache2').with_version('1.2.3')
|
|
134
|
+
#
|
|
135
|
+
# @example Assert that an +apt_package+ was removed with attributes
|
|
136
|
+
# expect(chef_run).to remove_apt_package('apache2').with(version: '1.2.3')
|
|
137
|
+
#
|
|
138
|
+
# @example Assert that an +apt_package+ was removed using a regex
|
|
139
|
+
# expect(chef_run).to remove_apt_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
|
140
|
+
#
|
|
141
|
+
# @example Assert that an +apt_package+ was _not_ removed
|
|
142
|
+
# expect(chef_run).to_not remove_apt_package('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 remove_apt_package(resource_name)
|
|
151
|
+
ChefSpec::Matchers::ResourceMatcher.new(:apt_package, :remove, resource_name)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
#
|
|
155
|
+
# Assert that an +apt_package+ resource exists in the Chef run with the
|
|
156
|
+
# action +:upgrade+. Given a Chef Recipe that upgrades "apache2" as an
|
|
157
|
+
# +apt_package+:
|
|
158
|
+
#
|
|
159
|
+
# apt_package 'apache2' do
|
|
160
|
+
# action :upgrade
|
|
161
|
+
# end
|
|
162
|
+
#
|
|
163
|
+
# The Examples section demonstrates the different ways to test an
|
|
164
|
+
# +apt_package+ resource with ChefSpec.
|
|
165
|
+
#
|
|
166
|
+
# @example Assert that an +apt_package+ was upgraded
|
|
167
|
+
# expect(chef_run).to upgrade_apt_package('apache2')
|
|
168
|
+
#
|
|
169
|
+
# @example Assert that an +apt_package+ was upgraded with predicate matchers
|
|
170
|
+
# expect(chef_run).to upgrade_apt_package('apache2').with_version('1.2.3')
|
|
171
|
+
#
|
|
172
|
+
# @example Assert that an +apt_package+ was upgraded with attributes
|
|
173
|
+
# expect(chef_run).to upgrade_apt_package('apache2').with(version: '1.2.3')
|
|
174
|
+
#
|
|
175
|
+
# @example Assert that an +apt_package+ was upgraded using a regex
|
|
176
|
+
# expect(chef_run).to upgrade_apt_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
|
177
|
+
#
|
|
178
|
+
# @example Assert that an +apt_package+ was _not_ upgraded
|
|
179
|
+
# expect(chef_run).to_not upgrade_apt_package('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 upgrade_apt_package(resource_name)
|
|
188
|
+
ChefSpec::Matchers::ResourceMatcher.new(:apt_package, :upgrade, resource_name)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
end
|
|
192
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module ChefSpec::API
|
|
2
|
+
# @since 3.0.0
|
|
3
|
+
module BatchMatchers
|
|
4
|
+
ChefSpec::Runner.define_runner_method :batch
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
# Assert that a +batch+ resource exists in the Chef run with the
|
|
8
|
+
# action +:run+. Given a Chef Recipe that runs "unzip" using
|
|
9
|
+
# +batch+:
|
|
10
|
+
#
|
|
11
|
+
# batch 'unzip' do
|
|
12
|
+
# action :run
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# The Examples section demonstrates the different ways to test a
|
|
16
|
+
# +batch+ resource with ChefSpec.
|
|
17
|
+
#
|
|
18
|
+
# @example Assert that a +batch+ was run
|
|
19
|
+
# expect(chef_run).to run_batch('unzip')
|
|
20
|
+
#
|
|
21
|
+
# @example Assert that a +batch+ was run with predicate matchers
|
|
22
|
+
# expect(chef_run).to run_batch('unzip').with_cwd('/home')
|
|
23
|
+
#
|
|
24
|
+
# @example Assert that a +batch+ was run with attributes
|
|
25
|
+
# expect(chef_run).to run_batch('unzip').with(cwd: '/home')
|
|
26
|
+
#
|
|
27
|
+
# @example Assert that a +batch+ was run using a regex
|
|
28
|
+
# expect(chef_run).to run_batch('unzip').with(cwd: /\/(.+)/)
|
|
29
|
+
#
|
|
30
|
+
# @example Assert that a +batch+ was _not_ run
|
|
31
|
+
# expect(chef_run).to_not run_batch('unzip')
|
|
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_batch(resource_name)
|
|
40
|
+
ChefSpec::Matchers::ResourceMatcher.new(:batch, :run, resource_name)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
module ChefSpec::API
|
|
2
|
+
# @since 0.8.0
|
|
3
|
+
module ChefGemMatchers
|
|
4
|
+
ChefSpec::Runner.define_runner_method :chef_gem
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
# Assert that a +chef_gem+ resource exists in the Chef run with the
|
|
8
|
+
# action +:install+. Given a Chef Recipe that installs "community-zero" as a
|
|
9
|
+
# +chef_gem+:
|
|
10
|
+
#
|
|
11
|
+
# chef_gem 'community-zero' do
|
|
12
|
+
# action :install
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# The Examples section demonstrates the different ways to test a
|
|
16
|
+
# +chef_gem+ resource with ChefSpec.
|
|
17
|
+
#
|
|
18
|
+
# @example Assert that a +chef_gem+ was installed
|
|
19
|
+
# expect(chef_run).to install_chef_gem('community-zero')
|
|
20
|
+
#
|
|
21
|
+
# @example Assert that a +chef_gem+ was installed with predicate matchers
|
|
22
|
+
# expect(chef_run).to install_chef_gem('community-zero').with_version('1.2.3')
|
|
23
|
+
#
|
|
24
|
+
# @example Assert that a +chef_gem+ was installed with attributes
|
|
25
|
+
# expect(chef_run).to install_chef_gem('community-zero').with(version: '1.2.3')
|
|
26
|
+
#
|
|
27
|
+
# @example Assert that a +chef_gem+ was installed using a regex
|
|
28
|
+
# expect(chef_run).to install_chef_gem('community-zero').with(version: /(\d+\.){2}\.\d+/)
|
|
29
|
+
#
|
|
30
|
+
# @example Assert that a +chef_gem+ was _not_ installed
|
|
31
|
+
# expect(chef_run).to_not install_chef_gem('community-zero')
|
|
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_chef_gem(resource_name)
|
|
40
|
+
ChefSpec::Matchers::ResourceMatcher.new(:chef_gem, :install, resource_name)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# Assert that a +chef_gem+ resource exists in the Chef run with the
|
|
45
|
+
# action +:purge+. Given a Chef Recipe that purges "community-zero" as a
|
|
46
|
+
# +chef_gem+:
|
|
47
|
+
#
|
|
48
|
+
# chef_gem 'community-zero' do
|
|
49
|
+
# action :purge
|
|
50
|
+
# end
|
|
51
|
+
#
|
|
52
|
+
# The Examples section demonstrates the different ways to test a
|
|
53
|
+
# +chef_gem+ resource with ChefSpec.
|
|
54
|
+
#
|
|
55
|
+
# @example Assert that a +chef_gem+ was purgeed
|
|
56
|
+
# expect(chef_run).to purge_chef_gem('community-zero')
|
|
57
|
+
#
|
|
58
|
+
# @example Assert that a +chef_gem+ was purgeed with predicate matchers
|
|
59
|
+
# expect(chef_run).to purge_chef_gem('community-zero').with_version('1.2.3')
|
|
60
|
+
#
|
|
61
|
+
# @example Assert that a +chef_gem+ was purgeed with attributes
|
|
62
|
+
# expect(chef_run).to purge_chef_gem('community-zero').with(version: '1.2.3')
|
|
63
|
+
#
|
|
64
|
+
# @example Assert that a +chef_gem+ was purgeed using a regex
|
|
65
|
+
# expect(chef_run).to purge_chef_gem('community-zero').with(version: /(\d+\.){2}\.\d+/)
|
|
66
|
+
#
|
|
67
|
+
# @example Assert that a +chef_gem+ was _not_ purgeed
|
|
68
|
+
# expect(chef_run).to_not purge_chef_gem('community-zero')
|
|
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_chef_gem(resource_name)
|
|
77
|
+
ChefSpec::Matchers::ResourceMatcher.new(:chef_gem, :purge, resource_name)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
#
|
|
81
|
+
# Assert that a +chef_gem+ resource exists in the Chef run with the
|
|
82
|
+
# action +:reconfig+. Given a Chef Recipe that reconfigures "community-zero"
|
|
83
|
+
# as a +chef_gem+:
|
|
84
|
+
#
|
|
85
|
+
# chef_gem 'community-zero' do
|
|
86
|
+
# action :reconfig
|
|
87
|
+
# end
|
|
88
|
+
#
|
|
89
|
+
# The Examples section demonstrates the different ways to test a
|
|
90
|
+
# +chef_gem+ resource with ChefSpec.
|
|
91
|
+
#
|
|
92
|
+
# @example Assert that a +chef_gem+ was reconfigured
|
|
93
|
+
# expect(chef_run).to reconfig_chef_gem('community-zero')
|
|
94
|
+
#
|
|
95
|
+
# @example Assert that a +chef_gem+ was reconfigured with predicate matchers
|
|
96
|
+
# expect(chef_run).to reconfig_chef_gem('community-zero').with_version('1.2.3')
|
|
97
|
+
#
|
|
98
|
+
# @example Assert that a +chef_gem+ was reconfigured with attributes
|
|
99
|
+
# expect(chef_run).to reconfig_chef_gem('community-zero').with(version: '1.2.3')
|
|
100
|
+
#
|
|
101
|
+
# @example Assert that a +chef_gem+ was reconfigured using a regex
|
|
102
|
+
# expect(chef_run).to reconfig_chef_gem('community-zero').with(version: /(\d+\.){2}\.\d+/)
|
|
103
|
+
#
|
|
104
|
+
# @example Assert that a +chef_gem+ was _not_ reconfigured
|
|
105
|
+
# expect(chef_run).to_not reconfig_chef_gem('community-zero')
|
|
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 reconfig_chef_gem(resource_name)
|
|
114
|
+
ChefSpec::Matchers::ResourceMatcher.new(:chef_gem, :reconfig, resource_name)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
#
|
|
118
|
+
# Assert that a +chef_gem+ resource exists in the Chef run with the
|
|
119
|
+
# action +:remove+. Given a Chef Recipe that removes "community-zero" as a
|
|
120
|
+
# +chef_gem+:
|
|
121
|
+
#
|
|
122
|
+
# chef_gem 'community-zero' do
|
|
123
|
+
# action :remove
|
|
124
|
+
# end
|
|
125
|
+
#
|
|
126
|
+
# The Examples section demonstrates the different ways to test a
|
|
127
|
+
# +chef_gem+ resource with ChefSpec.
|
|
128
|
+
#
|
|
129
|
+
# @example Assert that a +chef_gem+ was removeed
|
|
130
|
+
# expect(chef_run).to remove_chef_gem('community-zero')
|
|
131
|
+
#
|
|
132
|
+
# @example Assert that a +chef_gem+ was removeed with predicate matchers
|
|
133
|
+
# expect(chef_run).to remove_chef_gem('community-zero').with_version('1.2.3')
|
|
134
|
+
#
|
|
135
|
+
# @example Assert that a +chef_gem+ was removeed with attributes
|
|
136
|
+
# expect(chef_run).to remove_chef_gem('community-zero').with(version: '1.2.3')
|
|
137
|
+
#
|
|
138
|
+
# @example Assert that a +chef_gem+ was removeed using a regex
|
|
139
|
+
# expect(chef_run).to remove_chef_gem('community-zero').with(version: /(\d+\.){2}\.\d+/)
|
|
140
|
+
#
|
|
141
|
+
# @example Assert that a +chef_gem+ was _not_ removeed
|
|
142
|
+
# expect(chef_run).to_not remove_chef_gem('community-zero')
|
|
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 remove_chef_gem(resource_name)
|
|
151
|
+
ChefSpec::Matchers::ResourceMatcher.new(:chef_gem, :remove, resource_name)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
#
|
|
155
|
+
# Assert that a +chef_gem+ resource exists in the Chef run with the
|
|
156
|
+
# action +:upgrade+. Given a Chef Recipe that upgrades "community-zero" as a
|
|
157
|
+
# +chef_gem+:
|
|
158
|
+
#
|
|
159
|
+
# chef_gem 'community-zero' do
|
|
160
|
+
# action :upgrade
|
|
161
|
+
# end
|
|
162
|
+
#
|
|
163
|
+
# The Examples section demonstrates the different ways to test a
|
|
164
|
+
# +chef_gem+ resource with ChefSpec.
|
|
165
|
+
#
|
|
166
|
+
# @example Assert that a +chef_gem+ was upgradeed
|
|
167
|
+
# expect(chef_run).to upgrade_chef_gem('community-zero')
|
|
168
|
+
#
|
|
169
|
+
# @example Assert that a +chef_gem+ was upgradeed with predicate matchers
|
|
170
|
+
# expect(chef_run).to upgrade_chef_gem('community-zero').with_version('1.2.3')
|
|
171
|
+
#
|
|
172
|
+
# @example Assert that a +chef_gem+ was upgradeed with attributes
|
|
173
|
+
# expect(chef_run).to upgrade_chef_gem('community-zero').with(version: '1.2.3')
|
|
174
|
+
#
|
|
175
|
+
# @example Assert that a +chef_gem+ was upgradeed using a regex
|
|
176
|
+
# expect(chef_run).to upgrade_chef_gem('community-zero').with(version: /(\d+\.){2}\.\d+/)
|
|
177
|
+
#
|
|
178
|
+
# @example Assert that a +chef_gem+ was _not_ upgradeed
|
|
179
|
+
# expect(chef_run).to_not upgrade_chef_gem('community-zero')
|
|
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 upgrade_chef_gem(resource_name)
|
|
188
|
+
ChefSpec::Matchers::ResourceMatcher.new(:chef_gem, :upgrade, resource_name)
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|