chefspec 7.0.0 → 7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/Gemfile +6 -0
- data/README.md +43 -11
- data/Rakefile +48 -8
- data/chefspec.gemspec +0 -8
- data/examples/cab_package/spec/install_spec.rb +20 -18
- data/examples/cab_package/spec/remove_spec.rb +17 -15
- data/examples/cached/spec/default_spec.rb +1 -0
- data/examples/compile_time/spec/default_spec.rb +2 -0
- data/examples/custom_matcher/libraries/matcher.rb +1 -23
- data/examples/dnf_package/spec/install_spec.rb +20 -18
- data/examples/dnf_package/spec/purge_spec.rb +17 -15
- data/examples/dnf_package/spec/remove_spec.rb +17 -15
- data/examples/dnf_package/spec/upgrade_spec.rb +17 -15
- data/examples/heavy_provider_light_resource/spec/provider_service_spec.rb +1 -0
- data/examples/msu_package/spec/install_spec.rb +20 -18
- data/examples/msu_package/spec/remove_spec.rb +17 -15
- data/examples/server/spec/exotic_port_spec.rb +15 -2
- data/lib/chefspec.rb +1 -8
- data/lib/chefspec/api.rb +6 -84
- data/lib/chefspec/api/do_nothing.rb +18 -21
- data/lib/chefspec/api/include_recipe.rb +20 -23
- data/lib/chefspec/api/link.rb +20 -99
- data/lib/chefspec/api/notifications.rb +32 -35
- data/lib/chefspec/api/reboot.rb +5 -14
- data/lib/chefspec/api/render_file.rb +29 -32
- data/lib/chefspec/api/state_attrs.rb +22 -25
- data/lib/chefspec/api/subscriptions.rb +29 -32
- data/lib/chefspec/api/user.rb +216 -219
- data/lib/chefspec/extensions.rb +16 -0
- data/lib/chefspec/extensions/chef/resource.rb +90 -8
- data/lib/chefspec/version.rb +1 -1
- data/lib/chefspec/zero_server.rb +20 -18
- metadata +3 -313
- data/examples/custom_resource/libraries/matchers.rb +0 -5
- data/examples/use_inline_resources/libraries/matchers.rb +0 -5
- data/features/apt_package.feature +0 -14
- data/features/apt_repository.feature +0 -15
- data/features/apt_update.feature +0 -13
- data/features/attributes.feature +0 -7
- data/features/batch.feature +0 -10
- data/features/bff_package.feature +0 -12
- data/features/cab_package.feature +0 -21
- data/features/cached.feature +0 -7
- data/features/chef_gem.feature +0 -14
- data/features/chocolatey_package.feature +0 -14
- data/features/compile_time.feature +0 -7
- data/features/cookbook_file.feature +0 -13
- data/features/cron.feature +0 -11
- data/features/custom_matcher.feature +0 -11
- data/features/custom_resource.feature +0 -7
- data/features/deploy.feature +0 -12
- data/features/directory.feature +0 -11
- data/features/dnf_package.feature +0 -26
- data/features/do_nothing.feature +0 -10
- data/features/dpkg_package.feature +0 -12
- data/features/dsc_resource.feature +0 -10
- data/features/dsc_script.feature +0 -10
- data/features/env.feature +0 -12
- data/features/erl_call.feature +0 -10
- data/features/execute.feature +0 -10
- data/features/exotic_zero_port.feature +0 -7
- data/features/expect_exception.feature +0 -12
- data/features/file.feature +0 -13
- data/features/freebsd_package.feature +0 -11
- data/features/gem_package.feature +0 -14
- data/features/git.feature +0 -12
- data/features/group.feature +0 -13
- data/features/guards.feature +0 -10
- data/features/heavy_provider_light_resource.feature +0 -10
- data/features/homebrew_package.feature +0 -12
- data/features/http_request.feature +0 -15
- data/features/ifconfig.feature +0 -13
- data/features/include_recipe.feature +0 -10
- data/features/ips_package.feature +0 -12
- data/features/launchd.feature +0 -17
- data/features/link.feature +0 -12
- data/features/log.feature +0 -10
- data/features/macports_package.feature +0 -13
- data/features/mdadm.feature +0 -12
- data/features/mount.feature +0 -14
- data/features/msu_package.feature +0 -23
- data/features/multiple_actions.feature +0 -12
- data/features/multiple_run_action.feature +0 -7
- data/features/notifications.feature +0 -14
- data/features/ohai.feature +0 -10
- data/features/openbsd_package.feature +0 -12
- data/features/osx_profile.feature +0 -13
- data/features/package.feature +0 -14
- data/features/pacman_package.feature +0 -13
- data/features/paludis_package.feature +0 -12
- data/features/portage_package.feature +0 -13
- data/features/powershell_script.feature +0 -10
- data/features/reboot.feature +0 -12
- data/features/registry_key.feature +0 -13
- data/features/remote_directory.feature +0 -12
- data/features/remote_file.feature +0 -13
- data/features/render_file.feature +0 -11
- data/features/roles.feature +0 -7
- data/features/route.feature +0 -11
- data/features/rpm_package.feature +0 -12
- data/features/ruby_block.feature +0 -11
- data/features/script.feature +0 -16
- data/features/server.feature +0 -16
- data/features/server_on_disk.feature +0 -16
- data/features/service.feature +0 -15
- data/features/smartos_package.feature +0 -12
- data/features/solaris_package.feature +0 -12
- data/features/state_attrs.feature +0 -7
- data/features/step_definitions/background_steps.rb +0 -7
- data/features/step_into.feature +0 -7
- data/features/stub_command.feature +0 -7
- data/features/stub_data_bag.feature +0 -7
- data/features/stub_data_bag_item.feature +0 -7
- data/features/stub_node.feature +0 -7
- data/features/stub_search.feature +0 -7
- data/features/subscribes.feature +0 -14
- data/features/subversion.feature +0 -13
- data/features/support/env.rb +0 -38
- data/features/support/executor.rb +0 -20
- data/features/support/exotic_zero_port.rb +0 -3
- data/features/support/on_disk.rb +0 -7
- data/features/systemd_unit.feature +0 -27
- data/features/template.feature +0 -13
- data/features/use_inline_resources.feature +0 -7
- data/features/user.feature +0 -15
- data/features/windows_package.feature +0 -11
- data/features/windows_service.feature +0 -16
- data/features/yum_package.feature +0 -13
- data/features/yum_repository.feature +0 -23
- data/features/zypper_package.feature +0 -13
- data/lib/chefspec/api/apt_package.rb +0 -192
- data/lib/chefspec/api/apt_repository.rb +0 -56
- data/lib/chefspec/api/apt_update.rb +0 -53
- data/lib/chefspec/api/batch.rb +0 -43
- data/lib/chefspec/api/bff_package.rb +0 -154
- data/lib/chefspec/api/cab_package.rb +0 -80
- data/lib/chefspec/api/chef_gem.rb +0 -191
- data/lib/chefspec/api/chocolatey_package.rb +0 -107
- data/lib/chefspec/api/cookbook_file.rb +0 -166
- data/lib/chefspec/api/cron.rb +0 -80
- data/lib/chefspec/api/deploy.rb +0 -117
- data/lib/chefspec/api/directory.rb +0 -80
- data/lib/chefspec/api/dnf_package.rb +0 -154
- data/lib/chefspec/api/dpkg_package.rb +0 -117
- data/lib/chefspec/api/dsc_resource.rb +0 -49
- data/lib/chefspec/api/dsc_script.rb +0 -37
- data/lib/chefspec/api/easy_install_package.rb +0 -154
- data/lib/chefspec/api/env.rb +0 -117
- data/lib/chefspec/api/erl_call.rb +0 -43
- data/lib/chefspec/api/execute.rb +0 -43
- data/lib/chefspec/api/file.rb +0 -166
- data/lib/chefspec/api/freebsd_package.rb +0 -80
- data/lib/chefspec/api/gem_package.rb +0 -191
- data/lib/chefspec/api/git.rb +0 -117
- data/lib/chefspec/api/group.rb +0 -154
- data/lib/chefspec/api/homebrew_package.rb +0 -154
- data/lib/chefspec/api/http_request.rb +0 -228
- data/lib/chefspec/api/ifconfig.rb +0 -154
- data/lib/chefspec/api/ips_package.rb +0 -117
- data/lib/chefspec/api/launchd.rb +0 -151
- data/lib/chefspec/api/log.rb +0 -43
- data/lib/chefspec/api/macports_package.rb +0 -154
- data/lib/chefspec/api/mdadm.rb +0 -117
- data/lib/chefspec/api/mount.rb +0 -192
- data/lib/chefspec/api/msu_package.rb +0 -81
- data/lib/chefspec/api/ohai.rb +0 -43
- data/lib/chefspec/api/openbsd_package.rb +0 -155
- data/lib/chefspec/api/osx_profile.rb +0 -63
- data/lib/chefspec/api/package.rb +0 -192
- data/lib/chefspec/api/pacman_package.rb +0 -155
- data/lib/chefspec/api/paludis_package.rb +0 -155
- data/lib/chefspec/api/portage_package.rb +0 -155
- data/lib/chefspec/api/powershell_script.rb +0 -43
- data/lib/chefspec/api/registry_key.rb +0 -166
- data/lib/chefspec/api/remote_directory.rb +0 -120
- data/lib/chefspec/api/remote_file.rb +0 -166
- data/lib/chefspec/api/route.rb +0 -80
- data/lib/chefspec/api/rpm_package.rb +0 -117
- data/lib/chefspec/api/ruby_block.rb +0 -68
- data/lib/chefspec/api/script.rb +0 -278
- data/lib/chefspec/api/service.rb +0 -246
- data/lib/chefspec/api/smartos_package.rb +0 -117
- data/lib/chefspec/api/solaris_package.rb +0 -117
- data/lib/chefspec/api/subversion.rb +0 -154
- data/lib/chefspec/api/systemd_unit.rb +0 -353
- data/lib/chefspec/api/template.rb +0 -166
- data/lib/chefspec/api/windows_package.rb +0 -86
- data/lib/chefspec/api/windows_service.rb +0 -286
- data/lib/chefspec/api/yum_package.rb +0 -154
- data/lib/chefspec/api/yum_repository.rb +0 -130
- data/lib/chefspec/api/zypper_package.rb +0 -154
- data/spec/unit/api_spec.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3617560994bd67eae8bece75bdfcd66c6fcc259
|
4
|
+
data.tar.gz: 953c6f0e6e1471483ad9d7fd1f9ecb8b7d77f5be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f6016eb17cf6fcbb0497d1b9f097f5f4ddc54002572653ff87c666a60bb7819d38e4c452ff14bb3c49cb3c3705fbe79f373f00662e98a5524019b507bc509ee
|
7
|
+
data.tar.gz: ab41f6c8868ba16d5f6f350a847e5314d1c983bccb98aab78a9de6bd99ea0a835b95be565263b69c81777063ad98af3d4605a8f2e6fc4fce8363d15ec17d5151
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# CHANGELOG for ChefSpec
|
2
2
|
|
3
|
-
## 7.
|
3
|
+
## 7.1.0 (May 9, 2017)
|
4
|
+
|
5
|
+
- Resource matchers are now generated automatically. What does this mean for you? A lot:
|
6
|
+
1. You won't have to worry about older releases of ChefSpec not knowing about new resources in chef-client.
|
7
|
+
2. You won't have to define the matchers in your cookbook code, which also means you won't have issues if a community cookbook lacks matchers
|
8
|
+
|
9
|
+
- Removed the usage of Cucumber for testing
|
10
|
+
- Removed all test deps from the Gemspec
|
11
|
+
- Added a warning about stubbing core Ruby methods and the issues that can cause
|
12
|
+
|
13
|
+
## 7.0.0 (April 18, 2017)
|
4
14
|
|
5
15
|
- Increased the chef gem dependency from 12.6+ to 12.14+. Since ChefSpec is consumed within ChefDK this actually has a minor impact on end users who generally consume Chefspec via ChefDK, which will bundle both compatible chef and chefspec releases.
|
6
16
|
- Fixed incompatibilities with Chef 13.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -9,26 +9,18 @@ ChefSpec runs your cookbook(s) locally with Chef Solo without actually convergin
|
|
9
9
|
- It's really fast!
|
10
10
|
- Your tests can vary node attributes, operating systems, and search results to assert behavior under varying conditions.
|
11
11
|
|
12
|
-
## What people are saying
|
13
|
-
|
14
|
-
> I just wanted to drop you a line to say "HELL YES!" to ChefSpec. - [Joe Goggins](https://twitter.com/jgoggins)
|
15
|
-
|
16
|
-
> OK ChefSpec is my new best friend. Delightful few hours working with it. - [Michael Ivey](https://twitter.com/ivey)
|
17
|
-
|
18
|
-
**Chat with us - [#chefspec](irc://irc.freenode.net/chefspec) on Freenode**
|
19
|
-
|
20
12
|
## Important Notes
|
21
13
|
|
22
14
|
- **ChefSpec requires Ruby 2.2 or later and Chef 12.14.89 or later!**
|
23
15
|
- **This documentation corresponds to the master branch, which may be unreleased. Please check the README of the latest git tag or the gem's source for your version's documentation!**
|
24
|
-
- **Each resource matcher is self-documented using [Yard](http://rubydoc.info/github/sethvargo/chefspec) and has a corresponding
|
25
|
-
- **ChefSpec aims to maintain compatibility with the two most recent minor versions of Chef.** If you are running an older version of Chef it may work, or you will need to run an older version of ChefSpec.
|
16
|
+
- **Each resource matcher is self-documented using [Yard](http://rubydoc.info/github/sethvargo/chefspec) and has a corresponding test recipe in the [examples directory](https://github.com/sethvargo/chefspec/tree/master/examples).**
|
26
17
|
|
27
18
|
## Notes on Compatibility with Chef Versions
|
28
19
|
|
20
|
+
**ChefSpec aims to maintain compatibility with the two most recent minor versions of Chef.** If you are running an older version of Chef it may work, or you will need to run an older version of ChefSpec.
|
21
|
+
|
29
22
|
As a general rule, if it is tested in the Travis CI matrix, it is a supported version. The section below details any specific versions that are _not_ supported and why:
|
30
23
|
|
31
|
-
Additionally, if you look at a cucumber feature and see a tag like `@not_chef_x_y_z`, that means that particular functionality is not supported on those versions of Chef.
|
32
24
|
|
33
25
|
## Writing a Cookbook Example
|
34
26
|
|
@@ -710,6 +702,34 @@ describe 'example::default' do
|
|
710
702
|
end
|
711
703
|
```
|
712
704
|
|
705
|
+
### Ruby libraries (File, FileUtils, etc)
|
706
|
+
|
707
|
+
When stubbing core ruby libraries, users must be aware that there is no differentiation between your cookbook code that calls `File.exist?` and core chef
|
708
|
+
code (e.g. the cookbook loader) that calls `File.exist?`. If you stub or setup an expectation without qualifying the arguments then you will stub that
|
709
|
+
method for all core chef code as well. Also note that if you setup an expectation on a particular argument that invoking the method with any other
|
710
|
+
argument will throw an unexpected argument error out of rspec, so you must setup an allowance using `.and_call_original` to avoid breaking core chef.
|
711
|
+
|
712
|
+
```ruby
|
713
|
+
describe 'example::default' do
|
714
|
+
let(:chef_run) { ChefSpec::SoloRunner.new }
|
715
|
+
|
716
|
+
before do
|
717
|
+
# avoid breaking all of core chef wherever it calls File.exist? with other arguments
|
718
|
+
allow(File).to receive(:exist?).and_call_original
|
719
|
+
end
|
720
|
+
|
721
|
+
it "tests something when /etc/myfile.txt does not exist" do
|
722
|
+
# only setup an expectation on our file
|
723
|
+
expect(File).to receive(:exist?).with("/etc/myfile.txt").and_return(false)
|
724
|
+
[ ... test that the chef resource collection is constructed correctly in this case ... ]
|
725
|
+
end
|
726
|
+
end
|
727
|
+
```
|
728
|
+
|
729
|
+
This is basic usage of rspec and not specific to chefspec. It applies to any class method in `File`, `Dir`, `FileUtils`, `IO` or any other ruby library. In
|
730
|
+
general any time you `expect(Some::Symbol).to receive(:a_method).and_return(value)` you run the risk of breaking other code unless you isolate your mocking
|
731
|
+
or expectation down to only the arguments which your code uses.
|
732
|
+
|
713
733
|
## Reporting
|
714
734
|
|
715
735
|
ChefSpec can generate a report of resources read over resources tested.
|
@@ -893,6 +913,18 @@ end
|
|
893
913
|
|
894
914
|
**NOTE:** If your cookbook exposes LWRPs, it is highly recommended you also create a `libraries/matchers.rb` file as outlined below in the "Packaging Custom Matchers" section. **You should never `step_into` an LWRP unless you are testing it. Never `step_into` an LWRP from another cookbook!**
|
895
915
|
|
916
|
+
## Automatic Matchers
|
917
|
+
|
918
|
+
As of ChefSpec 7.1.0 there are "custom" matchers generated for all internal core-chef resources, along with any LWRPs/HWRPs/Custom Resources that are user-defined in cookbooks.
|
919
|
+
|
920
|
+
The matchers follow the standard custom of `<action>_<resource_name>` with the exception of the `create_if_missing` action which *also* gets a `create_<resource_name>_if_missing`
|
921
|
+
matcher.
|
922
|
+
|
923
|
+
Matchers should be wired up for the `resource_name` of the resource along with all define `provides` lines synonyms and any `action` methods or `allowed_actions`.
|
924
|
+
|
925
|
+
There should be little reason to package custom matchers in cookbooks any more, but the approach below still works if there are special matchers which cookbooks wish to expose which do
|
926
|
+
not follow the automatically generated pattern.
|
927
|
+
|
896
928
|
## Packaging Custom Matchers
|
897
929
|
|
898
930
|
ChefSpec exposes the ability for cookbook authors to package custom matchers inside a cookbook so that other developers may take advantage of them in testing. This is done by creating a special library file in the cookbook named `matchers.rb`:
|
data/Rakefile
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
|
-
require '
|
2
|
+
require 'rspec/core'
|
3
3
|
require 'rspec/core/rake_task'
|
4
4
|
require 'yard/rake/yardoc_task'
|
5
|
+
require 'tmpdir'
|
6
|
+
require 'rspec'
|
7
|
+
require 'chefspec'
|
5
8
|
|
6
9
|
require 'chef/version'
|
7
10
|
|
@@ -14,13 +17,50 @@ RSpec::Core::RakeTask.new(:unit) do |t|
|
|
14
17
|
end.join(' ')
|
15
18
|
end
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
failed = false
|
21
|
+
|
22
|
+
namespace :acceptance do |ns|
|
23
|
+
Dir.foreach("examples") do |dir|
|
24
|
+
next if dir == '.' or dir == '..'
|
25
|
+
desc "#{dir} acceptance tests"
|
26
|
+
task dir.to_sym do
|
27
|
+
Dir.mktmpdir do |tmp|
|
28
|
+
FileUtils.cp_r("examples/#{dir}", tmp)
|
29
|
+
|
30
|
+
pwd = Dir.pwd
|
31
|
+
|
32
|
+
Dir.chdir "#{tmp}/#{dir}" do
|
33
|
+
puts "rspec examples/#{dir}"
|
34
|
+
|
35
|
+
#
|
36
|
+
# This bit of mildly awful magic below is to load each file into an in-memory
|
37
|
+
# RSpec runner while keeping a persistent ChefZero server alive.
|
38
|
+
#
|
39
|
+
load "#{pwd}/lib/chefspec/rspec.rb"
|
40
|
+
|
41
|
+
RSpec.configure do |config|
|
42
|
+
config.color = true
|
43
|
+
config.before(:suite) do
|
44
|
+
ChefSpec::ZeroServer.setup!
|
45
|
+
end
|
46
|
+
config.after(:each) do
|
47
|
+
ChefSpec::ZeroServer.reset!
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
RSpec.clear_examples
|
52
|
+
exitstatus = RSpec::Core::Runner.run(["spec"])
|
53
|
+
RSpec.reset
|
54
|
+
failed = true unless exitstatus == 0
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
task acceptance: Rake.application.tasks.select { |t| t.name.start_with?("acceptance:") } do
|
63
|
+
raise "some tests failed" if failed
|
24
64
|
end
|
25
65
|
|
26
66
|
desc 'Run all tests'
|
data/chefspec.gemspec
CHANGED
@@ -28,12 +28,4 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_dependency 'chef', '>= 12.14.89'
|
29
29
|
s.add_dependency 'fauxhai', '>= 4', '< 6'
|
30
30
|
s.add_dependency 'rspec', '~> 3.0'
|
31
|
-
|
32
|
-
# Development Dependencies
|
33
|
-
s.add_development_dependency 'rake', '< 13.0'
|
34
|
-
s.add_development_dependency 'redcarpet', '~> 3.3'
|
35
|
-
s.add_development_dependency 'yard', '~> 0.8'
|
36
|
-
|
37
|
-
# Testing Dependencies
|
38
|
-
s.add_development_dependency 'aruba', '~> 0.8'
|
39
31
|
end
|
@@ -1,26 +1,28 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
if defined?(Chef::Resource::CabPackage)
|
4
|
+
describe 'cab_package::install' do
|
5
|
+
let(:chef_run) do
|
6
|
+
ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
|
7
|
+
.converge(described_recipe)
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
it 'installs a cab_package with the default action' do
|
11
|
+
expect(chef_run).to install_cab_package('default_action')
|
12
|
+
expect(chef_run).to_not install_cab_package('not_default_action')
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
it 'installs a cab_package with an explicit action' do
|
16
|
+
expect(chef_run).to install_cab_package('explicit_action')
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
it 'installs a cab_package with attributes' do
|
20
|
+
expect(chef_run).to install_cab_package('with_attributes').with(version: '1.2.3')
|
21
|
+
expect(chef_run).to_not install_cab_package('with_attributes').with(version: '1.2.4')
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
it 'installs a cab_package when specifying the identity attribute' do
|
25
|
+
expect(chef_run).to install_cab_package('identity_attribute')
|
26
|
+
end
|
25
27
|
end
|
26
28
|
end
|
@@ -1,22 +1,24 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
if defined?(Chef::Resource::CabPackage)
|
4
|
+
describe 'cab_package::remove' do
|
5
|
+
let(:chef_run) do
|
6
|
+
ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
|
7
|
+
.converge(described_recipe)
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
it 'removes a cab_package with an explicit action' do
|
11
|
+
expect(chef_run).to remove_cab_package('explicit_action')
|
12
|
+
expect(chef_run).to_not remove_cab_package('not_explicit_action')
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
it 'removes a cab_package with attributes' do
|
16
|
+
expect(chef_run).to remove_cab_package('with_attributes').with(version: '1.2.3')
|
17
|
+
expect(chef_run).to_not remove_cab_package('with_attributes').with(version: '1.2.4')
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
it 'removes a cab_package when specifying the identity attribute' do
|
21
|
+
expect(chef_run).to remove_cab_package('identity_attribute')
|
22
|
+
end
|
21
23
|
end
|
22
24
|
end
|
@@ -1,23 +1 @@
|
|
1
|
-
|
2
|
-
ChefSpec.define_matcher :custom_matcher_thing
|
3
|
-
|
4
|
-
#
|
5
|
-
# When defining a custom LWRP matcher, you should always add some
|
6
|
-
# documentation indicating how to use the custom matcher.
|
7
|
-
#
|
8
|
-
# @example This is an example
|
9
|
-
# expect(chef_run).to install_custom_matcher_thing('foo')
|
10
|
-
#
|
11
|
-
# @param [String] resource_name
|
12
|
-
# the resource name
|
13
|
-
#
|
14
|
-
# @return [ChefSpec::Matchers::ResourceMatcher]
|
15
|
-
#
|
16
|
-
def install_custom_matcher_thing(resource_name)
|
17
|
-
ChefSpec::Matchers::ResourceMatcher.new(:custom_matcher_thing, :install, resource_name)
|
18
|
-
end
|
19
|
-
|
20
|
-
def remove_custom_matcher_thing(resource_name)
|
21
|
-
ChefSpec::Matchers::ResourceMatcher.new(:custom_matcher_thing, :remove, resource_name)
|
22
|
-
end
|
23
|
-
end
|
1
|
+
# this file is no longer required
|
@@ -1,26 +1,28 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
if defined?(Chef::Resource::DnfPackage)
|
4
|
+
describe 'dnf_package::install' do
|
5
|
+
let(:chef_run) do
|
6
|
+
ChefSpec::ServerRunner.new(platform: 'fedora', version: '25')
|
7
|
+
.converge(described_recipe)
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
it 'installs a dnf_package with the default action' do
|
11
|
+
expect(chef_run).to install_dnf_package('default_action')
|
12
|
+
expect(chef_run).to_not install_dnf_package('not_default_action')
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
it 'installs a dnf_package with an explicit action' do
|
16
|
+
expect(chef_run).to install_dnf_package('explicit_action')
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
it 'installs a dnf_package with attributes' do
|
20
|
+
expect(chef_run).to install_dnf_package('with_attributes').with(version: '1.0.0')
|
21
|
+
expect(chef_run).to_not install_dnf_package('with_attributes').with(version: '1.2.3')
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
it 'installs a dnf_package when specifying the identity attribute' do
|
25
|
+
expect(chef_run).to install_dnf_package('identity_attribute')
|
26
|
+
end
|
25
27
|
end
|
26
28
|
end
|
@@ -1,22 +1,24 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
if defined?(Chef::Resource::DnfPackage)
|
4
|
+
describe 'dnf_package::purge' do
|
5
|
+
let(:chef_run) do
|
6
|
+
ChefSpec::ServerRunner.new(platform: 'fedora', version: '25')
|
7
|
+
.converge(described_recipe)
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
it 'purges a dnf_package with an explicit action' do
|
11
|
+
expect(chef_run).to purge_dnf_package('explicit_action')
|
12
|
+
expect(chef_run).to_not purge_dnf_package('not_explicit_action')
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
it 'purges a dnf_package with attributes' do
|
16
|
+
expect(chef_run).to purge_dnf_package('with_attributes').with(version: '1.0.0')
|
17
|
+
expect(chef_run).to_not purge_dnf_package('with_attributes').with(version: '1.2.3')
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
it 'purges a dnf_package when specifying the identity attribute' do
|
21
|
+
expect(chef_run).to purge_dnf_package('identity_attribute')
|
22
|
+
end
|
21
23
|
end
|
22
24
|
end
|
@@ -1,22 +1,24 @@
|
|
1
1
|
require 'chefspec'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
if defined?(Chef::Resource::DnfPackage)
|
4
|
+
describe 'dnf_package::remove' do
|
5
|
+
let(:chef_run) do
|
6
|
+
ChefSpec::ServerRunner.new(platform: 'fedora', version: '25')
|
7
|
+
.converge(described_recipe)
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
it 'removes a dnf_package with an explicit action' do
|
11
|
+
expect(chef_run).to remove_dnf_package('explicit_action')
|
12
|
+
expect(chef_run).to_not remove_dnf_package('not_explicit_action')
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
it 'removes a dnf_package with attributes' do
|
16
|
+
expect(chef_run).to remove_dnf_package('with_attributes').with(version: '1.0.0')
|
17
|
+
expect(chef_run).to_not remove_dnf_package('with_attributes').with(version: '1.2.3')
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
it 'removes a dnf_package when specifying the identity attribute' do
|
21
|
+
expect(chef_run).to remove_dnf_package('identity_attribute')
|
22
|
+
end
|
21
23
|
end
|
22
24
|
end
|