chefspec 5.4.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +6 -2
- data/CHANGELOG.md +12 -1
- data/README.md +17 -3
- data/chefspec.gemspec +2 -3
- data/examples/apt_package/spec/install_spec.rb +1 -1
- data/examples/apt_package/spec/purge_spec.rb +1 -1
- data/examples/apt_package/spec/reconfig_spec.rb +1 -1
- data/examples/apt_package/spec/remove_spec.rb +1 -1
- data/examples/apt_package/spec/upgrade_spec.rb +1 -1
- data/examples/apt_repository/spec/add_spec.rb +1 -1
- data/examples/apt_repository/spec/remove_spec.rb +1 -1
- data/examples/apt_update/spec/periodic_spec.rb +1 -1
- data/examples/apt_update/spec/update_spec.rb +1 -1
- data/examples/batch/spec/run_spec.rb +1 -1
- data/examples/cab_package/recipes/install.rb +13 -0
- data/examples/cab_package/recipes/remove.rb +13 -0
- data/examples/cab_package/spec/install_spec.rb +26 -0
- data/examples/cab_package/spec/remove_spec.rb +22 -0
- data/examples/chocolatey_package/spec/install_spec.rb +1 -1
- data/examples/chocolatey_package/spec/remove_spec.rb +1 -1
- data/examples/chocolatey_package/spec/upgrade_spec.rb +1 -1
- data/examples/dnf_package/recipes/install.rb +13 -0
- data/examples/dnf_package/recipes/purge.rb +13 -0
- data/examples/dnf_package/recipes/remove.rb +13 -0
- data/examples/dnf_package/recipes/upgrade.rb +13 -0
- data/examples/dnf_package/spec/install_spec.rb +26 -0
- data/examples/dnf_package/spec/purge_spec.rb +22 -0
- data/examples/dnf_package/spec/remove_spec.rb +22 -0
- data/examples/dnf_package/spec/upgrade_spec.rb +22 -0
- data/examples/dpkg_package/spec/install_spec.rb +1 -1
- data/examples/dpkg_package/spec/purge_spec.rb +1 -1
- data/examples/dpkg_package/spec/remove_spec.rb +1 -1
- data/examples/dsc_resource/spec/run_spec.rb +4 -4
- data/examples/dsc_script/spec/run_spec.rb +1 -1
- data/examples/env/spec/create_spec.rb +1 -1
- data/examples/env/spec/delete_spec.rb +1 -1
- data/examples/env/spec/modify_spec.rb +1 -1
- data/examples/freebsd_package/spec/install_spec.rb +1 -1
- data/examples/freebsd_package/spec/remove_spec.rb +1 -1
- data/examples/ips_package/spec/install_spec.rb +1 -1
- data/examples/ips_package/spec/remove_spec.rb +1 -1
- data/examples/ips_package/spec/upgrade_spec.rb +1 -1
- data/examples/msu_package/recipes/install.rb +13 -0
- data/examples/msu_package/recipes/remove.rb +13 -0
- data/examples/msu_package/spec/install_spec.rb +26 -0
- data/examples/msu_package/spec/remove_spec.rb +22 -0
- data/examples/pacman_package/spec/install_spec.rb +1 -1
- data/examples/pacman_package/spec/purge_spec.rb +1 -1
- data/examples/pacman_package/spec/remove_spec.rb +1 -1
- data/examples/pacman_package/spec/upgrade_spec.rb +1 -1
- data/examples/portage_package/spec/install_spec.rb +1 -1
- data/examples/portage_package/spec/purge_spec.rb +1 -1
- data/examples/portage_package/spec/remove_spec.rb +1 -1
- data/examples/portage_package/spec/upgrade_spec.rb +1 -1
- data/examples/powershell_script/spec/run_spec.rb +1 -1
- data/examples/registry_key/spec/create_if_missing_spec.rb +1 -1
- data/examples/registry_key/spec/create_spec.rb +1 -1
- data/examples/registry_key/spec/delete_key_spec.rb +1 -1
- data/examples/registry_key/spec/delete_spec.rb +1 -1
- data/examples/roles/roles/role.rb +2 -2
- data/examples/rpm_package/spec/install_spec.rb +1 -1
- data/examples/rpm_package/spec/remove_spec.rb +1 -1
- data/examples/rpm_package/spec/upgrade_spec.rb +1 -1
- data/examples/server/spec/data_bag_spec.rb +9 -11
- data/examples/smartos_package/spec/install_spec.rb +1 -1
- data/examples/smartos_package/spec/remove_spec.rb +1 -1
- data/examples/smartos_package/spec/upgrade_spec.rb +1 -1
- data/examples/solaris_package/spec/install_spec.rb +1 -1
- data/examples/solaris_package/spec/remove_spec.rb +1 -1
- data/examples/step_into/spec/default_spec.rb +2 -2
- data/examples/use_inline_resources/spec/default_spec.rb +1 -1
- data/examples/windows_package/spec/install_spec.rb +1 -1
- data/examples/windows_package/spec/remove_spec.rb +1 -1
- data/examples/windows_service/spec/configure_startup_spec.rb +1 -1
- data/examples/windows_service/spec/disable_spec.rb +1 -1
- data/examples/windows_service/spec/enable_spec.rb +1 -1
- data/examples/windows_service/spec/reload_spec.rb +1 -1
- data/examples/windows_service/spec/restart_spec.rb +1 -1
- data/examples/windows_service/spec/start_spec.rb +1 -1
- data/examples/windows_service/spec/stop_spec.rb +1 -1
- data/examples/yum_package/spec/install_spec.rb +1 -1
- data/examples/yum_package/spec/purge_spec.rb +1 -1
- data/examples/yum_package/spec/remove_spec.rb +1 -1
- data/examples/yum_package/spec/upgrade_spec.rb +1 -1
- data/examples/yum_repository/spec/add_spec.rb +1 -1
- data/examples/yum_repository/spec/create_spec.rb +1 -1
- data/examples/yum_repository/spec/delete_spec.rb +1 -1
- data/examples/yum_repository/spec/makecache_spec.rb +1 -1
- data/examples/yum_repository/spec/remove_spec.rb +1 -1
- data/features/cab_package.feature +21 -0
- data/features/dnf_package.feature +26 -0
- data/features/msu_package.feature +23 -0
- data/features/support/env.rb +8 -0
- data/lib/chefspec.rb +0 -1
- data/lib/chefspec/api.rb +3 -0
- data/lib/chefspec/api/cab_package.rb +80 -0
- data/lib/chefspec/api/dnf_package.rb +154 -0
- data/lib/chefspec/api/msu_package.rb +81 -0
- data/lib/chefspec/rspec.rb +1 -0
- data/lib/chefspec/server_methods.rb +4 -35
- data/lib/chefspec/server_runner.rb +2 -42
- data/lib/chefspec/version.rb +1 -1
- data/lib/chefspec/zero_server.rb +139 -0
- metadata +31 -6
- data/lib/chefspec/chef_backwards_compat.rb +0 -79
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'smartos_package::install' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'smartos', version: '5.11')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'installs a smartos_package with the default action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'smartos_package::remove' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'smartos', version: '5.11')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'removes a smartos_package with an explicit action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'smartos_package::upgrade' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'smartos', version: '5.11')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'upgrades a smartos_package with an explicit action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'solaris_package::install' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'solaris2', version: '5.11')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'installs a solaris_package with the default action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'solaris_package::remove' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'solaris2', version: '5.11')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'removes a solaris_package with an explicit action' do
|
|
@@ -15,8 +15,8 @@ describe 'step_into::default' do
|
|
|
15
15
|
|
|
16
16
|
context 'with :step_into' do
|
|
17
17
|
let(:chef_run) do
|
|
18
|
-
ChefSpec::ServerRunner.new(step_into: %w(step_into_lwrp provides_this))
|
|
19
|
-
|
|
18
|
+
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04', step_into: %w(step_into_lwrp provides_this))
|
|
19
|
+
.converge(described_recipe)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it 'executes the LWRPs action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'use_inline_resources::default' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04', step_into: ['use_inline_resources_lwrp'])
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'uses the LWRP' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'windows_package::install' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'installs a windows_package with an explicit action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'windows_package::remove' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'removes a windows_package with an explicit action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'windows_service::configure_startup' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'configures startup for a windows_service with an explicit action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'windows_service::disable' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'disables a windows_service with an explicit action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'windows_service::enable' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'enables a windows_service with an explicit action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'windows_service::reload' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'reloads a windows_service with an explicit action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'windows_service::restart' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'restarts a windows_service with an explicit action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'windows_service::start' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'starts a windows_service with an explicit action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'windows_service::stop' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'stops a windows_service with an explicit action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'yum_package::install' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'centos', version: '7.2.1511')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'installs a yum_package with the default action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'yum_package::remove' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'centos', version: '7.2.1511')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'removes a yum_package with an explicit action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'yum_package::upgrade' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'centos', version: '7.2.1511')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'upgrades a yum_package with an explicit action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'yum_repository::create' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'centos', version: '7.2.1511')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'create a yum_repository with default action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'yum_repository::delete' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'centos', version: '7.2.1511')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'removes a yum_repository with delete action' do
|
|
@@ -3,7 +3,7 @@ require 'chefspec'
|
|
|
3
3
|
describe 'yum_repository::remove' do
|
|
4
4
|
let(:chef_run) do
|
|
5
5
|
ChefSpec::ServerRunner.new(platform: 'centos', version: '7.2.1511')
|
|
6
|
-
|
|
6
|
+
.converge(described_recipe)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it 'removes a yum_repository with remove action' do
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
@not_chef_12_6_0
|
|
2
|
+
@not_chef_12_7_2
|
|
3
|
+
@not_chef_12_8_1
|
|
4
|
+
@not_chef_12_9_41
|
|
5
|
+
@not_chef_12_10_24
|
|
6
|
+
@not_chef_12_11_18
|
|
7
|
+
@not_chef_12_12_15
|
|
8
|
+
@not_chef_12_13_37
|
|
9
|
+
@not_chef_12_14_89
|
|
10
|
+
|
|
11
|
+
Feature: The cab_package matcher
|
|
12
|
+
Background:
|
|
13
|
+
* I am using the "cab_package" cookbook
|
|
14
|
+
|
|
15
|
+
Scenario Outline: Running specs
|
|
16
|
+
* I successfully run `rspec spec/<Matcher>_spec.rb`
|
|
17
|
+
* the output should contain "0 failures"
|
|
18
|
+
Examples:
|
|
19
|
+
| Matcher |
|
|
20
|
+
| install |
|
|
21
|
+
| remove |
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
@not_chef_12_6_0
|
|
2
|
+
@not_chef_12_7_2
|
|
3
|
+
@not_chef_12_8_1
|
|
4
|
+
@not_chef_12_9_41
|
|
5
|
+
@not_chef_12_10_24
|
|
6
|
+
@not_chef_12_11_18
|
|
7
|
+
@not_chef_12_12_15
|
|
8
|
+
@not_chef_12_13_37
|
|
9
|
+
@not_chef_12_14_89
|
|
10
|
+
@not_chef_12_15_19
|
|
11
|
+
@not_chef_12_16_42
|
|
12
|
+
@not_chef_12_17_44
|
|
13
|
+
|
|
14
|
+
Feature: The dnf_package matcher
|
|
15
|
+
Background:
|
|
16
|
+
* I am using the "dnf_package" cookbook
|
|
17
|
+
|
|
18
|
+
Scenario Outline: Running specs
|
|
19
|
+
* I successfully run `rspec spec/<Matcher>_spec.rb`
|
|
20
|
+
* the output should contain "0 failures"
|
|
21
|
+
Examples:
|
|
22
|
+
| Matcher |
|
|
23
|
+
| install |
|
|
24
|
+
| purge |
|
|
25
|
+
| remove |
|
|
26
|
+
| upgrade |
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@not_chef_12_6_0
|
|
2
|
+
@not_chef_12_7_2
|
|
3
|
+
@not_chef_12_8_1
|
|
4
|
+
@not_chef_12_9_41
|
|
5
|
+
@not_chef_12_10_24
|
|
6
|
+
@not_chef_12_11_18
|
|
7
|
+
@not_chef_12_12_15
|
|
8
|
+
@not_chef_12_13_37
|
|
9
|
+
@not_chef_12_14_89
|
|
10
|
+
@not_chef_12_15_19
|
|
11
|
+
@not_chef_12_16_42
|
|
12
|
+
|
|
13
|
+
Feature: The msu_package matcher
|
|
14
|
+
Background:
|
|
15
|
+
* I am using the "msu_package" 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
|
+
| install |
|
|
23
|
+
| remove |
|
data/features/support/env.rb
CHANGED
|
@@ -20,6 +20,14 @@ Before do
|
|
|
20
20
|
# RSpec::Runner) removes our configurations :(
|
|
21
21
|
load 'lib/chefspec/rspec.rb'
|
|
22
22
|
|
|
23
|
+
# These settings need to be specified manually here rather than in rspec.rb
|
|
24
|
+
# because we do not want the zero-server terminating between each run. The
|
|
25
|
+
# runs happen too quickly in succession the port doesn't have time to get reset.
|
|
26
|
+
RSpec.configure do |config|
|
|
27
|
+
config.before(:suite) { ChefSpec::ZeroServer.setup! }
|
|
28
|
+
config.after(:each) { ChefSpec::ZeroServer.reset! }
|
|
29
|
+
end
|
|
30
|
+
|
|
23
31
|
# Use a temporary directory to suppress Travis warnings
|
|
24
32
|
@dirs = [Dir.mktmpdir]
|
|
25
33
|
end
|
data/lib/chefspec.rb
CHANGED
data/lib/chefspec/api.rb
CHANGED
|
@@ -29,12 +29,14 @@ require_relative 'api/apt_update'
|
|
|
29
29
|
require_relative 'api/apt_repository'
|
|
30
30
|
require_relative 'api/bff_package'
|
|
31
31
|
require_relative 'api/batch'
|
|
32
|
+
require_relative 'api/cab_package'
|
|
32
33
|
require_relative 'api/chef_gem'
|
|
33
34
|
require_relative 'api/chocolatey_package'
|
|
34
35
|
require_relative 'api/cookbook_file'
|
|
35
36
|
require_relative 'api/cron'
|
|
36
37
|
require_relative 'api/deploy'
|
|
37
38
|
require_relative 'api/directory'
|
|
39
|
+
require_relative 'api/dnf_package'
|
|
38
40
|
require_relative 'api/dpkg_package'
|
|
39
41
|
require_relative 'api/do_nothing'
|
|
40
42
|
require_relative 'api/dsc_resource'
|
|
@@ -59,6 +61,7 @@ require_relative 'api/log'
|
|
|
59
61
|
require_relative 'api/macports_package'
|
|
60
62
|
require_relative 'api/mdadm'
|
|
61
63
|
require_relative 'api/mount'
|
|
64
|
+
require_relative 'api/msu_package'
|
|
62
65
|
require_relative 'api/notifications'
|
|
63
66
|
require_relative 'api/ohai'
|
|
64
67
|
require_relative 'api/openbsd_package'
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
module ChefSpec::API
|
|
2
|
+
# @since 6.0.0
|
|
3
|
+
module CabPackageMatchers
|
|
4
|
+
ChefSpec.define_matcher :cab_package
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
# Assert that a +cab_package+ resource exists in the Chef run with the
|
|
8
|
+
# action +:install+. Given a Chef Recipe that installs "apache2" as a
|
|
9
|
+
# +cab_package+:
|
|
10
|
+
#
|
|
11
|
+
# cab_package 'apache2' do
|
|
12
|
+
# action :install
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# The Examples section demonstrates the different ways to test a
|
|
16
|
+
# +cab_package+ resource with ChefSpec.
|
|
17
|
+
#
|
|
18
|
+
# @example Assert that a +cab_package+ was installed
|
|
19
|
+
# expect(chef_run).to install_cab_package('apache2')
|
|
20
|
+
#
|
|
21
|
+
# @example Assert that a +cab_package+ was installed with predicate matchers
|
|
22
|
+
# expect(chef_run).to install_cab_package('apache2').with_version('1.2.3')
|
|
23
|
+
#
|
|
24
|
+
# @example Assert that a +cab_package+ was installed with attributes
|
|
25
|
+
# expect(chef_run).to install_cab_package('apache2').with(version: '1.2.3')
|
|
26
|
+
#
|
|
27
|
+
# @example Assert that a +cab_package+ was installed using a regex
|
|
28
|
+
# expect(chef_run).to install_cab_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
|
29
|
+
#
|
|
30
|
+
# @example Assert that a +cab_package+ was _not_ installed
|
|
31
|
+
# expect(chef_run).to_not install_cab_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_cab_package(resource_name)
|
|
40
|
+
ChefSpec::Matchers::ResourceMatcher.new(:cab_package, :install, resource_name)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# Assert that a +cab_package+ resource exists in the Chef run with the
|
|
45
|
+
# action +:remove+. Given a Chef Recipe that removes "apache2" as a
|
|
46
|
+
# +cab_package+:
|
|
47
|
+
#
|
|
48
|
+
# cab_package 'apache2' do
|
|
49
|
+
# action :remove
|
|
50
|
+
# end
|
|
51
|
+
#
|
|
52
|
+
# The Examples section demonstrates the different ways to test a
|
|
53
|
+
# +cab_package+ resource with ChefSpec.
|
|
54
|
+
#
|
|
55
|
+
# @example Assert that a +cab_package+ was removed
|
|
56
|
+
# expect(chef_run).to remove_cab_package('apache2')
|
|
57
|
+
#
|
|
58
|
+
# @example Assert that a +cab_package+ was removed with predicate matchers
|
|
59
|
+
# expect(chef_run).to remove_cab_package('apache2').with_version('1.2.3')
|
|
60
|
+
#
|
|
61
|
+
# @example Assert that a +cab_package+ was removed with attributes
|
|
62
|
+
# expect(chef_run).to remove_cab_package('apache2').with(version: '1.2.3')
|
|
63
|
+
#
|
|
64
|
+
# @example Assert that a +cab_package+ was removed using a regex
|
|
65
|
+
# expect(chef_run).to remove_cab_package('apache2').with(version: /(\d+\.){2}\.\d+/)
|
|
66
|
+
#
|
|
67
|
+
# @example Assert that a +cab_package+ was _not_ removed
|
|
68
|
+
# expect(chef_run).to_not remove_cab_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_cab_package(resource_name)
|
|
77
|
+
ChefSpec::Matchers::ResourceMatcher.new(:cab_package, :remove, resource_name)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|