chefspec 5.2.0 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/README.md +3 -3
  4. data/chefspec.gemspec +1 -1
  5. data/examples/bff_package/recipes/install.rb +13 -0
  6. data/examples/bff_package/recipes/purge.rb +13 -0
  7. data/examples/bff_package/recipes/remove.rb +13 -0
  8. data/examples/bff_package/recipes/upgrade.rb +13 -0
  9. data/examples/bff_package/spec/install_spec.rb +23 -0
  10. data/examples/bff_package/spec/purge_spec.rb +19 -0
  11. data/examples/bff_package/spec/remove_spec.rb +19 -0
  12. data/examples/bff_package/spec/upgrade_spec.rb +19 -0
  13. data/examples/homebrew_package/recipes/install.rb +13 -0
  14. data/examples/homebrew_package/recipes/purge.rb +13 -0
  15. data/examples/homebrew_package/recipes/remove.rb +13 -0
  16. data/examples/homebrew_package/recipes/upgrade.rb +13 -0
  17. data/examples/homebrew_package/spec/install_spec.rb +23 -0
  18. data/examples/homebrew_package/spec/purge_spec.rb +19 -0
  19. data/examples/homebrew_package/spec/remove_spec.rb +19 -0
  20. data/examples/homebrew_package/spec/upgrade_spec.rb +19 -0
  21. data/examples/launchd/recipes/create.rb +5 -0
  22. data/examples/launchd/recipes/create_if_missing.rb +3 -0
  23. data/examples/launchd/recipes/delete.rb +3 -0
  24. data/examples/launchd/recipes/disable.rb +3 -0
  25. data/examples/launchd/recipes/enable.rb +3 -0
  26. data/examples/launchd/spec/create_if_missing_spec.rb +10 -0
  27. data/examples/launchd/spec/create_spec.rb +14 -0
  28. data/examples/launchd/spec/delete_spec.rb +10 -0
  29. data/examples/launchd/spec/disable_spec.rb +10 -0
  30. data/examples/launchd/spec/enable_spec.rb +10 -0
  31. data/examples/openbsd_package/recipes/install.rb +13 -0
  32. data/examples/openbsd_package/recipes/purge.rb +13 -0
  33. data/examples/openbsd_package/recipes/remove.rb +13 -0
  34. data/examples/openbsd_package/recipes/upgrade.rb +13 -0
  35. data/examples/openbsd_package/spec/install_spec.rb +23 -0
  36. data/examples/openbsd_package/spec/purge_spec.rb +19 -0
  37. data/examples/openbsd_package/spec/remove_spec.rb +19 -0
  38. data/examples/openbsd_package/spec/upgrade_spec.rb +19 -0
  39. data/examples/osx_profile/recipes/install.rb +8 -0
  40. data/examples/osx_profile/recipes/remove.rb +8 -0
  41. data/examples/osx_profile/spec/install_spec.rb +15 -0
  42. data/examples/osx_profile/spec/remove_spec.rb +13 -0
  43. data/examples/paludis_package/recipes/install.rb +13 -0
  44. data/examples/paludis_package/recipes/purge.rb +13 -0
  45. data/examples/paludis_package/recipes/remove.rb +13 -0
  46. data/examples/paludis_package/recipes/upgrade.rb +13 -0
  47. data/examples/paludis_package/spec/install_spec.rb +23 -0
  48. data/examples/paludis_package/spec/purge_spec.rb +19 -0
  49. data/examples/paludis_package/spec/remove_spec.rb +19 -0
  50. data/examples/paludis_package/spec/upgrade_spec.rb +19 -0
  51. data/examples/ruby_block/recipes/create.rb +8 -0
  52. data/examples/ruby_block/spec/create_spec.rb +13 -0
  53. data/examples/script/recipes/run_ksh.rb +13 -0
  54. data/examples/script/spec/run_ksh_spec.rb +23 -0
  55. data/examples/solaris_package/recipes/upgrade.rb +13 -0
  56. data/examples/solaris_package/spec/upgrade_spec.rb +19 -0
  57. data/examples/systemd_unit/recipes/create.rb +3 -0
  58. data/examples/systemd_unit/recipes/delete.rb +3 -0
  59. data/examples/systemd_unit/recipes/disable.rb +3 -0
  60. data/examples/systemd_unit/recipes/enable.rb +3 -0
  61. data/examples/systemd_unit/recipes/mask.rb +3 -0
  62. data/examples/systemd_unit/recipes/reload_or_restart.rb +3 -0
  63. data/examples/systemd_unit/recipes/reload_or_try_restart.rb +3 -0
  64. data/examples/systemd_unit/recipes/restart.rb +3 -0
  65. data/examples/systemd_unit/recipes/start.rb +3 -0
  66. data/examples/systemd_unit/recipes/stop.rb +3 -0
  67. data/examples/systemd_unit/recipes/try_restart.rb +3 -0
  68. data/examples/systemd_unit/recipes/unmask.rb +3 -0
  69. data/examples/systemd_unit/spec/create_spec.rb +10 -0
  70. data/examples/systemd_unit/spec/delete_spec.rb +10 -0
  71. data/examples/systemd_unit/spec/disable_spec.rb +10 -0
  72. data/examples/systemd_unit/spec/enable_spec.rb +10 -0
  73. data/examples/systemd_unit/spec/mask_spec.rb +10 -0
  74. data/examples/systemd_unit/spec/reload_or_restart_spec.rb +10 -0
  75. data/examples/systemd_unit/spec/reload_or_try_restart_spec.rb +10 -0
  76. data/examples/systemd_unit/spec/restart_spec.rb +10 -0
  77. data/examples/systemd_unit/spec/start_spec.rb +10 -0
  78. data/examples/systemd_unit/spec/stop_spec.rb +10 -0
  79. data/examples/systemd_unit/spec/try_restart_spec.rb +10 -0
  80. data/examples/systemd_unit/spec/unmask_spec.rb +10 -0
  81. data/examples/zypper_package/recipes/install.rb +13 -0
  82. data/examples/zypper_package/recipes/purge.rb +13 -0
  83. data/examples/zypper_package/recipes/remove.rb +13 -0
  84. data/examples/zypper_package/recipes/upgrade.rb +13 -0
  85. data/examples/zypper_package/spec/install_spec.rb +23 -0
  86. data/examples/zypper_package/spec/purge_spec.rb +19 -0
  87. data/examples/zypper_package/spec/remove_spec.rb +19 -0
  88. data/examples/zypper_package/spec/upgrade_spec.rb +19 -0
  89. data/features/attributes.feature +1 -1
  90. data/features/bff_package.feature +12 -0
  91. data/features/chocolatey_package.feature +1 -0
  92. data/features/compile_time.feature +1 -1
  93. data/features/dsc_resource.feature +1 -0
  94. data/features/homebrew_package.feature +12 -0
  95. data/features/launchd.feature +23 -0
  96. data/features/openbsd_package.feature +14 -0
  97. data/features/osx_profile.feature +19 -0
  98. data/features/paludis_package.feature +14 -0
  99. data/features/roles.feature +1 -1
  100. data/features/ruby_block.feature +1 -0
  101. data/features/script.feature +8 -0
  102. data/features/solaris_package.feature +1 -0
  103. data/features/systemd_unit.feature +33 -0
  104. data/features/windows_package.feature +1 -0
  105. data/features/zypper_package.feature +18 -0
  106. data/lib/chefspec/api.rb +8 -0
  107. data/lib/chefspec/api/bff_package.rb +154 -0
  108. data/lib/chefspec/api/homebrew_package.rb +154 -0
  109. data/lib/chefspec/api/launchd.rb +151 -0
  110. data/lib/chefspec/api/openbsd_package.rb +155 -0
  111. data/lib/chefspec/api/osx_profile.rb +63 -0
  112. data/lib/chefspec/api/paludis_package.rb +155 -0
  113. data/lib/chefspec/api/ruby_block.rb +31 -0
  114. data/lib/chefspec/api/script.rb +39 -0
  115. data/lib/chefspec/api/solaris_package.rb +37 -0
  116. data/lib/chefspec/api/systemd_unit.rb +353 -0
  117. data/lib/chefspec/api/zypper_package.rb +154 -0
  118. data/lib/chefspec/version.rb +1 -1
  119. metadata +111 -3
