chefspec 7.1.1 → 7.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +20 -12
  3. data/CHANGELOG.md +12 -8
  4. data/CONTRIBUTING.md +3 -3
  5. data/Gemfile +1 -0
  6. data/ISSUES.md +1 -1
  7. data/README.md +19 -26
  8. data/examples/apt_package/recipes/lock.rb +13 -0
  9. data/examples/apt_package/recipes/unlock.rb +13 -0
  10. data/examples/apt_package/spec/lock_spec.rb +22 -0
  11. data/examples/apt_package/spec/unlock_spec.rb +22 -0
  12. data/examples/log/recipes/write.rb +3 -4
  13. data/examples/log/spec/write_spec.rb +4 -4
  14. data/examples/openbsd_package/spec/install_spec.rb +1 -1
  15. data/examples/openbsd_package/spec/purge_spec.rb +1 -1
  16. data/examples/openbsd_package/spec/remove_spec.rb +1 -1
  17. data/examples/openbsd_package/spec/upgrade_spec.rb +1 -1
  18. data/examples/package/recipes/lock.rb +17 -0
  19. data/examples/package/recipes/unlock.rb +17 -0
  20. data/examples/package/spec/lock_spec.rb +23 -0
  21. data/examples/package/spec/unlock_spec.rb +23 -0
  22. data/examples/pacman_package/spec/install_spec.rb +1 -1
  23. data/examples/pacman_package/spec/purge_spec.rb +1 -1
  24. data/examples/pacman_package/spec/remove_spec.rb +1 -1
  25. data/examples/pacman_package/spec/upgrade_spec.rb +1 -1
  26. data/examples/paludis_package/spec/install_spec.rb +1 -1
  27. data/examples/paludis_package/spec/purge_spec.rb +1 -1
  28. data/examples/paludis_package/spec/remove_spec.rb +1 -1
  29. data/examples/paludis_package/spec/upgrade_spec.rb +1 -1
  30. data/examples/portage_package/spec/install_spec.rb +1 -1
  31. data/examples/portage_package/spec/purge_spec.rb +1 -1
  32. data/examples/portage_package/spec/remove_spec.rb +1 -1
  33. data/examples/portage_package/spec/upgrade_spec.rb +1 -1
  34. data/examples/yum_package/recipes/lock.rb +13 -0
  35. data/examples/yum_package/recipes/unlock.rb +13 -0
  36. data/examples/yum_package/spec/lock_spec.rb +22 -0
  37. data/examples/yum_package/spec/unlock_spec.rb +22 -0
  38. data/examples/zypper_package/recipes/lock.rb +13 -0
  39. data/examples/zypper_package/recipes/unlock.rb +13 -0
  40. data/examples/zypper_package/spec/lock_spec.rb +19 -0
  41. data/examples/zypper_package/spec/unlock_spec.rb +19 -0
  42. data/lib/chefspec/coverage.rb +1 -0
  43. data/lib/chefspec/extensions.rb +1 -0
  44. data/lib/chefspec/extensions/chef/cookbook/gem_installer.rb +35 -0
  45. data/lib/chefspec/version.rb +1 -1
  46. data/templates/errors/may_need_to_specify_platform.erb +2 -2
  47. metadata +20 -11
  48. data/examples/deploy/recipes/deploy.rb +0 -10
  49. data/examples/deploy/recipes/force_deploy.rb +0 -9
  50. data/examples/deploy/recipes/rollback.rb +0 -9
  51. data/examples/deploy/spec/deploy_spec.rb +0 -15
  52. data/examples/deploy/spec/force_deploy_spec.rb +0 -15
  53. data/examples/deploy/spec/rollback_spec.rb +0 -15
  54. data/examples/erl_call/recipes/run.rb +0 -13
  55. data/examples/erl_call/spec/run_spec.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f005ab1291a2ded9f315a6418b743ef40d1922ef
4
- data.tar.gz: 64956c585525980326afb3d4989e89fbbcdaad85
2
+ SHA256:
3
+ metadata.gz: 0bf6f8f05122f340d69055e92becab58c98f2b558415eef849044bcfcf1c845f
4
+ data.tar.gz: d50a819fc4bfeead4ac9b4ab37811a247c41da401f3952e540d631353d7a6e42
5
5
  SHA512:
6
- metadata.gz: f4d999d60cdbc5c28d6a197b0ff005cfe9fe90ba5118ec4688d739c6464f409eabced2e394872d310224218640daa1316f9df494f3608fbeff428460a6d991ac
7
- data.tar.gz: 3d56a13c1b8523067e4a401ae1601b5b97461fc282d993c4a8eeef1a2e15cd9571c1752173d11a74c5e17215689b354e1115a51dd7bf1535348b7f96c49dabaf
6
+ metadata.gz: a0a4f05dcd658a28851c9b9797986cc7d2a37141faa6e32ed5bcbb9b14fc97ad22967f925cadd11da1bd80918e6d6053a38d5e482ef6075600f2c53b76616fa2
7
+ data.tar.gz: 7e34c8e1d8366bc5217c5d5329d1411b973e47f088eade93ea4cfd542bf8cef9020e03458fed0088a3f281238cc3767136560e920ef827144ea073f7b80a3ec8
@@ -17,16 +17,24 @@ bundler_args: --jobs 7 --retry 3
17
17
  matrix:
18
18
  include:
19
19
  - env: CHEF_VERSION=master
20
- rvm: 2.4.1
20
+ rvm: 2.5.0
21
+ - env: CHEF_VERSION=13.8.3
22
+ rvm: 2.4.3
23
+ - env: CHEF_VERSION=13.7.16
24
+ rvm: 2.4.3
25
+ - env: CHEF_VERSION=13.6.4
26
+ rvm: 2.4.2
27
+ - env: CHEF_VERSION=13.5.3
28
+ rvm: 2.4.2
29
+ - env: CHEF_VERSION=13.4.24
30
+ rvm: 2.4.2
31
+ - env: CHEF_VERSION=13.3.42
32
+ rvm: 2.4.2
33
+ - env: CHEF_VERSION=13.2.20
34
+ rvm: 2.4.2
35
+ - env: CHEF_VERSION=13.1.31
36
+ rvm: 2.4.2
21
37
  - env: CHEF_VERSION=13.0.118
22
- rvm: 2.4.1
23
- - env: CHEF_VERSION=12.18.31
24
- rvm: 2.3.1
25
- - env: CHEF_VERSION=12.17.44
26
- rvm: 2.3.1
27
- - env: CHEF_VERSION=12.16.42
28
- rvm: 2.3.1
29
- - env: CHEF_VERSION=12.15.19
30
- rvm: 2.3.1
31
- - env: CHEF_VERSION=12.14.89
32
- rvm: 2.3.1
38
+ rvm: 2.4.2
39
+ - env: CHEF_VERSION=12.21.31
40
+ rvm: 2.3.5
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG for ChefSpec
2
2
 
3
+ ## 7.1.2 (March, 6, 2018)
4
+
5
+ This release deprecated the spec coverage feature, which will be removed in a future release. In general this feature leads to users writing unnecessary and generally useless specs in an attempt to reach 100% spec coverage. ChefSpec is useful for testing the parts of your cookbook that include logic, but if a particular resource has no logic behind it, then there's little value in testing. We shouldn't provide a mechanism that encourages writing unnecessary specs that give a false assurance test coverage.
6
+
3
7
  ## 7.1.1 (November 28, 2017)
4
8
 
5
9
  - Better support for matching action :nothing in resources
