chefspec 4.2.0 → 4.7.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/.gitignore +1 -0
- data/.travis.yml +39 -16
- data/CHANGELOG.md +136 -72
- data/README.md +187 -13
- data/chefspec.gemspec +5 -5
- data/examples/batch/spec/run_spec.rb +5 -0
- data/examples/chef_gem/recipes/install.rb +8 -3
- data/examples/chef_gem/recipes/purge.rb +6 -3
- data/examples/chef_gem/recipes/reconfig.rb +6 -3
- data/examples/chef_gem/recipes/remove.rb +6 -3
- data/examples/chef_gem/recipes/upgrade.rb +6 -3
- data/examples/chocolatey_package/recipes/install.rb +6 -0
- data/examples/chocolatey_package/recipes/remove.rb +8 -0
- data/examples/chocolatey_package/recipes/upgrade.rb +8 -0
- data/examples/chocolatey_package/spec/install_spec.rb +21 -0
- data/examples/chocolatey_package/spec/remove_spec.rb +20 -0
- data/examples/chocolatey_package/spec/upgrade_spec.rb +20 -0
- data/examples/directory/recipes/create.rb +4 -0
- data/examples/directory/spec/create_spec.rb +4 -0
- data/examples/dpkg_package/spec/install_spec.rb +5 -0
- data/examples/dpkg_package/spec/purge_spec.rb +5 -0
- data/examples/dpkg_package/spec/remove_spec.rb +5 -0
- data/examples/dsc_resource/recipes/default.rb +20 -0
- data/examples/dsc_resource/spec/default_spec.rb +40 -0
- data/examples/env/spec/create_spec.rb +5 -0
- data/examples/env/spec/delete_spec.rb +5 -0
- data/examples/env/spec/modify_spec.rb +5 -0
- data/examples/ips_package/spec/install_spec.rb +5 -0
- data/examples/ips_package/spec/remove_spec.rb +5 -0
- data/examples/ips_package/spec/upgrade_spec.rb +5 -0
- data/examples/package/recipes/install.rb +4 -0
- data/examples/package/recipes/purge.rb +4 -0
- data/examples/package/recipes/reconfig.rb +4 -0
- data/examples/package/recipes/remove.rb +4 -0
- data/examples/package/recipes/upgrade.rb +4 -0
- data/examples/package/spec/install_spec.rb +4 -0
- data/examples/package/spec/purge_spec.rb +4 -0
- data/examples/package/spec/reconfig_spec.rb +4 -0
- data/examples/package/spec/remove_spec.rb +4 -0
- data/examples/package/spec/upgrade_spec.rb +4 -0
- data/examples/pacman_package/spec/install_spec.rb +5 -0
- data/examples/pacman_package/spec/purge_spec.rb +5 -0
- data/examples/pacman_package/spec/remove_spec.rb +5 -0
- data/examples/pacman_package/spec/upgrade_spec.rb +5 -0
- data/examples/powershell_script/spec/run_spec.rb +5 -0
- data/examples/reboot/recipes/cancel.rb +3 -0
- data/examples/reboot/recipes/now.rb +3 -0
- data/examples/reboot/recipes/request.rb +3 -0
- data/examples/reboot/spec/cancel_spec.rb +10 -0
- data/examples/reboot/spec/now_spec.rb +10 -0
- data/examples/reboot/spec/request_spec.rb +10 -0
- data/examples/render_file/spec/default_spec.rb +40 -0
- data/examples/rpm_package/spec/install_spec.rb +5 -0
- data/examples/rpm_package/spec/remove_spec.rb +5 -0
- data/examples/rpm_package/spec/upgrade_spec.rb +5 -0
- data/examples/server/spec/node_spec.rb +1 -1
- data/examples/server/spec/search_spec.rb +4 -0
- data/examples/step_into/providers/provides.rb +3 -0
- data/examples/step_into/recipes/default.rb +2 -0
- data/examples/step_into/resources/lwrp.rb +1 -1
- data/examples/step_into/resources/provides.rb +6 -0
- data/examples/step_into/spec/default_spec.rb +10 -2
- data/examples/windows_package/recipes/install.rb +13 -0
- data/examples/windows_package/recipes/remove.rb +13 -0
- data/examples/windows_package/spec/install_spec.rb +24 -0
- data/examples/windows_package/spec/remove_spec.rb +24 -0
- data/examples/windows_service/recipes/configure_startup.rb +13 -0
- data/examples/windows_service/recipes/disable.rb +13 -0
- data/examples/windows_service/recipes/enable.rb +13 -0
- data/examples/windows_service/recipes/reload.rb +13 -0
- data/examples/windows_service/recipes/restart.rb +13 -0
- data/examples/windows_service/recipes/start.rb +13 -0
- data/examples/windows_service/recipes/stop.rb +13 -0
- data/examples/windows_service/spec/configure_startup_spec.rb +24 -0
- data/examples/windows_service/spec/disable_spec.rb +24 -0
- data/examples/windows_service/spec/enable_spec.rb +24 -0
- data/examples/windows_service/spec/reload_spec.rb +24 -0
- data/examples/windows_service/spec/restart_spec.rb +24 -0
- data/examples/windows_service/spec/start_spec.rb +24 -0
- data/examples/windows_service/spec/stop_spec.rb +24 -0
- data/features/chocolatey_package.feature +29 -0
- data/features/dsc_resource.feature +18 -0
- data/features/reboot.feature +19 -0
- data/features/step_definitions/background_steps.rb +4 -1
- data/features/step_into.feature +7 -0
- data/features/support/env.rb +5 -4
- data/features/windows_package.feature +24 -0
- data/features/windows_service.feature +23 -0
- data/gemfiles/chefspec.gemfile +9 -0
- data/lib/chefspec/api/chocolatey_package.rb +107 -0
- data/lib/chefspec/api/directory.rb +10 -10
- data/lib/chefspec/api/dsc_resource.rb +49 -0
- data/lib/chefspec/api/group.rb +5 -5
- data/lib/chefspec/api/link.rb +10 -10
- data/lib/chefspec/api/mdadm.rb +5 -5
- data/lib/chefspec/api/reboot.rb +18 -0
- data/lib/chefspec/api/remote_directory.rb +10 -10
- data/lib/chefspec/api/route.rb +5 -5
- data/lib/chefspec/api/user.rb +5 -5
- data/lib/chefspec/api/windows_package.rb +86 -0
- data/lib/chefspec/api/windows_service.rb +286 -0
- data/lib/chefspec/api.rb +5 -0
- data/lib/chefspec/berkshelf.rb +7 -1
- data/lib/chefspec/coverage/filters.rb +2 -1
- data/lib/chefspec/coverage.rb +1 -1
- data/lib/chefspec/deprecations.rb +6 -2
- data/lib/chefspec/errors.rb +4 -0
- data/lib/chefspec/extensions/chef/lwrp_base.rb +23 -0
- data/lib/chefspec/file_cache_path_proxy.rb +15 -0
- data/lib/chefspec/matchers/render_file_matcher.rb +20 -2
- data/lib/chefspec/matchers/resource_matcher.rb +9 -2
- data/lib/chefspec/mixins/normalize.rb +7 -1
- data/lib/chefspec/policyfile.rb +62 -0
- data/lib/chefspec/renderer.rb +2 -4
- data/lib/chefspec/rspec.rb +3 -0
- data/lib/chefspec/server_methods.rb +1 -0
- data/lib/chefspec/server_runner.rb +9 -0
- data/lib/chefspec/solo_runner.rb +13 -3
- data/lib/chefspec/version.rb +1 -1
- data/lib/chefspec.rb +1 -1
- data/spec/unit/coverage/filters_spec.rb +60 -0
- data/spec/unit/deprecations_spec.rb +3 -1
- data/spec/unit/macros_spec.rb +1 -1
- data/spec/unit/matchers/render_file_matcher_spec.rb +11 -0
- data/spec/unit/renderer_spec.rb +20 -2
- data/spec/unit/server_runner_spec.rb +28 -0
- data/spec/unit/solo_runner_spec.rb +3 -1
- data/templates/errors/invalid_berkshelf_options.erb +4 -0
- data/templates/errors/may_need_to_specify_platform.erb +25 -0
- metadata +72 -18
- data/gemfiles/chef-11.14.0.gemfile +0 -5
- data/gemfiles/chef-11.16.0.gemfile +0 -5
- data/gemfiles/chef-12.0.0.gemfile +0 -5
- data/gemfiles/chef-master.gemfile +0 -5
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'chefspec'
|
|
2
|
+
|
|
3
|
+
RSpec.configure do |config|
|
|
4
|
+
config.platform = 'windows'
|
|
5
|
+
config.version = '2012R2'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe 'windows_service::configure_startup' do
|
|
9
|
+
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
|
|
10
|
+
|
|
11
|
+
it 'configures startup for a windows_service with an explicit action' do
|
|
12
|
+
expect(chef_run).to configure_startup_windows_service('explicit_action')
|
|
13
|
+
expect(chef_run).to_not configure_startup_windows_service('not_explicit_action')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'configures startup for a windows_service with attributes' do
|
|
17
|
+
expect(chef_run).to configure_startup_windows_service('with_attributes').with(pattern: 'pattern')
|
|
18
|
+
expect(chef_run).to_not configure_startup_windows_service('with_attributes').with(pattern: 'bacon')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'configures startup for a windows_service when specifying the identity attribute' do
|
|
22
|
+
expect(chef_run).to configure_startup_windows_service('identity_attribute')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'chefspec'
|
|
2
|
+
|
|
3
|
+
RSpec.configure do |config|
|
|
4
|
+
config.platform = 'windows'
|
|
5
|
+
config.version = '2012R2'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe 'windows_service::disable' do
|
|
9
|
+
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
|
|
10
|
+
|
|
11
|
+
it 'disables a windows_service with an explicit action' do
|
|
12
|
+
expect(chef_run).to disable_windows_service('explicit_action')
|
|
13
|
+
expect(chef_run).to_not disable_windows_service('not_explicit_action')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'disables a windows_service with attributes' do
|
|
17
|
+
expect(chef_run).to disable_windows_service('with_attributes').with(pattern: 'pattern')
|
|
18
|
+
expect(chef_run).to_not disable_windows_service('with_attributes').with(pattern: 'bacon')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'disables a windows_service when specifying the identity attribute' do
|
|
22
|
+
expect(chef_run).to disable_windows_service('identity_attribute')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'chefspec'
|
|
2
|
+
|
|
3
|
+
RSpec.configure do |config|
|
|
4
|
+
config.platform = 'windows'
|
|
5
|
+
config.version = '2012R2'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe 'windows_service::enable' do
|
|
9
|
+
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
|
|
10
|
+
|
|
11
|
+
it 'enables a windows_service with an explicit action' do
|
|
12
|
+
expect(chef_run).to enable_windows_service('explicit_action')
|
|
13
|
+
expect(chef_run).to_not enable_windows_service('not_explicit_action')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'enables a windows_service with attributes' do
|
|
17
|
+
expect(chef_run).to enable_windows_service('with_attributes').with(pattern: 'pattern')
|
|
18
|
+
expect(chef_run).to_not enable_windows_service('with_attributes').with(pattern: 'bacon')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'enables a windows_service when specifying the identity attribute' do
|
|
22
|
+
expect(chef_run).to enable_windows_service('identity_attribute')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'chefspec'
|
|
2
|
+
|
|
3
|
+
RSpec.configure do |config|
|
|
4
|
+
config.platform = 'windows'
|
|
5
|
+
config.version = '2012R2'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe 'windows_service::reload' do
|
|
9
|
+
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
|
|
10
|
+
|
|
11
|
+
it 'reloads a windows_service with an explicit action' do
|
|
12
|
+
expect(chef_run).to reload_windows_service('explicit_action')
|
|
13
|
+
expect(chef_run).to_not reload_windows_service('not_explicit_action')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'reloads a windows_service with attributes' do
|
|
17
|
+
expect(chef_run).to reload_windows_service('with_attributes').with(pattern: 'pattern')
|
|
18
|
+
expect(chef_run).to_not reload_windows_service('with_attributes').with(pattern: 'bacon')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'reloads a windows_service when specifying the identity attribute' do
|
|
22
|
+
expect(chef_run).to reload_windows_service('identity_attribute')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'chefspec'
|
|
2
|
+
|
|
3
|
+
RSpec.configure do |config|
|
|
4
|
+
config.platform = 'windows'
|
|
5
|
+
config.version = '2012R2'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe 'windows_service::restart' do
|
|
9
|
+
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
|
|
10
|
+
|
|
11
|
+
it 'restarts a windows_service with an explicit action' do
|
|
12
|
+
expect(chef_run).to restart_windows_service('explicit_action')
|
|
13
|
+
expect(chef_run).to_not restart_windows_service('not_explicit_action')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'restarts a windows_service with attributes' do
|
|
17
|
+
expect(chef_run).to restart_windows_service('with_attributes').with(pattern: 'pattern')
|
|
18
|
+
expect(chef_run).to_not restart_windows_service('with_attributes').with(pattern: 'bacon')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'restarts a windows_service when specifying the identity attribute' do
|
|
22
|
+
expect(chef_run).to restart_windows_service('identity_attribute')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'chefspec'
|
|
2
|
+
|
|
3
|
+
RSpec.configure do |config|
|
|
4
|
+
config.platform = 'windows'
|
|
5
|
+
config.version = '2012R2'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe 'windows_service::start' do
|
|
9
|
+
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
|
|
10
|
+
|
|
11
|
+
it 'starts a windows_service with an explicit action' do
|
|
12
|
+
expect(chef_run).to start_windows_service('explicit_action')
|
|
13
|
+
expect(chef_run).to_not start_windows_service('not_explicit_action')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'starts a windows_service with attributes' do
|
|
17
|
+
expect(chef_run).to start_windows_service('with_attributes').with(pattern: 'pattern')
|
|
18
|
+
expect(chef_run).to_not start_windows_service('with_attributes').with(pattern: 'bacon')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'starts a windows_service when specifying the identity attribute' do
|
|
22
|
+
expect(chef_run).to start_windows_service('identity_attribute')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'chefspec'
|
|
2
|
+
|
|
3
|
+
RSpec.configure do |config|
|
|
4
|
+
config.platform = 'windows'
|
|
5
|
+
config.version = '2012R2'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe 'windows_service::stop' do
|
|
9
|
+
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
|
|
10
|
+
|
|
11
|
+
it 'stops a windows_service with an explicit action' do
|
|
12
|
+
expect(chef_run).to stop_windows_service('explicit_action')
|
|
13
|
+
expect(chef_run).to_not stop_windows_service('not_explicit_action')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'stops a windows_service with attributes' do
|
|
17
|
+
expect(chef_run).to stop_windows_service('with_attributes').with(pattern: 'pattern')
|
|
18
|
+
expect(chef_run).to_not stop_windows_service('with_attributes').with(pattern: 'bacon')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'stops a windows_service when specifying the identity attribute' do
|
|
22
|
+
expect(chef_run).to stop_windows_service('identity_attribute')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@not_chef_11_14_2
|
|
2
|
+
@not_chef_11_14_6
|
|
3
|
+
@not_chef_11_16_0
|
|
4
|
+
@not_chef_11_16_2
|
|
5
|
+
@not_chef_11_16_4
|
|
6
|
+
@not_chef_11_18_0
|
|
7
|
+
@not_chef_11_18_6
|
|
8
|
+
@not_chef_12_0_3
|
|
9
|
+
@not_chef_12_1_0
|
|
10
|
+
@not_chef_12_1_1
|
|
11
|
+
@not_chef_12_1_2
|
|
12
|
+
@not_chef_12_2_1
|
|
13
|
+
@not_chef_12_3_0
|
|
14
|
+
@not_chef_12_4_0
|
|
15
|
+
@not_chef_12_4_3
|
|
16
|
+
@not_chef_12_5_1
|
|
17
|
+
@not_chef_12_6_0
|
|
18
|
+
Feature: The chocolatey_package matcher
|
|
19
|
+
Background:
|
|
20
|
+
* I am using the "chocolatey_package" cookbook
|
|
21
|
+
|
|
22
|
+
Scenario Outline: Running specs
|
|
23
|
+
* I successfully run `rspec spec/<Matcher>_spec.rb`
|
|
24
|
+
* the output should contain "0 failures"
|
|
25
|
+
Examples:
|
|
26
|
+
| Matcher |
|
|
27
|
+
| install |
|
|
28
|
+
| remove |
|
|
29
|
+
| upgrade |
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
@not_chef_11_14_2
|
|
2
|
+
@not_chef_11_14_6
|
|
3
|
+
@not_chef_11_16_0
|
|
4
|
+
@not_chef_11_16_2
|
|
5
|
+
@not_chef_11_16_4
|
|
6
|
+
@not_chef_11_18_0
|
|
7
|
+
@not_chef_11_18_6
|
|
8
|
+
@not_chef_12_0_3
|
|
9
|
+
@not_chef_12_1_0
|
|
10
|
+
@not_chef_12_1_1
|
|
11
|
+
@not_chef_12_1_2
|
|
12
|
+
Feature: The dsc_resource matcher
|
|
13
|
+
Background:
|
|
14
|
+
* I am using the "dsc_resource" cookbook
|
|
15
|
+
|
|
16
|
+
Scenario: Running specs
|
|
17
|
+
* I successfully run `rspec spec/default_spec.rb`
|
|
18
|
+
* the output should contain "0 failures"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@not_chef_11_14_2
|
|
2
|
+
@not_chef_11_14_6
|
|
3
|
+
@not_chef_11_16_0
|
|
4
|
+
@not_chef_11_16_2
|
|
5
|
+
@not_chef_11_16_4
|
|
6
|
+
@not_chef_11_18_0
|
|
7
|
+
@not_chef_11_18_6
|
|
8
|
+
Feature: The reboot matcher
|
|
9
|
+
Background:
|
|
10
|
+
* I am using the "reboot" cookbook
|
|
11
|
+
|
|
12
|
+
Scenario Outline: Running specs
|
|
13
|
+
* I successfully run `rspec spec/<Matcher>_spec.rb`
|
|
14
|
+
* the output should contain "0 failures"
|
|
15
|
+
Examples:
|
|
16
|
+
| Matcher |
|
|
17
|
+
| request |
|
|
18
|
+
| now |
|
|
19
|
+
| cancel |
|
data/features/step_into.feature
CHANGED
data/features/support/env.rb
CHANGED
|
@@ -8,12 +8,13 @@ require 'chefspec'
|
|
|
8
8
|
require_relative 'executor'
|
|
9
9
|
|
|
10
10
|
Before do
|
|
11
|
-
FileUtils.mkdir_p(
|
|
12
|
-
FileUtils.cp_r('examples', current_dir)
|
|
11
|
+
FileUtils.mkdir_p(expand_path('.'))
|
|
13
12
|
|
|
14
13
|
# Use InProcess testing by default
|
|
15
|
-
Aruba
|
|
16
|
-
|
|
14
|
+
Aruba.configure do |config|
|
|
15
|
+
config.command_launcher = :in_process
|
|
16
|
+
config.main_class = ChefSpec::Executor
|
|
17
|
+
end
|
|
17
18
|
|
|
18
19
|
# Need to reload this on each run because RSpec.reset (called by the
|
|
19
20
|
# RSpec::Runner) removes our configurations :(
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
@not_chef_11_14_2
|
|
2
|
+
@not_chef_11_14_6
|
|
3
|
+
@not_chef_11_16_0
|
|
4
|
+
@not_chef_11_16_2
|
|
5
|
+
@not_chef_11_16_4
|
|
6
|
+
@not_chef_11_18_0
|
|
7
|
+
@not_chef_11_18_6
|
|
8
|
+
@not_chef_12_0_3
|
|
9
|
+
@not_chef_12_1_0
|
|
10
|
+
@not_chef_12_1_1
|
|
11
|
+
@not_chef_12_1_2
|
|
12
|
+
@not_chef_12_2_1
|
|
13
|
+
@not_chef_12_3_0
|
|
14
|
+
Feature: The windows_package matcher
|
|
15
|
+
Background:
|
|
16
|
+
* I am using the "windows_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
|
+
| remove |
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@not_chef_11_14_2
|
|
2
|
+
@not_chef_11_14_6
|
|
3
|
+
@not_chef_11_16_0
|
|
4
|
+
@not_chef_11_16_2
|
|
5
|
+
@not_chef_11_16_4
|
|
6
|
+
@not_chef_11_18_0
|
|
7
|
+
@not_chef_11_18_6
|
|
8
|
+
Feature: The windows_service matcher
|
|
9
|
+
Background:
|
|
10
|
+
* I am using the "windows_service" cookbook
|
|
11
|
+
|
|
12
|
+
Scenario Outline: Running specs
|
|
13
|
+
* I successfully run `rspec spec/<Matcher>_spec.rb`
|
|
14
|
+
* the output should contain "0 failures"
|
|
15
|
+
Examples:
|
|
16
|
+
| Matcher |
|
|
17
|
+
| configure_startup |
|
|
18
|
+
| disable |
|
|
19
|
+
| enable |
|
|
20
|
+
| reload |
|
|
21
|
+
| restart |
|
|
22
|
+
| start |
|
|
23
|
+
| stop |
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
module ChefSpec::API
|
|
2
|
+
# @since 4.6.0
|
|
3
|
+
module ChocolateyPackageMatchers
|
|
4
|
+
ChefSpec.define_matcher :chocolatey_package
|
|
5
|
+
#
|
|
6
|
+
# Assert that a +chocolatey_package+ resource exists in the Chef run with the
|
|
7
|
+
# action +:install+. Given a Chef Recipe that installs "7zip" as a
|
|
8
|
+
# +chocolatey_package+:
|
|
9
|
+
#
|
|
10
|
+
# chocolatey_package '7zip' do
|
|
11
|
+
# action :install
|
|
12
|
+
# end
|
|
13
|
+
#
|
|
14
|
+
# The Examples section demonstrates the different ways to test a
|
|
15
|
+
# +chocolatey_package+ resource with ChefSpec.
|
|
16
|
+
#
|
|
17
|
+
# @example Assert that a +chocolatey_package+ was installed
|
|
18
|
+
# expect(chef_run).to install_chocolatey_package('7zip')
|
|
19
|
+
#
|
|
20
|
+
# @example Assert that a +chocolatey_package+ was installed with attributes
|
|
21
|
+
# expect(chef_run).to install_chocolatey_package('git').with(
|
|
22
|
+
# version: %w(2.7.1),
|
|
23
|
+
# options: '--params /GitAndUnixToolsOnPath'
|
|
24
|
+
# )
|
|
25
|
+
#
|
|
26
|
+
# @example Assert that a +chocolatey_package+ was _not_ installed
|
|
27
|
+
# expect(chef_run).to_not install_chocolatey_package('flashplayeractivex')
|
|
28
|
+
#
|
|
29
|
+
# @param [String, Regex] resource_name
|
|
30
|
+
# the name of the resource to match
|
|
31
|
+
#
|
|
32
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
33
|
+
#
|
|
34
|
+
def install_chocolatey_package(resource_name)
|
|
35
|
+
ChefSpec::Matchers::ResourceMatcher.new(:chocolatey_package, :install, resource_name)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
#
|
|
39
|
+
# Assert that a +chocolatey_package+ resource exists in the Chef run with the
|
|
40
|
+
# action +:remove+. Given a Chef Recipe that removes "7zip" as a
|
|
41
|
+
# +chocolatey_package+:
|
|
42
|
+
#
|
|
43
|
+
# chocolatey_package '7zip' do
|
|
44
|
+
# action :remove
|
|
45
|
+
# end
|
|
46
|
+
#
|
|
47
|
+
# To test the content rendered by a +chocolatey_package+, see
|
|
48
|
+
# {ChefSpec::API::RenderFileMatchers}.
|
|
49
|
+
#
|
|
50
|
+
# The Examples section demonstrates the different ways to test a
|
|
51
|
+
# +chocolatey_package+ resource with ChefSpec.
|
|
52
|
+
#
|
|
53
|
+
# @example Assert that a +chocolatey_package+ was removed
|
|
54
|
+
# expect(chef_run).to remove_chocolatey_package('7zip')
|
|
55
|
+
#
|
|
56
|
+
# @example Assert that a specific +chocolatey_package+ version was removed
|
|
57
|
+
# expect(chef_run).to remove_chocolatey_package('7zip').with(
|
|
58
|
+
# version: %w(15.14)
|
|
59
|
+
# )
|
|
60
|
+
#
|
|
61
|
+
# @example Assert that a +chocolatey_package+ was _not_ removed
|
|
62
|
+
# expect(chef_run).to_not remove_chocolatey_package('7zip')
|
|
63
|
+
#
|
|
64
|
+
#
|
|
65
|
+
# @param [String, Regex] resource_name
|
|
66
|
+
# the name of the resource to match
|
|
67
|
+
#
|
|
68
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
69
|
+
#
|
|
70
|
+
def remove_chocolatey_package(resource_name)
|
|
71
|
+
ChefSpec::Matchers::ResourceMatcher.new(:chocolatey_package, :remove, resource_name)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
#
|
|
75
|
+
# Assert that a +chocolatey_package+ resource exists in the Chef run with the
|
|
76
|
+
# action +:upgrade+. Given a Chef Recipe that upgrades "7zip" as a
|
|
77
|
+
# +chocolatey_package+:
|
|
78
|
+
#
|
|
79
|
+
# chocolatey_package '7zip' do
|
|
80
|
+
# action :upgrade
|
|
81
|
+
# end
|
|
82
|
+
#
|
|
83
|
+
# The Examples section demonstrates the different ways to test a
|
|
84
|
+
# +chocolatey_package+ resource with ChefSpec.
|
|
85
|
+
#
|
|
86
|
+
# @example Assert that a +chocolatey_package+ was upgraded
|
|
87
|
+
# expect(chef_run).to upgrade_chocolatey_package('7zip')
|
|
88
|
+
#
|
|
89
|
+
# @example Assert that a +chocolatey_package+ was upgraded with attributes
|
|
90
|
+
# expect(chef_run).to upgrade_chocolatey_package('git').with(
|
|
91
|
+
# version: %w(2.7.1),
|
|
92
|
+
# options: '-params "/GitAndUnixToolsOnPath"'
|
|
93
|
+
# )
|
|
94
|
+
#
|
|
95
|
+
# @example Assert that a +chocolatey_package+ was _not_ upgraded
|
|
96
|
+
# expect(chef_run).to_not upgrade_chocolatey_package('flashplayeractivex')
|
|
97
|
+
#
|
|
98
|
+
# @param [String, Regex] resource_name
|
|
99
|
+
# the name of the resource to match
|
|
100
|
+
#
|
|
101
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
102
|
+
#
|
|
103
|
+
def upgrade_chocolatey_package(resource_name)
|
|
104
|
+
ChefSpec::Matchers::ResourceMatcher.new(:chocolatey_package, :upgrade, resource_name)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
@@ -15,19 +15,19 @@ module ChefSpec::API
|
|
|
15
15
|
# The Examples section demonstrates the different ways to test a
|
|
16
16
|
# +directory+ resource with ChefSpec.
|
|
17
17
|
#
|
|
18
|
-
# @example Assert that a +directory+ was
|
|
18
|
+
# @example Assert that a +directory+ was created
|
|
19
19
|
# expect(chef_run).to create_directory('/tmp')
|
|
20
20
|
#
|
|
21
|
-
# @example Assert that a +directory+ was
|
|
21
|
+
# @example Assert that a +directory+ was created with predicate matchers
|
|
22
22
|
# expect(chef_run).to create_directory('/tmp').with_user('svargo')
|
|
23
23
|
#
|
|
24
|
-
# @example Assert that a +directory+ was
|
|
24
|
+
# @example Assert that a +directory+ was created with attributes
|
|
25
25
|
# expect(chef_run).to create_directory('/tmp').with(user: 'svargo')
|
|
26
26
|
#
|
|
27
|
-
# @example Assert that a +directory+ was
|
|
27
|
+
# @example Assert that a +directory+ was created using a regex
|
|
28
28
|
# expect(chef_run).to create_directory('/tmp').with(user: /sva(.+)/)
|
|
29
29
|
#
|
|
30
|
-
# @example Assert that a +directory+ was _not_
|
|
30
|
+
# @example Assert that a +directory+ was _not_ created
|
|
31
31
|
# expect(chef_run).to_not create_directory('/tmp')
|
|
32
32
|
#
|
|
33
33
|
#
|
|
@@ -52,19 +52,19 @@ module ChefSpec::API
|
|
|
52
52
|
# The Examples section demonstrates the different ways to test a
|
|
53
53
|
# +directory+ resource with ChefSpec.
|
|
54
54
|
#
|
|
55
|
-
# @example Assert that a +directory+ was
|
|
55
|
+
# @example Assert that a +directory+ was deleted
|
|
56
56
|
# expect(chef_run).to delete_directory('/tmp')
|
|
57
57
|
#
|
|
58
|
-
# @example Assert that a +directory+ was
|
|
58
|
+
# @example Assert that a +directory+ was deleted with predicate matchers
|
|
59
59
|
# expect(chef_run).to delete_directory('/tmp').with_user('svargo')
|
|
60
60
|
#
|
|
61
|
-
# @example Assert that a +directory+ was
|
|
61
|
+
# @example Assert that a +directory+ was deleted with attributes
|
|
62
62
|
# expect(chef_run).to delete_directory('/tmp').with(user: 'svargo')
|
|
63
63
|
#
|
|
64
|
-
# @example Assert that a +directory+ was
|
|
64
|
+
# @example Assert that a +directory+ was deleted using a regex
|
|
65
65
|
# expect(chef_run).to delete_directory('/tmp').with(user: /sva(.+)/)
|
|
66
66
|
#
|
|
67
|
-
# @example Assert that a +directory+ was _not_
|
|
67
|
+
# @example Assert that a +directory+ was _not_ deleted
|
|
68
68
|
# expect(chef_run).to_not delete_directory('/tmp')
|
|
69
69
|
#
|
|
70
70
|
#
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module ChefSpec::API
|
|
2
|
+
# @since 4.3.0
|
|
3
|
+
module DscResourceMatchers
|
|
4
|
+
ChefSpec.define_matcher :dsc_resource
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
# Assert that a +dsc_resource+ resource exists in the Chef run with the
|
|
8
|
+
# action +:run+. Given a Chef Recipe that installs "zip" as a
|
|
9
|
+
# +dsc_resource+:
|
|
10
|
+
#
|
|
11
|
+
# dsc_resource 'zip' do
|
|
12
|
+
# resource :archive
|
|
13
|
+
# property :ensure, 'Present'
|
|
14
|
+
# property :path, "C:\Users\Public\Documents\example.zip"
|
|
15
|
+
# property :destination, "C:\Users\Public\Documents\ExtractionPath"
|
|
16
|
+
# end
|
|
17
|
+
#
|
|
18
|
+
# To test the content rendered by a +dsc_resource+, see
|
|
19
|
+
# {ChefSpec::API::RenderFileMatchers}.
|
|
20
|
+
#
|
|
21
|
+
# The Examples section demonstrates the different ways to test a
|
|
22
|
+
# +dsc_resource+ resource with ChefSpec.
|
|
23
|
+
#
|
|
24
|
+
# @example Assert that a +dsc_resource+ was installed
|
|
25
|
+
# expect(chef_run).to run_dsc_resource('zip')
|
|
26
|
+
#
|
|
27
|
+
# @example Assert that a +dsc_resource+ was installed with predicate matchers
|
|
28
|
+
# expect(chef_run).to run_dsc_resource('zip').with_resource(:archive)
|
|
29
|
+
#
|
|
30
|
+
# @example Assert that a +dsc_resource+ was installed with attributes
|
|
31
|
+
# expect(chef_run).to run_dsc_resource('zip').with(resource: :archive)
|
|
32
|
+
#
|
|
33
|
+
# @example Assert that a +dsc_resource+ was installed using a regex
|
|
34
|
+
# expect(chef_run).to run_dsc_resource('zip').with(resource: /:arch(.+)/)
|
|
35
|
+
#
|
|
36
|
+
# @example Assert that a +dsc_resource+ was _not_ installed
|
|
37
|
+
# expect(chef_run).to_not run_dsc_resource('zip')
|
|
38
|
+
#
|
|
39
|
+
#
|
|
40
|
+
# @param [String, Regex] resource_name
|
|
41
|
+
# the name of the resource to match
|
|
42
|
+
#
|
|
43
|
+
# @return [ChefSpec::Matchers::ResourceMatcher]
|
|
44
|
+
#
|
|
45
|
+
def run_dsc_resource(resource_name)
|
|
46
|
+
ChefSpec::Matchers::ResourceMatcher.new(:dsc_resource, :run, resource_name)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
data/lib/chefspec/api/group.rb
CHANGED
|
@@ -15,19 +15,19 @@ module ChefSpec::API
|
|
|
15
15
|
# The Examples section demonstrates the different ways to test a
|
|
16
16
|
# +group+ resource with ChefSpec.
|
|
17
17
|
#
|
|
18
|
-
# @example Assert that a +group+ was
|
|
18
|
+
# @example Assert that a +group+ was created
|
|
19
19
|
# expect(chef_run).to create_group('apache2')
|
|
20
20
|
#
|
|
21
|
-
# @example Assert that a +group+ was
|
|
21
|
+
# @example Assert that a +group+ was created with predicate matchers
|
|
22
22
|
# expect(chef_run).to create_group('apache2').with_gid(1234)
|
|
23
23
|
#
|
|
24
|
-
# @example Assert that a +group+ was
|
|
24
|
+
# @example Assert that a +group+ was created with attributes
|
|
25
25
|
# expect(chef_run).to create_group('apache2').with(gid: 1234)
|
|
26
26
|
#
|
|
27
|
-
# @example Assert that a +group+ was
|
|
27
|
+
# @example Assert that a +group+ was created using a regex
|
|
28
28
|
# expect(chef_run).to create_group('apache2').with(gid: /\d+/)
|
|
29
29
|
#
|
|
30
|
-
# @example Assert that a +group+ was _not_
|
|
30
|
+
# @example Assert that a +group+ was _not_ created
|
|
31
31
|
# expect(chef_run).to_not create_group('apache2')
|
|
32
32
|
#
|
|
33
33
|
#
|
data/lib/chefspec/api/link.rb
CHANGED
|
@@ -15,19 +15,19 @@ module ChefSpec::API
|
|
|
15
15
|
# The Examples section demonstrates the different ways to test a
|
|
16
16
|
# +link+ resource with ChefSpec.
|
|
17
17
|
#
|
|
18
|
-
# @example Assert that a +link+ was
|
|
18
|
+
# @example Assert that a +link+ was created
|
|
19
19
|
# expect(chef_run).to create_link('/tmp')
|
|
20
20
|
#
|
|
21
|
-
# @example Assert that a +link+ was
|
|
21
|
+
# @example Assert that a +link+ was created with predicate matchers
|
|
22
22
|
# expect(chef_run).to create_link('/tmp').with_link_type(:hard)
|
|
23
23
|
#
|
|
24
|
-
# @example Assert that a +link+ was
|
|
24
|
+
# @example Assert that a +link+ was created with attributes
|
|
25
25
|
# expect(chef_run).to create_link('/tmp').with(link_type: :hard)
|
|
26
26
|
#
|
|
27
|
-
# @example Assert that a +link+ was
|
|
27
|
+
# @example Assert that a +link+ was created using a regex
|
|
28
28
|
# expect(chef_run).to create_link('/tmp').with(link_type: Symbol)
|
|
29
29
|
#
|
|
30
|
-
# @example Assert that a +link+ was _not_
|
|
30
|
+
# @example Assert that a +link+ was _not_ created
|
|
31
31
|
# expect(chef_run).to_not create_link('/tmp')
|
|
32
32
|
#
|
|
33
33
|
#
|
|
@@ -52,19 +52,19 @@ module ChefSpec::API
|
|
|
52
52
|
# The Examples section demonstrates the different ways to test a
|
|
53
53
|
# +link+ resource with ChefSpec.
|
|
54
54
|
#
|
|
55
|
-
# @example Assert that a +link+ was
|
|
55
|
+
# @example Assert that a +link+ was deleted
|
|
56
56
|
# expect(chef_run).to delete_link('/tmp')
|
|
57
57
|
#
|
|
58
|
-
# @example Assert that a +link+ was
|
|
58
|
+
# @example Assert that a +link+ was deleted with predicate matchers
|
|
59
59
|
# expect(chef_run).to delete_link('/tmp').with_link_type(:hard)
|
|
60
60
|
#
|
|
61
|
-
# @example Assert that a +link+ was
|
|
61
|
+
# @example Assert that a +link+ was deleted with attributes
|
|
62
62
|
# expect(chef_run).to delete_link('/tmp').with(link_type: :hard)
|
|
63
63
|
#
|
|
64
|
-
# @example Assert that a +link+ was
|
|
64
|
+
# @example Assert that a +link+ was deleted using a regex
|
|
65
65
|
# expect(chef_run).to delete_link('/tmp').with(link_type: Symbol)
|
|
66
66
|
#
|
|
67
|
-
# @example Assert that a +link+ was _not_
|
|
67
|
+
# @example Assert that a +link+ was _not_ deleted
|
|
68
68
|
# expect(chef_run).to_not delete_link('/tmp')
|
|
69
69
|
#
|
|
70
70
|
#
|
data/lib/chefspec/api/mdadm.rb
CHANGED
|
@@ -52,19 +52,19 @@ module ChefSpec::API
|
|
|
52
52
|
# The Examples section demonstrates the different ways to test a
|
|
53
53
|
# +mdadm+ resource with ChefSpec.
|
|
54
54
|
#
|
|
55
|
-
# @example Assert that a +mdadm+ was
|
|
55
|
+
# @example Assert that a +mdadm+ was created
|
|
56
56
|
# expect(chef_run).to create_mdadm('/dev/md0')
|
|
57
57
|
#
|
|
58
|
-
# @example Assert that a +mdadm+ was
|
|
58
|
+
# @example Assert that a +mdadm+ was created with predicate matchers
|
|
59
59
|
# expect(chef_run).to create_mdadm('/dev/md0').with_devices(['/dev/sda'])
|
|
60
60
|
#
|
|
61
|
-
# @example Assert that a +mdadm+ was
|
|
61
|
+
# @example Assert that a +mdadm+ was created with attributes
|
|
62
62
|
# expect(chef_run).to create_mdadm('/dev/md0').with(devices: ['/dev/sda'])
|
|
63
63
|
#
|
|
64
|
-
# @example Assert that a +mdadm+ was
|
|
64
|
+
# @example Assert that a +mdadm+ was created using a regex
|
|
65
65
|
# expect(chef_run).to create_mdadm('/dev/md0').with(devices: '/dev/sda')
|
|
66
66
|
#
|
|
67
|
-
# @example Assert that a +mdadm+ was _not_
|
|
67
|
+
# @example Assert that a +mdadm+ was _not_ created
|
|
68
68
|
# expect(chef_run).to_not create_mdadm('/dev/md0')
|
|
69
69
|
#
|
|
70
70
|
#
|