@@ -0,0 +1,14 @@
1
+ @not_chef_12_0_3
2
+
3
+ Feature: The paludis_package matcher
4
+ Background:
5
+ * I am using the "paludis_package" cookbook
6
+
7
+ Scenario Outline: Running specs
8
+ * I successfully run `rspec spec/<Matcher>_spec.rb`
9
+ * the output should contain "0 failures"
10
+ Examples:
11
+ | Matcher |
12
+ | install |
13
+ | purge |
14
+ | remove |
@@ -1,4 +1,4 @@
1
- Feature: Overridding roles in the Runner
1
+ Feature: Overriding roles in the Runner
2
2
  Background:
3
3
  * I am using the "roles" cookbook
4
4
 
@@ -8,3 +8,4 @@ Feature: The ruby_block matcher
8
8
  Examples:
9
9
  | Matcher |
10
10
  | run |
11
+ | create |
@@ -1,3 +1,10 @@
1
+ @not_chef_12_0_3
2
+ @not_chef_12_1_2
3
+ @not_chef_12_2_1
4
+ @not_chef_12_3_0
5
+ @not_chef_12_4_3
6
+ @not_chef_12_5_1
7
+
1
8
  Feature: The script matcher
2
9
  Background:
3
10
  * I am using the "script" cookbook