@@ -31,7 +35,7 @@
31
35
 
32
36
  ## 6.1.0 (March 9, 2017)
33
37
 
34
- - Loosen the Fauxhai dependency to allow Fauxhai 4.0 This deprecates a large number of Ohai mocks for end of life platforms. See <https://github.com/customink/fauxhai/blob/master/PLATFORMS.md> for the current list of platforms supported by Fauxhai
38
+ - Loosen the Fauxhai dependency to allow Fauxhai 4.0 This deprecates a large number of Ohai mocks for end of life platforms. See <https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md> for the current list of platforms supported by Fauxhai
35
39
  - SoloRunner defaults to use_policyfile == false now
36
40
 
37
41
  ## 6.0.1 (February 24, 2017)
@@ -384,7 +388,7 @@ IMPROVEMENTS:
384
388
 
385
389
  BUG FIXES:
386
390
 
387
- - Require i18n 0.6.9 or higher (but less than 1.0.0) ([#289](https://github.com/sethvargo/chefspec/issues/245))
391
+ - Require i18n 0.6.9 or higher (but less than 1.0.0) ([#289](https://github.com/chefspec/chefspec/issues/245))
388
392
 
389
393
  ## 3.1.1 (December 29, 2013)
390
394
 
@@ -437,12 +441,12 @@ IMPROVEMENTS:
437
441
 
438
442
  BUG FIXES:
439
443
 
440
- - Fix an issue where LWRPs were not properly stepped into when `use_inline_resources` was specified ([#244](https://github.com/sethvargo/chefspec/issues/244))
441
- - Coerce `render_file` `@expected_content` to a string before asserting if content is included ([#243](https://github.com/sethvargo/chefspec/issues/243))
444
+ - Fix an issue where LWRPs were not properly stepped into when `use_inline_resources` was specified ([#244](https://github.com/chefspec/chefspec/issues/244))
445
+ - Coerce `render_file` `@expected_content` to a string before asserting if content is included ([#243](https://github.com/chefspec/chefspec/issues/243))
442
446
 
443
447
  IMPROVEMENTS:
444
448
 
445
- - Miscellaneous documentation fixes and additions ([#245](https://github.com/sethvargo/chefspec/issues/245), [#241](https://github.com/sethvargo/chefspec/issues/241), [#238](https://github.com/sethvargo/chefspec/issues/238))
449
+ - Miscellaneous documentation fixes and additions ([#245](https://github.com/chefspec/chefspec/issues/245), [#241](https://github.com/chefspec/chefspec/issues/241), [#238](https://github.com/chefspec/chefspec/issues/238))
446
450
 
447
451
  ## 3.0.0 (October 20, 2013)
448
452
 
@@ -661,7 +665,7 @@ BUG FIXES:
661
665
 
662
666
  FEATURES:
663
667
 
664
- - LWRP support added (#40). You can now make assertions about the resources created by a provider by telling chefspec to [step into a provider implementation](https://github.com/sethvargo/chefspec/tree/v0.8.0#writing-examples-for-lwrps). Thanks to Augusto Becciu for implementing this feature.
668
+ - LWRP support added (#40). You can now make assertions about the resources created by a provider by telling chefspec to [step into a provider implementation](https://github.com/chefspec/chefspec/tree/v0.8.0#writing-examples-for-lwrps). Thanks to Augusto Becciu for implementing this feature.
665
669
  - Updated for compatibility with Chef 10.14\. Thanks Augusto Becciu.
666
670
 
667
671
  BUG FIXES:
@@ -724,8 +728,8 @@ BUG FIXES:
724
728
 
725
729
  FEATURES:
726
730
 
727
- - [Added new matcher](https://www.relishapp.com/sethvargo/chefspec/docs/write-examples-for-templates) `create_file_with_content` for verifying Chef `template` resource generated content.
728
- - [Knife plugin](https://www.relishapp.com/sethvargo/chefspec/docs/generate-placeholder-examples) added to generate placeholder examples.
731
+ - [Added new matcher](https://www.relishapp.com/chefspec/chefspec/docs/write-examples-for-templates) `create_file_with_content` for verifying Chef `template` resource generated content.
732
+ - [Knife plugin](https://www.relishapp.com/chefspec/chefspec/docs/generate-placeholder-examples) added to generate placeholder examples.
729
733
 
730
734
  ## 0.2.1 (September 21, 2011)
731
735
 
@@ -12,14 +12,14 @@ Also, please be patient as not all items will be tested or reviewed immediately
12
12
 
13
13
  Please be receptive and responsive to feedback about your additions or changes. The core team and/or other community members may make suggestions or ask questions about your change. This is part of the review process, and helps everyone to understand what is happening, why it is happening, and potentially optimizes your code.
14
14
 
15
- If you're looking to contribute but aren't sure where to start, check out the [open issues](https://github.com/sethvargo/chefspec/issues?state=open).
15
+ If you're looking to contribute but aren't sure where to start, check out the [open issues](https://github.com/chefspec/chefspec/issues?state=open).
16
16
 
17
17
 
18
18
  Will Not Merge
19
19
  --------------
20
20
  This section details, specifically, Pull Requests or features that will _not_ be merged:
21
21
 
22
- 1. Matchers for non-Chef core resources. ChefSpec 3.0 introduced a way for cookbook maintainers to [package matchers _with_ their cookbooks](https://github.com/sethvargo/chefspec#packaging-custom-matchers) at distribution time.
22
+ 1. Matchers for non-Chef core resources. ChefSpec 3.0 introduced a way for cookbook maintainers to [package matchers _with_ their cookbooks](https://github.com/chefspec/chefspec#packaging-custom-matchers) at distribution time.
23
23
  2. New features without accompanying unit tests, cucumber tests, and documentation.
24
24
 
25
25
 
@@ -39,7 +39,7 @@ Whether your pull request is a bug fix or introduces new classes or methods to t
39
39
 
40
40
  We understand that not all users submitting pull requests will be proficient with RSpec. The maintainers and community as a whole are a helpful group and can help you with writing tests. The [Better Specs](http://betterspecs.org/) site should provide some helpful resources to get you started.
41
41
 
42
- ChefSpec is tested on [Travis CI](https://travis-ci.org/sethvargo/chefspec) against multiple Chef Versions and Ruby Versions. **Your patches must work for all Chef and Ruby Versions on Travis.** This is in an effort to maintain backward compatibility as long as possible. For more information on which Chef and Ruby versions to support, checkout the [`.travis.yml`](https://github.com/sethvargo/chefspec/blob/master/.travis.yml) file.
42
+ ChefSpec is tested on [Travis CI](https://travis-ci.org/chefspec/chefspec) against multiple Chef Versions and Ruby Versions. **Your patches must work for all Chef and Ruby Versions on Travis.** This is in an effort to maintain backward compatibility as long as possible. For more information on which Chef and Ruby versions to support, checkout the [`.travis.yml`](https://github.com/chefspec/chefspec/blob/master/.travis.yml) file.
43
43
 
44
44
 
45
45
  Documentation
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ source 'https://rubygems.org'
4
4
  if ENV['CHEF_VERSION']
5
5
  if ENV['CHEF_VERSION'] == "master"
6
6
  gem 'chef', git: "https://github.com/chef/chef"
7
+ gem 'ohai', git: "https://github.com/chef/ohai"
7
8
  else
8
9
  gem 'chef', ENV['CHEF_VERSION']
9
10
  end
data/ISSUES.md CHANGED
@@ -38,4 +38,4 @@ Here's a snippet you can copy-paste into the issue and fill out:
38
38
  ```
39
39
  ```
40
40
 
41
- [Create a ticket](https://github.com/sethvargo/chefspec/issues/new) describing your problem and include the information above.
41
+ [Create a ticket](https://github.com/chefspec/chefspec/issues/new) describing your problem and include the information above.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ChefSpec
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/chefspec.svg)](https://badge.fury.io/rb/chefspec) [![Build Status](https://travis-ci.org/sethvargo/chefspec.svg?branch=master)](https://travis-ci.org/sethvargo/chefspec)
3
+ [![Gem Version](https://badge.fury.io/rb/chefspec.svg)](https://badge.fury.io/rb/chefspec) [![Build Status](https://travis-ci.org/chefspec/chefspec.svg?branch=master)](https://travis-ci.org/chefspec/chefspec)
4
4
 
5
5
  ChefSpec is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers.
6
6
 
@@ -13,7 +13,7 @@ ChefSpec runs your cookbook(s) locally with Chef Solo without actually convergin
13
13
 
14
14
  - **ChefSpec requires Ruby 2.2 or later and Chef 12.14.89 or later!**
15
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!**
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).**
16
+ - **Each resource matcher is self-documented using [Yard](http://rubydoc.info/github/chefspec/chefspec) and has a corresponding test recipe in the [examples directory](https://github.com/chefspec/chefspec/tree/master/examples).**
17
17
 
18
18
  ## Notes on Compatibility with Chef Versions
19
19
 
@@ -21,7 +21,6 @@ ChefSpec runs your cookbook(s) locally with Chef Solo without actually convergin
21
21
 
22
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:
23
23
 
24
-
25
24
  ## Writing a Cookbook Example
26
25
 
27
26
  If you want `knife` to automatically generate spec stubs for you, install [knife-spec](https://github.com/sethvargo/knife-spec).
@@ -50,7 +49,7 @@ Let's step through this file to see what is happening:
50
49
 
51
50
  1. At the top of the spec file we require the chefspec gem. This is required so that our custom matchers are loaded. In larger projects, it is common practice to create a file named "spec_helper.rb" and include ChefSpec and perform other setup tasks in that file.
52
51
  2. The `describe` keyword is part of RSpec and indicates that everything nested beneath is describing the `example::default` recipe. The convention is to have a separate spec for each recipe in your cookbook.
53
- 3. The `let` block on creates the `ChefSpec:SoloRunner` with mocked Ohai data for Ubuntu 16.04 from [Fauxhai](https://github.com/customink/fauxhai). It then does a fake Chef run with the run_list of `example::default`. Any subsequent examples can then refer to `chef_run` in order to make assertions about the resources that were created during the mock converge.
52
+ 3. The `let` block on creates the `ChefSpec:SoloRunner` with mocked Ohai data for Ubuntu 16.04 from [Fauxhai](https://github.com/chefspec/fauxhai). It then does a fake Chef run with the run_list of `example::default`. Any subsequent examples can then refer to `chef_run` in order to make assertions about the resources that were created during the mock converge.
54
53
  4. The `described_recipe` macro is a ChefSpec helper method that infers the recipe from the `describe` block. Alternatively you could specify the recipe directly.
55
54
  5. The `it` block is an example specifying that the `foo` package is installed. Normally you will have multiple `it` blocks per recipe, each making a single assertion.
56
55
 
@@ -109,7 +108,7 @@ ChefSpec::SoloRunner.new(file_cache_path: Chef::Config[:file_cache_path])
109
108
  ChefSpec::SoloRunner.new(log_level: :debug).converge(described_recipe)
110
109
  ```
111
110
 
112
- **NOTE** You do not _need_ to specify a platform and version to use ChefSpec. However, some cookbooks may rely on [Ohai](http://github.com/chef/ohai) data that ChefSpec cannot not automatically generate. Specifying the `platform` and `version` keys instructs ChefSpec to load stubbed Ohai attributes from another platform using [fauxhai](https://github.com/customink/fauxhai). See the [PLATFORMS.md file](https://github.com/customink/fauxhai/blob/master/PLATFORMS.md) in the Fauxhai repo for a complete list of platforms and versions for use with ChefSpec.
111
+ **NOTE** You do not _need_ to specify a platform and version to use ChefSpec. However, some cookbooks may rely on [Ohai](http://github.com/chef/ohai) data that ChefSpec cannot not automatically generate. Specifying the `platform` and `version` keys instructs ChefSpec to load stubbed Ohai attributes from another platform using [fauxhai](https://github.com/chefspec/fauxhai). See the [PLATFORMS.md file](https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md) in the Fauxhai repo for a complete list of platforms and versions for use with ChefSpec.
113
112
 
114
113
  ### ChefZero Server
115
114
 
@@ -276,9 +275,9 @@ end
276
275
 
277
276
  This test is asserting that the Chef run will have a _group_ resource with the name _docker_, an action of _modify_, and an attributes hash including `{ members: ['vagrant'] }`.
278
277
 
279
- ChefSpec includes matchers for all of Chef's core resources using the above schema. Each resource matcher is self-documented using [Yard](http://rubydoc.info/github/sethvargo/chefspec) and has a corresponding cucumber test from the [examples directory](https://github.com/sethvargo/chefspec/tree/master/examples).
278
+ ChefSpec includes matchers for all of Chef's core resources using the above schema. Each resource matcher is self-documented using [Yard](http://rubydoc.info/github/chefspec/chefspec) and has a corresponding cucumber test from the [examples directory](https://github.com/chefspec/chefspec/tree/master/examples).
280
279
 
281
- Additionally, ChefSpec includes the following helpful matchers. They are also [documented in Yard](http://rubydoc.info/github/sethvargo/chefspec), but they are included here because they do not follow the "general pattern".
280
+ Additionally, ChefSpec includes the following helpful matchers. They are also [documented in Yard](http://rubydoc.info/github/chefspec/chefspec), but they are included here because they do not follow the "general pattern".
282
281
 
283
282
  ### include_recipe
284
283
 
@@ -373,7 +372,7 @@ resource = chef_run.execute('install')
373
372
  expect(resource).to do_nothing
374
373
  ```
375
374
 
376
- **For more complex examples, please see the [examples directory](https://github.com/sethvargo/chefspec/tree/master/examples) or the [Yard documentation](http://rubydoc.info/github/sethvargo/chefspec).**
375
+ **For more complex examples, please see the [examples directory](https://github.com/chefspec/chefspec/tree/master/examples) or the [Yard documentation](http://rubydoc.info/github/chefspec/chefspec).**
377
376
 
378
377
  ## Specifying Node Information
379
378
 
@@ -393,7 +392,6 @@ describe 'example::default' do
393
392
  end
394
393
  ```
395
394
 
396
-
397
395
  ### Setting Node Attributes
398
396
 
399
397
  Node attributes can also be set inside the initializer block:
@@ -410,7 +408,7 @@ end
410
408
 
411
409
  ### Automatic attributes
412
410
 
413
- ChefSpec provides mocked automatic Ohai data using [fauxhai](https://github.com/customink/fauxhai). To mock out `automatic` attributes, you must use the `automatic` key:
411
+ ChefSpec provides mocked automatic Ohai data using [fauxhai](https://github.com/chefspec/fauxhai). To mock out `automatic` attributes, you must use the `automatic` key:
414
412
 
415
413
  ```ruby
416
414
  describe 'example::default' do
@@ -723,10 +721,7 @@ end
723
721
 
724
722
  ### Ruby libraries (File, FileUtils, etc)
725
723
 
726
- 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
727
- 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
728
- 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
729
- 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.
724
+ 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 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 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 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.
730
725
 
731
726
  ```ruby
732
727
  describe 'example::default' do
@@ -745,12 +740,12 @@ describe 'example::default' do
745
740
  end
746
741
  ```
747
742
 
748
- 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
749
- 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
750
- or expectation down to only the arguments which your code uses.
743
+ 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 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 or expectation down to only the arguments which your code uses.
751
744
 
752
745
  ## Reporting
753
746
 
747
+ **NOTE: The coverage reporting feature is deprecated and will be removed in a future version. This documentation exists only for reference purposes.**
748
+
754
749
  ChefSpec can generate a report of resources read over resources tested.
755
750
 
756
751
  To generate the coverage report, add the following to your `spec_helper.rb` before you require any "Chef" code:
@@ -854,8 +849,7 @@ ChefSpec::Coverage.start! do
854
849
  end
855
850
  ```
856
851
 
857
- If you would like to add alternative reporting for the Coverage.report! ouput, you can supply your own by calling add_output in the `ChefSepc::Coverage` block:
858
- Note the reportOutput has the following items in it: total, touched, coverage and collections of untouched_resources and all_resources
852
+ If you would like to add alternative reporting for the Coverage.report! ouput, you can supply your own by calling add_output in the `ChefSepc::Coverage` block: Note the reportOutput has the following items in it: total, touched, coverage and collections of untouched_resources and all_resources
859
853
 
860
854
  ```ruby
861
855
  ChefSpec::Coverage.start! do
@@ -870,6 +864,7 @@ ChefSpec::Coverage.start! do
870
864
  end
871
865
  end
872
866
  ```
867
+
873
868
  Note the above example outputs the raw data without applying formatting.
874
869
 
875
870
  ## Mocking Out Environments
@@ -936,13 +931,11 @@ end
936
931
 
937
932
  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.
938
933
 
939
- 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`
940
- matcher.
934
+ 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` matcher.
941
935
 
942
936
  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`.
943
937
 
944
- 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
945
- not follow the automatically generated pattern.
938
+ 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 not follow the automatically generated pattern.
946
939
 
947
940
  ## Packaging Custom Matchers
948
941
 
@@ -1234,7 +1227,7 @@ let(:chef_run) { ChefSpec::SoloRunner.new }
1234
1227
  cached(:chef_run) { ChefSpec::SoloRunner.new }
1235
1228
  ```
1236
1229
 
1237
- Everything else should work the same. Be advised, as the method name suggests, this will cache the results of your Chef Client Run for the **entire RSpec example**. This makes stubbing more of a challenge, since the node is already converged. For more information, please see [Juri Timošin's blog post on faster specs](http://dracoater.blogspot.com/2013/12/testing-chef-cookbooks-part-25-speeding.html) as well as the discussion in [#275](https://github.com/sethvargo/chefspec/issues/275).
1230
+ Everything else should work the same. Be advised, as the method name suggests, this will cache the results of your Chef Client Run for the **entire RSpec example**. This makes stubbing more of a challenge, since the node is already converged. For more information, please see [Juri Timošin's blog post on faster specs](http://dracoater.blogspot.com/2013/12/testing-chef-cookbooks-part-25-speeding.html) as well as the discussion in [#275](https://github.com/chefspec/chefspec/issues/275).
1238
1231
 
1239
1232
  ## Media & Third-party Tutorials
1240
1233
 
@@ -1274,8 +1267,8 @@ Everything else should work the same. Be advised, as the method name suggests, t
1274
1267
 
1275
1268
  ChefSpec is on [Travis CI][travis] which tests against multiple Chef and Ruby versions.
1276
1269
 
1277
- If you are contributing, please see the [Contributing Guidelines](https://github.com/sethvargo/chefspec/blob/master/CONTRIBUTING.md) for more information.
1270
+ If you are contributing, please see the [Contributing Guidelines](https://github.com/chefspec/chefspec/blob/master/CONTRIBUTING.md) for more information.
1278
1271
 
1279
1272
  ## License
1280
1273
 
1281
- MIT - see the accompanying [LICENSE](https://github.com/sethvargo/chefspec/blob/master/LICENSE) file for details.
1274
+ MIT - see the accompanying [LICENSE](https://github.com/chefspec/chefspec/blob/master/LICENSE) file for details.
@@ -0,0 +1,13 @@
1
+ apt_package 'explicit_action' do
2
+ action :lock
3
+ end
4
+
5
+ apt_package 'with_attributes' do
6
+ version '1.0.0'
7
+ action :lock
8
+ end
9
+
10
+ apt_package 'specifying the identity attribute' do
11
+ package_name 'identity_attribute'
12
+ action :lock
13
+ end
@@ -0,0 +1,13 @@
1
+ apt_package 'explicit_action' do
2
+ action :unlock
3
+ end
4
+
5
+ apt_package 'with_attributes' do
6
+ version '1.0.0'
7
+ action :unlock
8
+ end
9
+
10
+ apt_package 'specifying the identity attribute' do
11
+ package_name 'identity_attribute'
12
+ action :unlock
13
+ end
@@ -0,0 +1,22 @@
1
+ require 'chefspec'
2
+
3
+ describe 'apt_package::lock' do
4
+ let(:chef_run) do
5
+ ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04')
6
+ .converge(described_recipe)
7
+ end
8
+
9
+ it 'locks a apt_package with an explicit action' do
10
+ expect(chef_run).to lock_apt_package('explicit_action')
11
+ expect(chef_run).to_not lock_apt_package('not_explicit_action')
12
+ end
13
+
14
+ it 'locks a apt_package with attributes' do
15
+ expect(chef_run).to lock_apt_package('with_attributes').with(version: '1.0.0')
16
+ expect(chef_run).to_not lock_apt_package('with_attributes').with(version: '1.2.3')
17
+ end
18
+
19
+ it 'locks a apt_package when specifying the identity attribute' do
20
+ expect(chef_run).to lock_apt_package('identity_attribute')
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require 'chefspec'
2
+
3
+ describe 'apt_package::unlock' do
4
+ let(:chef_run) do
5
+ ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04')
6
+ .converge(described_recipe)
7
+ end
8
+
9
+ it 'unlocks a apt_package with an explicit action' do
10
+ expect(chef_run).to unlock_apt_package('explicit_action')
11
+ expect(chef_run).to_not unlock_apt_package('not_explicit_action')
12
+ end
13
+
14
+ it 'unlocks a apt_package with attributes' do
15
+ expect(chef_run).to unlock_apt_package('with_attributes').with(version: '1.0.0')
16
+ expect(chef_run).to_not unlock_apt_package('with_attributes').with(version: '1.2.3')
17
+ end
18
+
19
+ it 'unlocks a apt_package when specifying the identity attribute' do
20
+ expect(chef_run).to unlock_apt_package('identity_attribute')
21
+ end
22
+ end
@@ -1,9 +1,8 @@
1
1
  log 'default_action'
2
2
 
3
- # CHEF-4561
4
- # log 'explicit_action' do
5
- # action :write
6
- # end
3
+ log 'explicit_action' do
4
+ action :write
5
+ end
7
6
 
8
7
  log 'with_attributes' do
9
8
  level :debug
@@ -8,10 +8,9 @@ describe 'log::write' do
8
8
  expect(chef_run).to_not write_log('not_default_action')
9
9
  end
10
10
 
11
- # CHEF-4561
12
- # it 'writes a log with an explicit action' do
13
- # expect(chef_run).to write_log('explicit_action')
14
- # end
11
+ it 'writes a log with an explicit action' do
12
+ expect(chef_run).to write_log('explicit_action')
13
+ end
15
14
 
16
15
  it 'writes a log with attributes' do
17
16
  expect(chef_run).to write_log('with_attributes').with(level: :debug)
@@ -19,6 +18,7 @@ describe 'log::write' do
19
18
  end
20
19
 
21
20
  it 'writes a log when specifying the identity attribute' do
21
+ skip if Chef::VERSION == "13.7.16" # this is broken in 13.7.16
22
22
  expect(chef_run).to write_log('identity_attribute')
23
23
  end
24
24
  end
@@ -1,7 +1,7 @@
1
1
  require 'chefspec'
2
2
 
3
3
  describe 'openbsd_package::install' do
4
- let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'openbsd', version: '5.4').converge(described_recipe) }
4
+ let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'openbsd', version: '6.2').converge(described_recipe) }
5
5
 
6
6
  it 'installs a openbsd_package with the default action' do
7
7
  expect(chef_run).to install_openbsd_package('default_action')
@@ -1,7 +1,7 @@
1
1
  require 'chefspec'
2
2
 
3
3
  describe 'openbsd_package::purge' do
4
- let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'openbsd', version: '5.4').converge(described_recipe) }
4
+ let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'openbsd', version: '6.2').converge(described_recipe) }
5
5
 
6
6
  it 'purges a openbsd_package with an explicit action' do
7
7
  expect(chef_run).to purge_openbsd_package('explicit_action')
@@ -1,7 +1,7 @@
1
1
  require 'chefspec'
2
2
 
3
3
  describe 'openbsd_package::remove' do
4
- let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'openbsd', version: '5.4').converge(described_recipe) }
4
+ let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'openbsd', version: '6.2').converge(described_recipe) }
5
5
 
6
6
  it 'removes a openbsd_package with an explicit action' do
7
7
  expect(chef_run).to remove_openbsd_package('explicit_action')
@@ -1,7 +1,7 @@
1
1
  require 'chefspec'
2
2
 
3
3
  describe 'openbsd_package::upgrade' do
4
- let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'openbsd', version: '5.4').converge(described_recipe) }
4
+ let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'openbsd', version: '6.2').converge(described_recipe) }
5
5
 
6
6
  it 'upgrades a openbsd_package with an explicit action' do
7
7
  expect(chef_run).to upgrade_openbsd_package('explicit_action')
@@ -0,0 +1,17 @@
1
+ package 'explicit_action' do
2
+ action :lock
3
+ end
4
+
5
+ package 'with_attributes' do
6
+ version '1.0.0'
7
+ action :lock
8
+ end
9
+
10
+ package 'specifying the identity attribute' do
11
+ package_name 'identity_attribute'
12
+ action :lock
13
+ end
14
+
15
+ package %w(with array) do
16
+ action :lock
17
+ end
@@ -0,0 +1,17 @@
1
+ package 'explicit_action' do
2
+ action :unlock
3
+ end
4
+
5
+ package 'with_attributes' do
6
+ version '1.0.0'
7
+ action :unlock
8
+ end
9
+
10
+ package 'specifying the identity attribute' do
11
+ package_name 'identity_attribute'
12
+ action :unlock
13
+ end
14
+
15
+ package %w(with array) do
16
+ action :unlock
17
+ end
@@ -0,0 +1,23 @@
1
+ require 'chefspec'
2
+
3
+ describe 'package::lock' do
4
+ let(:chef_run) { ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) }
5
+
6
+ it 'locks a package with an explicit action' do
7
+ expect(chef_run).to lock_package('explicit_action')
8
+ expect(chef_run).to_not lock_package('not_explicit_action')
9
+ end
10
+
11
+ it 'locks a package with attributes' do
12
+ expect(chef_run).to lock_package('with_attributes').with(version: '1.0.0')
13
+ expect(chef_run).to_not lock_package('with_attributes').with(version: '1.2.3')
14
+ end
15
+
16
+ it 'locks a package when specifying the identity attribute' do
17
+ expect(chef_run).to lock_package('identity_attribute')
18
+ end
19
+
20
+ it 'locks all packages when given an array of names' do
21
+ expect(chef_run).to lock_package(%w(with array))
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ require 'chefspec'
2
+
3
+ describe 'package::unlock' do
4
+ let(:chef_run) { ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) }
5
+
6
+ it 'unlocks a package with an explicit action' do
7
+ expect(chef_run).to unlock_package('explicit_action')
8
+ expect(chef_run).to_not unlock_package('not_explicit_action')
9
+ end
10
+
11
+ it 'unlocks a package with attributes' do
12
+ expect(chef_run).to unlock_package('with_attributes').with(version: '1.0.0')
13
+ expect(chef_run).to_not unlock_package('with_attributes').with(version: '1.2.3')
14
+ end
15
+
16
+ it 'unlocks a package when specifying the identity attribute' do
17
+ expect(chef_run).to unlock_package('identity_attribute')
18
+ end
19
+
20
+ it 'unlocks all packages when given an array of names' do
21
+ expect(chef_run).to unlock_package(%w(with array))
22
+ end
23
+ end
@@ -2,7 +2,7 @@ require 'chefspec'
2
2
 
3
3
  describe 'pacman_package::install' do
4
4
  let(:chef_run) do
5
- ChefSpec::ServerRunner.new(platform: 'arch', version: '4.9.11-1-ARCH')
5
+ ChefSpec::ServerRunner.new(platform: 'arch', version: '4.10.13-1-ARCH')
6
6
  .converge(described_recipe)
7
7
  end
8
8
 
@@ -2,7 +2,7 @@ require 'chefspec'
2
2
 
3
3
  describe 'pacman_package::purge' do
4
4
  let(:chef_run) do
5
- ChefSpec::ServerRunner.new(platform: 'arch', version: '4.9.11-1-ARCH')
5
+ ChefSpec::ServerRunner.new(platform: 'arch', version: '4.10.13-1-ARCH')
6
6
  .converge(described_recipe)
7
7
  end
8
8
 
@@ -2,7 +2,7 @@ require 'chefspec'
2
2
 
3
3
  describe 'pacman_package::remove' do
4
4
  let(:chef_run) do
5
- ChefSpec::ServerRunner.new(platform: 'arch', version: '4.9.11-1-ARCH')
5
+ ChefSpec::ServerRunner.new(platform: 'arch', version: '4.10.13-1-ARCH')
6
6
  .converge(described_recipe)
7
7
  end
8
8
 
@@ -2,7 +2,7 @@ require 'chefspec'
2
2
 
3
3
  describe 'pacman_package::upgrade' do
4
4
  let(:chef_run) do
5
- ChefSpec::ServerRunner.new(platform: 'arch', version: '4.9.11-1-ARCH')
5
+ ChefSpec::ServerRunner.new(platform: 'arch', version: '4.10.13-1-ARCH')
6
6
  .converge(described_recipe)
7
7
  end
8
8
 
@@ -1,7 +1,7 @@
1
1
  require 'chefspec'
2
2
 
3
3
  describe 'paludis_package::install' do
4
- let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'gentoo', version: '2.2').converge(described_recipe) }
4
+ let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'gentoo', version: '4.9.6-gentoo-r1').converge(described_recipe) }
5
5
 
6
6
  it 'installs a paludis_package with the default action' do
7
7
  expect(chef_run).to install_paludis_package('default_action')
@@ -1,7 +1,7 @@
1
1
  require 'chefspec'
2
2
 
3
3
  describe 'paludis_package::purge' do
4
- let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'gentoo', version: '2.2').converge(described_recipe) }
4
+ let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'gentoo', version: '4.9.6-gentoo-r1').converge(described_recipe) }
5
5
 
6
6
  it 'purges a paludis_package with an explicit action' do
7
7
  expect(chef_run).to purge_paludis_package('explicit_action')
@@ -1,7 +1,7 @@
1
1
  require 'chefspec'
2
2
 
3
3
  describe 'paludis_package::remove' do
4
- let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'gentoo', version: '2.2').converge(described_recipe) }
4
+ let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'gentoo', version: '4.9.6-gentoo-r1').converge(described_recipe) }
5
5
 
6
6
  it 'removes a paludis_package with an explicit action' do
7
7
  expect(chef_run).to remove_paludis_package('explicit_action')
@@ -1,7 +1,7 @@
1
1
  require 'chefspec'
2
2
 
3
3
  describe 'paludis_package::upgrade' do
4
- let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'gentoo', version: '2.2').converge(described_recipe) }
4
+ let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'gentoo', version: '4.9.6-gentoo-r1').converge(described_recipe) }
5
5
 
6
6
  it 'upgrades a paludis_package with an explicit action' do
7
7
  expect(chef_run).to upgrade_paludis_package('explicit_action')
@@ -2,7 +2,7 @@ require 'chefspec'
2
2
 
3
3
  describe 'portage_package::install' do
4
4
  let(:chef_run) do
5
- ChefSpec::ServerRunner.new(platform: 'gentoo', version: '2.2')
5
+ ChefSpec::ServerRunner.new(platform: 'gentoo', version: '4.9.6-gentoo-r1')
6
6
  .converge(described_recipe)
7
7
  end
8
8
 
@@ -2,7 +2,7 @@ require 'chefspec'
2
2
 
3
3
  describe 'portage_package::purge' do
4
4
  let(:chef_run) do
5
- ChefSpec::ServerRunner.new(platform: 'gentoo', version: '2.2')
5
+ ChefSpec::ServerRunner.new(platform: 'gentoo', version: '4.9.6-gentoo-r1')
6
6
  .converge(described_recipe)
7
7
  end
8
8
 
@@ -2,7 +2,7 @@ require 'chefspec'
2
2
 
3
3
  describe 'portage_package::remove' do
4
4
  let(:chef_run) do
5
- ChefSpec::ServerRunner.new(platform: 'gentoo', version: '2.2')
5
+ ChefSpec::ServerRunner.new(platform: 'gentoo', version: '4.9.6-gentoo-r1')
6
6
  .converge(described_recipe)
7
7
  end
8
8
 
@@ -2,7 +2,7 @@ require 'chefspec'
2
2
 
3
3
  describe 'portage_package::upgrade' do
4
4
  let(:chef_run) do
5
- ChefSpec::ServerRunner.new(platform: 'gentoo', version: '2.2')
5
+ ChefSpec::ServerRunner.new(platform: 'gentoo', version: '4.9.6-gentoo-r1')
6
6
  .converge(described_recipe)
7
7
  end
8
8
 
@@ -0,0 +1,13 @@
1
+ yum_package 'explicit_action' do
2
+ action :lock
3
+ end
4
+
5
+ yum_package 'with_attributes' do
6
+ version '1.0.0'
7
+ action :lock
8
+ end
9
+
10
+ yum_package 'specifying the identity attribute' do
11
+ package_name 'identity_attribute'
12
+ action :lock
13
+ end
@@ -0,0 +1,13 @@
1
+ yum_package 'explicit_action' do
2
+ action :unlock
3
+ end
4
+
5
+ yum_package 'with_attributes' do
6
+ version '1.0.0'
7
+ action :unlock
8
+ end
9
+
10
+ yum_package 'specifying the identity attribute' do
11
+ package_name 'identity_attribute'
12
+ action :unlock
13
+ end
@@ -0,0 +1,22 @@
1
+ require 'chefspec'
2
+
3
+ describe 'yum_package::lock' do
4
+ let(:chef_run) do
5
+ ChefSpec::ServerRunner.new(platform: 'centos', version: '7.3.1611')
6
+ .converge(described_recipe)
7
+ end
8
+
9
+ it 'locks a yum_package with an explicit action' do
10
+ expect(chef_run).to lock_yum_package('explicit_action')
11
+ expect(chef_run).to_not lock_yum_package('not_explicit_action')
12
+ end
13
+
14
+ it 'locks a yum_package with attributes' do
15
+ expect(chef_run).to lock_yum_package('with_attributes').with(version: '1.0.0')
16
+ expect(chef_run).to_not lock_yum_package('with_attributes').with(version: '1.2.3')
17
+ end
18
+
19
+ it 'locks a yum_package when specifying the identity attribute' do
20
+ expect(chef_run).to lock_yum_package('identity_attribute')
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require 'chefspec'
2
+
3
+ describe 'yum_package::unlock' do
4
+ let(:chef_run) do
5
+ ChefSpec::ServerRunner.new(platform: 'centos', version: '7.3.1611')
6
+ .converge(described_recipe)
7
+ end
8
+
9
+ it 'unlocks a yum_package with an explicit action' do
10
+ expect(chef_run).to unlock_yum_package('explicit_action')
11
+ expect(chef_run).to_not unlock_yum_package('not_explicit_action')
12
+ end
13
+
14
+ it 'unlocks a yum_package with attributes' do
15
+ expect(chef_run).to unlock_yum_package('with_attributes').with(version: '1.0.0')
16
+ expect(chef_run).to_not unlock_yum_package('with_attributes').with(version: '1.2.3')
17
+ end
18
+
19
+ it 'unlocks a yum_package when specifying the identity attribute' do
20
+ expect(chef_run).to unlock_yum_package('identity_attribute')
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ zypper_package 'explicit_action' do
2
+ action :lock
3
+ end
4
+
5
+ zypper_package 'with_attributes' do
6
+ version '1.0.0'
7
+ action :lock
8
+ end
9
+
10
+ zypper_package 'specifying the identity attribute' do
11
+ package_name 'identity_attribute'
12
+ action :lock
13
+ end
@@ -0,0 +1,13 @@
1
+ zypper_package 'explicit_action' do
2
+ action :unlock
3
+ end
4
+
5
+ zypper_package 'with_attributes' do
6
+ version '1.0.0'
7
+ action :unlock
8
+ end
9
+
10
+ zypper_package 'specifying the identity attribute' do
11
+ package_name 'identity_attribute'
12
+ action :unlock
13
+ end
@@ -0,0 +1,19 @@
1
+ require 'chefspec'
2
+
3
+ describe 'zypper_package::lock' do
4
+ let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.1').converge(described_recipe) }
5
+
6
+ it 'locks a zypper_package with an explicit action' do
7
+ expect(chef_run).to lock_zypper_package('explicit_action')
8
+ expect(chef_run).to_not lock_zypper_package('not_explicit_action')
9
+ end
10
+
11
+ it 'locks a zypper_package with attributes' do
12
+ expect(chef_run).to lock_zypper_package('with_attributes').with(version: '1.0.0')
13
+ expect(chef_run).to_not lock_zypper_package('with_attributes').with(version: '1.2.3')
14
+ end
15
+
16
+ it 'locks a zypper_package when specifying the identity attribute' do
17
+ expect(chef_run).to lock_zypper_package('identity_attribute')
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ require 'chefspec'
2
+
3
+ describe 'zypper_package::unlock' do
4
+ let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'opensuse', version: '42.1').converge(described_recipe) }
5
+
6
+ it 'unlocks a zypper_package with an explicit action' do
7
+ expect(chef_run).to unlock_zypper_package('explicit_action')
8
+ expect(chef_run).to_not unlock_zypper_package('not_explicit_action')
9
+ end
10
+
11
+ it 'unlocks a zypper_package with attributes' do
12
+ expect(chef_run).to unlock_zypper_package('with_attributes').with(version: '1.0.0')
13
+ expect(chef_run).to_not unlock_zypper_package('with_attributes').with(version: '1.2.3')
14
+ end
15
+
16
+ it 'unlocks a zypper_package when specifying the identity attribute' do
17
+ expect(chef_run).to unlock_zypper_package('identity_attribute')
18
+ end
19
+ end
@@ -45,6 +45,7 @@ module ChefSpec
45
45
  # +at_exit+ handler for printing the coverage report.
46
46
  #
47
47
  def start!(&block)
48
+ warn("ChefSpec's coverage reporting is deprecated and will be removed in a future version")
48
49
  instance_eval(&block) if block
49
50
  at_exit { ChefSpec::Coverage.report! }
50
51
  end
@@ -11,6 +11,7 @@ require_relative 'extensions/chef/securable'
11
11
  require_relative 'extensions/chef/client'
12
12
  require_relative 'extensions/chef/conditional'
13
13
  require_relative 'extensions/chef/cookbook_uploader'
14
+ require_relative 'extensions/chef/cookbook/gem_installer'
14
15
  require_relative 'extensions/chef/data_query'
15
16
  require_relative 'extensions/chef/lwrp_base'
16
17
  require_relative 'extensions/chef/resource/freebsd_package'
@@ -0,0 +1,35 @@
1
+ require 'chef/cookbook/gem_installer'
2
+
3
+ class Chef
4
+ class Cookbook
5
+ class GemInstaller
6
+ # Installs the gems into the omnibus gemset.
7
+ def install
8
+ cookbook_gems = Hash.new { |h, k| h[k] = [] }
9
+
10
+ cookbook_collection.each do |cookbook_name, cookbook_version|
11
+ cookbook_version.metadata.gems.each do |args|
12
+ cookbook_gems[args.first] += args[1..-1]
13
+ end
14
+ end
15
+
16
+ events.cookbook_gem_start(cookbook_gems)
17
+ cookbook_gems.each { |gem_name, gem_requirements| locate_gem(gem_name, gem_requirements) }
18
+ events.cookbook_gem_finished
19
+ end
20
+
21
+ private
22
+
23
+ def locate_gem(gem_name, gem_requirements)
24
+ ::Gem::Specification::find_by_name(gem_name, gem_requirements)
25
+ rescue ::Gem::MissingSpecError
26
+ gem_cmd = "gem install #{gem_name} --version '#{gem_requirements.join(', ')}'"
27
+ gemfile_line = "gem '#{[gem_name, *gem_requirements].join('\', \'')}'"
28
+ warn "No matching version found for '#{gem_name}' in your gem environment.\n" \
29
+ " - if you are using ChefDK, run the following command: \"chef #{gem_cmd}\"\n" \
30
+ " - if you are using bundler, append \"#{gemfile_line}\" to your Gemfile and run \"bundle install\"\n" \
31
+ " - otherwise run: \"#{gem_cmd}\""
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module ChefSpec
2
- VERSION = '7.1.1'
2
+ VERSION = '7.1.2'
3
3
  end
@@ -17,8 +17,8 @@ by specifying the platform and version like so:
17
17
 
18
18
  You can read more information in ChefSpec's README or the Fauxhai project:
19
19
 
20
- https://github.com/sethvargo/chefspec#configuration
21
- https://github.com/customink/fauxhai
20
+ https://github.com/chefspec/chefspec#configuration
21
+ https://github.com/chefspec/fauxhai
22
22
 
23
23
  Here is the original error:
24
24
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chefspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.1
4
+ version: 7.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Crump
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-11-28 00:00:00.000000000 Z
12
+ date: 2018-03-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
@@ -80,14 +80,18 @@ files:
80
80
  - Rakefile
81
81
  - chefspec.gemspec
82
82
  - examples/apt_package/recipes/install.rb
83
+ - examples/apt_package/recipes/lock.rb
83
84
  - examples/apt_package/recipes/purge.rb
84
85
  - examples/apt_package/recipes/reconfig.rb
85
86
  - examples/apt_package/recipes/remove.rb
87
+ - examples/apt_package/recipes/unlock.rb
86
88
  - examples/apt_package/recipes/upgrade.rb
87
89
  - examples/apt_package/spec/install_spec.rb
90
+ - examples/apt_package/spec/lock_spec.rb
88
91
  - examples/apt_package/spec/purge_spec.rb
89
92
  - examples/apt_package/spec/reconfig_spec.rb
90
93
  - examples/apt_package/spec/remove_spec.rb
94
+ - examples/apt_package/spec/unlock_spec.rb
91
95
  - examples/apt_package/spec/upgrade_spec.rb
92
96
  - examples/apt_repository/recipes/add.rb
93
97
  - examples/apt_repository/recipes/remove.rb
@@ -156,12 +160,6 @@ files:
156
160
  - examples/custom_resource/recipes/default.rb
157
161
  - examples/custom_resource/resources/custom_resource.rb
158
162
  - examples/custom_resource/spec/default_spec.rb
159
- - examples/deploy/recipes/deploy.rb
160
- - examples/deploy/recipes/force_deploy.rb
161
- - examples/deploy/recipes/rollback.rb
162
- - examples/deploy/spec/deploy_spec.rb
163
- - examples/deploy/spec/force_deploy_spec.rb
164
- - examples/deploy/spec/rollback_spec.rb
165
163
  - examples/directory/recipes/create.rb
166
164
  - examples/directory/recipes/delete.rb
167
165
  - examples/directory/spec/create_spec.rb
@@ -192,8 +190,6 @@ files:
192
190
  - examples/env/spec/create_spec.rb
193
191
  - examples/env/spec/delete_spec.rb
194
192
  - examples/env/spec/modify_spec.rb
195
- - examples/erl_call/recipes/run.rb
196
- - examples/erl_call/spec/run_spec.rb
197
193
  - examples/execute/recipes/run.rb
198
194
  - examples/execute/spec/run_spec.rb
199
195
  - examples/expect_exception/recipes/compile_error.rb
@@ -363,14 +359,18 @@ files:
363
359
  - examples/osx_profile/spec/install_spec.rb
364
360
  - examples/osx_profile/spec/remove_spec.rb
365
361
  - examples/package/recipes/install.rb
362
+ - examples/package/recipes/lock.rb
366
363
  - examples/package/recipes/purge.rb
367
364
  - examples/package/recipes/reconfig.rb
368
365
  - examples/package/recipes/remove.rb
366
+ - examples/package/recipes/unlock.rb
369
367
  - examples/package/recipes/upgrade.rb
370
368
  - examples/package/spec/install_spec.rb
369
+ - examples/package/spec/lock_spec.rb
371
370
  - examples/package/spec/purge_spec.rb
372
371
  - examples/package/spec/reconfig_spec.rb
373
372
  - examples/package/spec/remove_spec.rb
373
+ - examples/package/spec/unlock_spec.rb
374
374
  - examples/package/spec/upgrade_spec.rb
375
375
  - examples/pacman_package/recipes/install.rb
376
376
  - examples/pacman_package/recipes/purge.rb
@@ -614,12 +614,16 @@ files:
614
614
  - examples/windows_service/spec/start_spec.rb
615
615
  - examples/windows_service/spec/stop_spec.rb
616
616
  - examples/yum_package/recipes/install.rb
617
+ - examples/yum_package/recipes/lock.rb
617
618
  - examples/yum_package/recipes/purge.rb
618
619
  - examples/yum_package/recipes/remove.rb
620
+ - examples/yum_package/recipes/unlock.rb
619
621
  - examples/yum_package/recipes/upgrade.rb
620
622
  - examples/yum_package/spec/install_spec.rb
623
+ - examples/yum_package/spec/lock_spec.rb
621
624
  - examples/yum_package/spec/purge_spec.rb
622
625
  - examples/yum_package/spec/remove_spec.rb
626
+ - examples/yum_package/spec/unlock_spec.rb
623
627
  - examples/yum_package/spec/upgrade_spec.rb
624
628
  - examples/yum_repository/recipes/add.rb
625
629
  - examples/yum_repository/recipes/create.rb
@@ -632,12 +636,16 @@ files:
632
636
  - examples/yum_repository/spec/makecache_spec.rb
633
637
  - examples/yum_repository/spec/remove_spec.rb
634
638
  - examples/zypper_package/recipes/install.rb
639
+ - examples/zypper_package/recipes/lock.rb
635
640
  - examples/zypper_package/recipes/purge.rb
636
641
  - examples/zypper_package/recipes/remove.rb
642
+ - examples/zypper_package/recipes/unlock.rb
637
643
  - examples/zypper_package/recipes/upgrade.rb
638
644
  - examples/zypper_package/spec/install_spec.rb
645
+ - examples/zypper_package/spec/lock_spec.rb
639
646
  - examples/zypper_package/spec/purge_spec.rb
640
647
  - examples/zypper_package/spec/remove_spec.rb
648
+ - examples/zypper_package/spec/unlock_spec.rb
641
649
  - examples/zypper_package/spec/upgrade_spec.rb
642
650
  - lib/chefspec.rb
643
651
  - lib/chefspec/api.rb
@@ -660,6 +668,7 @@ files:
660
668
  - lib/chefspec/extensions.rb
661
669
  - lib/chefspec/extensions/chef/client.rb
662
670
  - lib/chefspec/extensions/chef/conditional.rb
671
+ - lib/chefspec/extensions/chef/cookbook/gem_installer.rb
663
672
  - lib/chefspec/extensions/chef/cookbook_uploader.rb
664
673
  - lib/chefspec/extensions/chef/data_query.rb
665
674
  - lib/chefspec/extensions/chef/lwrp_base.rb
@@ -760,7 +769,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
760
769
  version: '0'
761
770
  requirements: []
762
771
  rubyforge_project:
763
- rubygems_version: 2.6.13
772
+ rubygems_version: 2.7.5
764
773
  signing_key:
765
774
  specification_version: 4
766
775
  summary: Write RSpec examples and generate coverage reports for Chef recipes!
@@ -1,10 +0,0 @@
1
- deploy '/tmp/default_action'
2
-
3
- deploy '/tmp/explicit_action' do
4
- action :deploy
5
- end
6
-
7
- deploy '/tmp/with_attributes' do
8
- repo 'ssh://git.path'
9
- migrate true
10
- end
@@ -1,9 +0,0 @@
1
- deploy '/tmp/explicit_action' do
2
- action :force_deploy
3
- end
4
-
5
- deploy '/tmp/with_attributes' do
6
- repo 'ssh://git.path'
7
- migrate true
8
- action :force_deploy
9
- end
@@ -1,9 +0,0 @@
1
- deploy '/tmp/explicit_action' do
2
- action :rollback
3
- end
4
-
5
- deploy '/tmp/with_attributes' do
6
- repo 'ssh://git.path'
7
- migrate true
8
- action :rollback
9
- end
@@ -1,15 +0,0 @@
1
- require 'chefspec'
2
-
3
- describe 'deploy::deploy' do
4
- let(:chef_run) { ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) }
5
-
6
- it 'deploys a deploy with an explicit action' do
7
- expect(chef_run).to deploy_deploy('/tmp/explicit_action')
8
- expect(chef_run).to_not deploy_deploy('/tmp/not_explicit_action')
9
- end
10
-
11
- it 'deploys a deploy with attributes' do
12
- expect(chef_run).to deploy_deploy('/tmp/with_attributes').with(repo: 'ssh://git.path', migrate: true)
13
- expect(chef_run).to_not deploy_deploy('/tmp/with_attributes').with(repo: 'ssh://git.other_path', migrate: false)
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- require 'chefspec'
2
-
3
- describe 'deploy::force_deploy' do
4
- let(:chef_run) { ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) }
5
-
6
- it 'force deploys a deploy with an explicit action' do
7
- expect(chef_run).to force_deploy_deploy('/tmp/explicit_action')
8
- expect(chef_run).to_not force_deploy_deploy('/tmp/not_explicit_action')
9
- end
10
-
11
- it 'force deploys a deploy with attributes' do
12
- expect(chef_run).to force_deploy_deploy('/tmp/with_attributes').with(repo: 'ssh://git.path', migrate: true)
13
- expect(chef_run).to_not force_deploy_deploy('/tmp/with_attributes').with(repo: 'ssh://git.other_path', migrate: false)
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- require 'chefspec'
2
-
3
- describe 'deploy::rollback' do
4
- let(:chef_run) { ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) }
5
-
6
- it 'rollsback deploys a deploy with an explicit action' do
7
- expect(chef_run).to rollback_deploy('/tmp/explicit_action')
8
- expect(chef_run).to_not rollback_deploy('/tmp/not_explicit_action')
9
- end
10
-
11
- it 'rollsback deploys a deploy with attributes' do
12
- expect(chef_run).to rollback_deploy('/tmp/with_attributes').with(repo: 'ssh://git.path', migrate: true)
13
- expect(chef_run).to_not rollback_deploy('/tmp/with_attributes').with(repo: 'ssh://git.other_path', migrate: false)
14
- end
15
- end
@@ -1,13 +0,0 @@
1
- erl_call 'default_action'
2
-
3
- erl_call 'explicit_action' do
4
- action :run
5
- end
6
-
7
- erl_call 'with_attributes' do
8
- code 'hello'
9
- end
10
-
11
- erl_call 'specifying the identity attribute' do
12
- code 'identity_attribute'
13
- end
@@ -1,23 +0,0 @@
1
- require 'chefspec'
2
-
3
- describe 'erl_call::run' do
4
- let(:chef_run) { ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) }
5
-
6
- it 'runs a erl_call with the default action' do
7
- expect(chef_run).to run_erl_call('default_action')
8
- expect(chef_run).to_not run_erl_call('not_default_action')
9
- end
10
-
11
- it 'runs a erl_call with an explicit action' do
12
- expect(chef_run).to run_erl_call('explicit_action')
13
- end
14
-
15
- it 'runs a erl_call with attributes' do
16
- expect(chef_run).to run_erl_call('with_attributes').with(code: 'hello')
17
- expect(chef_run).to_not run_erl_call('with_attributes').with(code: 'not_hello')
18
- end
19
-
20
- it 'runs a erl_call when specifying the identity attribute' do
21
- expect(chef_run).to run_erl_call('identity_attribute')
22
- end
23
- end