@@ -11,5 +18,6 @@ Feature: The script matcher
11
18
  | run_csh |
12
19
  | run_perl |
13
20
  | run_python |
21
+ | run_ksh |
14
22
  | run_ruby |
15
23
  | run_script |
@@ -9,3 +9,4 @@ Feature: The solaris_package matcher
9
9
  | Matcher |
10
10
  | install |
11
11
  | remove |
12
+ | upgrade |
@@ -0,0 +1,33 @@
1
+ @not_chef_12_0_3
2
+ @not_chef_12_1_2
3
+ @not_chef_12_2_1
4
+ @not_chef_12_3_0
5
+ @not_chef_12_4_3
6
+ @not_chef_12_5_1
7
+ @not_chef_12_6_0
8
+ @not_chef_12_7_2
9
+ @not_chef_12_8_1
10
+ @not_chef_12_9_41
11
+ @not_chef_12_10_24
12
+
13
+ Feature: The systemd_unit matcher
14
+ Background:
15
+ * I am using the "systemd_unit" cookbook
16
+
17
+ Scenario Outline: Running specs
18
+ * I successfully run `rspec spec/<Matcher>_spec.rb`
19
+ * the output should contain "0 failures"
20
+ Examples:
21
+ | Matcher |
22
+ | create |
23
+ | delete |
24
+ | enable |
25
+ | disable |
26
+ | mask |
27
+ | unmask |
28
+ | start |
29
+ | stop |
30
+ | restart |
31
+ | try_restart |
32
+ | reload_or_restart |
33
+ | reload_or_try_restart |
@@ -2,6 +2,7 @@
2
2
  @not_chef_12_1_2
3
3
  @not_chef_12_2_1
4
4
  @not_chef_12_3_0
5
+
5
6
  Feature: The windows_package matcher
6
7
  Background:
7
8
  * I am using the "windows_package" cookbook
@@ -0,0 +1,18 @@
1
+ @not_chef_12_0_3
2
+ @not_chef_12_1_2
3
+ @not_chef_12_2_1
4
+ @not_chef_12_3_0
5
+
6
+ Feature: The zypper_package matcher
7
+ Background:
8
+ * I am using the "zypper_package" cookbook
9
+
10
+ Scenario Outline: Running specs
11
+ * I successfully run `rspec spec/<Matcher>_spec.rb`
12
+ * the output should contain "0 failures"
13
+ Examples:
14
+ | Matcher |
15
+ | install |
16
+ | purge |
17
+ | remove |
18
+ | upgrade |
@@ -27,6 +27,7 @@ end
27
27
  require_relative 'api/apt_package'
28
28
  require_relative 'api/apt_update'
29
29
  require_relative 'api/apt_repository'
30
+ require_relative 'api/bff_package'
30
31
  require_relative 'api/batch'
31
32
  require_relative 'api/chef_gem'
32
33
  require_relative 'api/chocolatey_package'
@@ -47,10 +48,12 @@ require_relative 'api/freebsd_package'
47
48
  require_relative 'api/gem_package'
48
49
  require_relative 'api/git'
49
50
  require_relative 'api/group'
51
+ require_relative 'api/homebrew_package'
50
52
  require_relative 'api/http_request'
51
53
  require_relative 'api/ifconfig'
52
54
  require_relative 'api/include_recipe'
53
55
  require_relative 'api/ips_package'
56
+ require_relative 'api/launchd'
54
57
  require_relative 'api/link'
55
58
  require_relative 'api/log'
56
59
  require_relative 'api/macports_package'
@@ -58,8 +61,11 @@ require_relative 'api/mdadm'
58
61
  require_relative 'api/mount'
59
62
  require_relative 'api/notifications'
60
63
  require_relative 'api/ohai'
64
+ require_relative 'api/openbsd_package'
65
+ require_relative 'api/osx_profile'
61
66
  require_relative 'api/package'
62
67
  require_relative 'api/pacman_package'
68
+ require_relative 'api/paludis_package'
63
69
  require_relative 'api/portage_package'
64
70
  require_relative 'api/powershell_script'
65
71
  require_relative 'api/reboot'
@@ -77,9 +83,11 @@ require_relative 'api/solaris_package'
77
83
  require_relative 'api/state_attrs'
78
84
  require_relative 'api/subscriptions'
79
85
  require_relative 'api/subversion'
86
+ require_relative 'api/systemd_unit'
80
87
  require_relative 'api/template'
81
88
  require_relative 'api/user'
82
89
  require_relative 'api/windows_package'
83
90
  require_relative 'api/windows_service'
84
91
  require_relative 'api/yum_package'
85
92
  require_relative 'api/yum_repository'
93
+ require_relative 'api/zypper_package'
@@ -0,0 +1,154 @@
1
+ module ChefSpec::API
2
+ # @since 5.1.0
3
+ module BffPackageMatchers
4
+ ChefSpec.define_matcher :bff_package
5
+
6
+ #
7
+ # Assert that a +bff_package+ resource exists in the Chef run with the
8
+ # action +:install+. Given a Chef Recipe that installs "apache2" as a
9
+ # +bff_package+:
10
+ #
11
+ # bff_package 'apache2' do
12
+ # action :install
13
+ # end
14
+ #
15
+ # The Examples section demonstrates the different ways to test a
16
+ # +bff_package+ resource with ChefSpec.
17
+ #
18
+ # @example Assert that a +bff_package+ was installed
19
+ # expect(chef_run).to install_bff_package('apache2')
20
+ #
21
+ # @example Assert that a +bff_package+ was installed with predicate matchers
22
+ # expect(chef_run).to install_bff_package('apache2').with_version('1.2.3')
23
+ #
24
+ # @example Assert that a +bff_package+ was installed with attributes
25
+ # expect(chef_run).to install_bff_package('apache2').with(version: '1.2.3')
26
+ #
27
+ # @example Assert that a +bff_package+ was installed using a regex
28
+ # expect(chef_run).to install_bff_package('apache2').with(version: /(\d+\.){2}\.\d+/)
29
+ #
30
+ # @example Assert that a +bff_package+ was _not_ installed
31
+ # expect(chef_run).to_not install_bff_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_bff_package(resource_name)
40
+ ChefSpec::Matchers::ResourceMatcher.new(:bff_package, :install, resource_name)
41
+ end
42
+
43
+ #
44
+ # Assert that a +bff_package+ resource exists in the Chef run with the
45
+ # action +:purge+. Given a Chef Recipe that purges "apache2" as a
46
+ # +bff_package+:
47
+ #
48
+ # bff_package 'apache2' do
49
+ # action :purge
50
+ # end
51
+ #
52
+ # The Examples section demonstrates the different ways to test a
53
+ # +bff_package+ resource with ChefSpec.
54
+ #
55
+ # @example Assert that a +bff_package+ was purged
56
+ # expect(chef_run).to purge_bff_package('apache2')
57
+ #
58
+ # @example Assert that a +bff_package+ was purged with predicate matchers
59
+ # expect(chef_run).to purge_bff_package('apache2').with_version('1.2.3')
60
+ #
61
+ # @example Assert that a +bff_package+ was purged with attributes
62
+ # expect(chef_run).to purge_bff_package('apache2').with(version: '1.2.3')
63
+ #
64
+ # @example Assert that a +bff_package+ was purged using a regex
65
+ # expect(chef_run).to purge_bff_package('apache2').with(version: /(\d+\.){2}\.\d+/)
66
+ #
67
+ # @example Assert that a +bff_package+ was _not_ purged
68
+ # expect(chef_run).to_not purge_bff_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_bff_package(resource_name)
77
+ ChefSpec::Matchers::ResourceMatcher.new(:bff_package, :purge, resource_name)
78
+ end
79
+
80
+ #
81
+ # Assert that a +bff_package+ resource exists in the Chef run with the
82
+ # action +:remove+. Given a Chef Recipe that removes "apache2" as a
83
+ # +bff_package+:
84
+ #
85
+ # bff_package 'apache2' do
86
+ # action :remove
87
+ # end
88
+ #
89
+ # The Examples section demonstrates the different ways to test a
90
+ # +bff_package+ resource with ChefSpec.
91
+ #
92
+ # @example Assert that a +bff_package+ was removed
93
+ # expect(chef_run).to remove_bff_package('apache2')
94
+ #
95
+ # @example Assert that a +bff_package+ was removed with predicate matchers
96
+ # expect(chef_run).to remove_bff_package('apache2').with_version('1.2.3')
97
+ #
98
+ # @example Assert that a +bff_package+ was removed with attributes
99
+ # expect(chef_run).to remove_bff_package('apache2').with(version: '1.2.3')
100
+ #
101
+ # @example Assert that a +bff_package+ was removed using a regex
102
+ # expect(chef_run).to remove_bff_package('apache2').with(version: /(\d+\.){2}\.\d+/)
103
+ #
104
+ # @example Assert that a +bff_package+ was _not_ removed
105
+ # expect(chef_run).to_not remove_bff_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_bff_package(resource_name)
114
+ ChefSpec::Matchers::ResourceMatcher.new(:bff_package, :remove, resource_name)
115
+ end
116
+
117
+ #
118
+ # Assert that a +bff_package+ resource exists in the Chef run with the
119
+ # action +:upgrade+. Given a Chef Recipe that upgrades "apache2" as a
120
+ # +bff_package+:
121
+ #
122
+ # bff_package 'apache2' do
123
+ # action :upgrade
124
+ # end
125
+ #
126
+ # The Examples section demonstrates the different ways to test a
127
+ # +bff_package+ resource with ChefSpec.
128
+ #
129
+ # @example Assert that a +bff_package+ was upgraded
130
+ # expect(chef_run).to upgrade_bff_package('apache2')
131
+ #
132
+ # @example Assert that a +bff_package+ was upgraded with predicate matchers
133
+ # expect(chef_run).to upgrade_bff_package('apache2').with_version('1.2.3')
134
+ #
135
+ # @example Assert that a +bff_package+ was upgraded with attributes
136
+ # expect(chef_run).to upgrade_bff_package('apache2').with(version: '1.2.3')
137
+ #
138
+ # @example Assert that a +bff_package+ was upgraded using a regex
139
+ # expect(chef_run).to upgrade_bff_package('apache2').with(version: /(\d+\.){2}\.\d+/)
140
+ #
141
+ # @example Assert that a +bff_package+ was _not_ upgraded
142
+ # expect(chef_run).to_not upgrade_bff_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 upgrade_bff_package(resource_name)
151
+ ChefSpec::Matchers::ResourceMatcher.new(:bff_package, :upgrade, resource_name)
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,154 @@
1
+ module ChefSpec::API
2
+ # @since 5.1.0
3
+ module HomebrewPackageMatchers
4
+ ChefSpec.define_matcher :homebrew_package
5
+
6
+ #
7
+ # Assert that a +homebrew_package+ resource exists in the Chef run with the
8
+ # action +:install+. Given a Chef Recipe that installs "community-zero" as a
9
+ # +homebrew_package+:
10
+ #
11
+ # homebrew_package 'community-zero' do
12
+ # action :install
13
+ # end
14
+ #
15
+ # The Examples section demonstrates the different ways to test a
16
+ # +homebrew_package+ resource with ChefSpec.
17
+ #
18
+ # @example Assert that a +homebrew_package+ was installed
19
+ # expect(chef_run).to install_homebrew_package('community-zero')
20
+ #
21
+ # @example Assert that a +homebrew_package+ was installed with predicate matchers
22
+ # expect(chef_run).to install_homebrew_package('community-zero').with_version('1.2.3')
23
+ #
24
+ # @example Assert that a +homebrew_package+ was installed with attributes
25
+ # expect(chef_run).to install_homebrew_package('community-zero').with(version: '1.2.3')
26
+ #
27
+ # @example Assert that a +homebrew_package+ was installed using a regex
28
+ # expect(chef_run).to install_homebrew_package('community-zero').with(version: /(\d+\.){2}\.\d+/)
29
+ #
30
+ # @example Assert that a +homebrew_package+ was _not_ installed
31
+ # expect(chef_run).to_not install_homebrew_package('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_homebrew_package(resource_name)
40
+ ChefSpec::Matchers::ResourceMatcher.new(:homebrew_package, :install, resource_name)
41
+ end
42
+
43
+ #
44
+ # Assert that a +homebrew_package+ resource exists in the Chef run with the
45
+ # action +:purge+. Given a Chef Recipe that purges "community-zero" as a
46
+ # +homebrew_package+:
47
+ #
48
+ # homebrew_package 'community-zero' do
49
+ # action :purge
50
+ # end
51
+ #
52
+ # The Examples section demonstrates the different ways to test a
53
+ # +homebrew_package+ resource with ChefSpec.
54
+ #
55
+ # @example Assert that a +homebrew_package+ was purgeed
56
+ # expect(chef_run).to purge_homebrew_package('community-zero')
57
+ #
58
+ # @example Assert that a +homebrew_package+ was purgeed with predicate matchers
59
+ # expect(chef_run).to purge_homebrew_package('community-zero').with_version('1.2.3')
60
+ #
61
+ # @example Assert that a +homebrew_package+ was purgeed with attributes
62
+ # expect(chef_run).to purge_homebrew_package('community-zero').with(version: '1.2.3')
63
+ #
64
+ # @example Assert that a +homebrew_package+ was purgeed using a regex
65
+ # expect(chef_run).to purge_homebrew_package('community-zero').with(version: /(\d+\.){2}\.\d+/)
66
+ #
67
+ # @example Assert that a +homebrew_package+ was _not_ purgeed
68
+ # expect(chef_run).to_not purge_homebrew_package('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_homebrew_package(resource_name)
77
+ ChefSpec::Matchers::ResourceMatcher.new(:homebrew_package, :purge, resource_name)
78
+ end
79
+
80
+ #
81
+ # Assert that a +homebrew_package+ resource exists in the Chef run with the
82
+ # action +:remove+. Given a Chef Recipe that removes "community-zero" as a
83
+ # +homebrew_package+:
84
+ #
85
+ # homebrew_package 'community-zero' do
86
+ # action :remove
87
+ # end
88
+ #
89
+ # The Examples section demonstrates the different ways to test a
90
+ # +homebrew_package+ resource with ChefSpec.
91
+ #
92
+ # @example Assert that a +homebrew_package+ was removeed
93
+ # expect(chef_run).to remove_homebrew_package('community-zero')
94
+ #
95
+ # @example Assert that a +homebrew_package+ was removeed with predicate matchers
96
+ # expect(chef_run).to remove_homebrew_package('community-zero').with_version('1.2.3')
97
+ #
98
+ # @example Assert that a +homebrew_package+ was removeed with attributes
99
+ # expect(chef_run).to remove_homebrew_package('community-zero').with(version: '1.2.3')
100
+ #
101
+ # @example Assert that a +homebrew_package+ was removeed using a regex
102
+ # expect(chef_run).to remove_homebrew_package('community-zero').with(version: /(\d+\.){2}\.\d+/)
103
+ #
104
+ # @example Assert that a +homebrew_package+ was _not_ removeed
105
+ # expect(chef_run).to_not remove_homebrew_package('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 remove_homebrew_package(resource_name)
114
+ ChefSpec::Matchers::ResourceMatcher.new(:homebrew_package, :remove, resource_name)
115
+ end
116
+
117
+ #
118
+ # Assert that a +homebrew_package+ resource exists in the Chef run with the
119
+ # action +:upgrade+. Given a Chef Recipe that upgrades "community-zero" as a
120
+ # +homebrew_package+:
121
+ #
122
+ # homebrew_package 'community-zero' do
123
+ # action :upgrade
124
+ # end
125
+ #
126
+ # The Examples section demonstrates the different ways to test a
127
+ # +homebrew_package+ resource with ChefSpec.
128
+ #
129
+ # @example Assert that a +homebrew_package+ was upgradeed
130
+ # expect(chef_run).to upgrade_homebrew_package('community-zero')
131
+ #
132
+ # @example Assert that a +homebrew_package+ was upgradeed with predicate matchers
133
+ # expect(chef_run).to upgrade_homebrew_package('community-zero').with_version('1.2.3')
134
+ #
135
+ # @example Assert that a +homebrew_package+ was upgradeed with attributes
136
+ # expect(chef_run).to upgrade_homebrew_package('community-zero').with(version: '1.2.3')
137
+ #
138
+ # @example Assert that a +homebrew_package+ was upgradeed using a regex
139
+ # expect(chef_run).to upgrade_homebrew_package('community-zero').with(version: /(\d+\.){2}\.\d+/)
140
+ #
141
+ # @example Assert that a +homebrew_package+ was _not_ upgradeed
142
+ # expect(chef_run).to_not upgrade_homebrew_package('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 upgrade_homebrew_package(resource_name)
151
+ ChefSpec::Matchers::ResourceMatcher.new(:homebrew_package, :upgrade, resource_name)
152
+ end
153
+ end
154
+ end