From caa5113dcf1cc254ca47c471fa2496bba9cae960 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Tue, 2 Aug 2016 16:55:13 -0700 Subject: [PATCH 01/15] Add testing on Ruby 2.3 in Travis Signed-off-by: Tim Smith --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index e863cb82..30a3fe22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,9 @@ before_install: - gem install bundler rvm: - - 2.1 - - 2.2 + - 2.1.9 + - 2.2.5 + - 2.3.1 branches: only: @@ -51,4 +52,3 @@ matrix: rvm: 1.9.3 - env: CHEF_VERSION=11.14.2 rvm: 1.9.3 - From 33ae63201b6c2c44a4ea1eea558d28dba1b07d82 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Tue, 2 Aug 2016 16:56:38 -0700 Subject: [PATCH 02/15] Require the latest Fauxhai We've made some nice changes to the data. We should ensure people are using the latest and greatest Signed-off-by: Tim Smith --- chefspec.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chefspec.gemspec b/chefspec.gemspec index e3a855ac..71c6312b 100644 --- a/chefspec.gemspec +++ b/chefspec.gemspec @@ -27,7 +27,7 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 2.1' s.add_dependency 'chef', '>= 11.14' - s.add_dependency 'fauxhai', '~> 3.2' + s.add_dependency 'fauxhai', '~> 3.6' s.add_dependency 'rspec', '~> 3.0' # Development Dependencies From 0e8aabeaeff8bb890282a50840fc2a9def22a17b Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Tue, 2 Aug 2016 17:11:39 -0700 Subject: [PATCH 03/15] Pin rack in the Gemfile until we remove Ruby 2.1 support Older versions of chef have an open Rack requirement Signed-off-by: Tim Smith --- Gemfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Gemfile b/Gemfile index 851fabc2..14695307 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,5 @@ source 'https://rubygems.org' gemspec + +# necessary until we drop support for Ruby 2.1 +gem 'rack', '< 2' From c3c578a8a13f67c57cf83e19f212d6d130273354 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Tue, 2 Aug 2016 17:12:40 -0700 Subject: [PATCH 04/15] Remove support for Chef 11 It's time. Signed-off-by: Tim Smith --- .travis.yml | 19 ++++--------------- chefspec.gemspec | 4 ++-- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 30a3fe22..bd44ca2e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,10 @@ gemfile: gemfiles/chefspec.gemfile env: - CHEF_VERSION=master + - CHEF_VERSION=12.12.15 + - CHEF_VERSION=12.11.18 + - CHEF_VERSION=12.10.24 + - CHEF_VERSION=12.9.41 - CHEF_VERSION=12.8.1 - CHEF_VERSION=12.7.2 - CHEF_VERSION=12.6.0 @@ -37,18 +41,3 @@ matrix: fast_finish: true allow_failures: - env: CHEF_VERSION=master - include: - - env: CHEF_VERSION=11.18.6 - rvm: 1.9.3 - - env: CHEF_VERSION=11.18.0 - rvm: 1.9.3 - - env: CHEF_VERSION=11.16.4 - rvm: 1.9.3 - - env: CHEF_VERSION=11.16.2 - rvm: 1.9.3 - - env: CHEF_VERSION=11.16.0 - rvm: 1.9.3 - - env: CHEF_VERSION=11.14.6 - rvm: 1.9.3 - - env: CHEF_VERSION=11.14.2 - rvm: 1.9.3 diff --git a/chefspec.gemspec b/chefspec.gemspec index 71c6312b..3424417f 100644 --- a/chefspec.gemspec +++ b/chefspec.gemspec @@ -23,10 +23,10 @@ Gem::Specification.new do |s| s.test_files = s.files.grep(%r{^(test|spec|features)/}) s.require_paths = ['lib'] - # ChefSpec requires Ruby 2.1+ + # ChefSpec requires Ruby 2.1+ since ChefDK uses 2.1.X s.required_ruby_version = '>= 2.1' - s.add_dependency 'chef', '>= 11.14' + s.add_dependency 'chef', '>= 12.0' s.add_dependency 'fauxhai', '~> 3.6' s.add_dependency 'rspec', '~> 3.0' From efe26a7c50f1972c89eb5b3fc49675f9fab6868b Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Tue, 2 Aug 2016 17:40:53 -0700 Subject: [PATCH 05/15] Test only the latest of each feature release Signed-off-by: Tim Smith --- .travis.yml | 3 --- Gemfile | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index bd44ca2e..f9622d7e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,12 +29,9 @@ env: - CHEF_VERSION=12.6.0 - CHEF_VERSION=12.5.1 - CHEF_VERSION=12.4.3 - - CHEF_VERSION=12.4.0 - CHEF_VERSION=12.3.0 - CHEF_VERSION=12.2.1 - CHEF_VERSION=12.1.2 - - CHEF_VERSION=12.1.1 - - CHEF_VERSION=12.1.0 - CHEF_VERSION=12.0.3 matrix: diff --git a/Gemfile b/Gemfile index 14695307..81a83e27 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ source 'https://rubygems.org' -gemspec # necessary until we drop support for Ruby 2.1 gem 'rack', '< 2' + +gemspec From cc037b6a95f0026ad8c93d06c5149eae9b688fb7 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Tue, 2 Aug 2016 21:36:45 -0700 Subject: [PATCH 06/15] Try to pin Rack down for bundle installs again Signed-off-by: Tim Smith --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 81a83e27..b351f324 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' # necessary until we drop support for Ruby 2.1 -gem 'rack', '< 2' +gem 'rack', '~> 1.0' gemspec From 3e260a9fd5632614543ae91d1032d80ea57c15bb Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 3 Aug 2016 12:28:09 -0700 Subject: [PATCH 07/15] Pin rack in Travis when Chef < 12.6 This is less than ideal, but work around rack failing gem installs on older chef releases Signed-off-by: Tim Smith --- Gemfile | 3 --- gemfiles/chefspec.gemfile | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index b351f324..fa75df15 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,3 @@ source 'https://rubygems.org' -# necessary until we drop support for Ruby 2.1 -gem 'rack', '~> 1.0' - gemspec diff --git a/gemfiles/chefspec.gemfile b/gemfiles/chefspec.gemfile index cb1cb517..839bf5cc 100644 --- a/gemfiles/chefspec.gemfile +++ b/gemfiles/chefspec.gemfile @@ -1,5 +1,11 @@ source 'https://rubygems.org' +# travis runs on older chef releases failed while including +# rack 2.X on Ruby 2.1. When we remove Ruby 2.1 support this can go +if ENV['CHEF_VERSION'].to_f < 12.6 + gem 'rack', '~> 1.0' +end + if ENV['CHEF_VERSION'] == 'master' gem 'chef', github: 'chef/chef' else From 3d0ca5292257daf787e46fc658ecb9e6fd1cf9c0 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Tue, 9 Aug 2016 13:10:07 -0700 Subject: [PATCH 08/15] Format the markdown Signed-off-by: Tim Smith --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 690454d8..2e925720 100644 --- a/README.md +++ b/README.md @@ -858,9 +858,10 @@ end 1. The entire contents of this file must be wrapped with the conditional clause checking if `ChefSpec` is defined. 2. Each matcher is actually a top-level method. The above example corresponds to the following RSpec test: - ```ruby - expect(chef_run).to my_custom_matcher('...') - ``` + + ```ruby + expect(chef_run).to my_custom_matcher('...') + ``` 3. `ChefSpec::Matchers::ResourceMatcher` accepts three parameters: 1. The name of the resource to find in the resource collection (i.e. the name of the LWRP). @@ -1148,11 +1149,15 @@ Development 1. Fork the repository from GitHub. 2. Clone your fork to your local machine: - $ git clone git@github.com:USER/chefspec.git + ``` + $ git clone git@github.com:USER/chefspec.git + ``` 3. Create a git branch - $ git checkout -b my_bug_fix + ``` + $ git checkout -b my_bug_fix + ``` 4. **Write tests** 5. Make your changes/patches/fixes, committing appropriately From 6ca6d141f3bfd4aaf5a08322181bcc2fe1c594a1 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 17 Aug 2016 10:02:10 -0700 Subject: [PATCH 09/15] Remove Ruby 2.3 testing for now --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f9622d7e..25f99cbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ before_install: rvm: - 2.1.9 - 2.2.5 - - 2.3.1 branches: only: From 5ff7e6b3d41efc11b60f0ac046e51cc8a527b207 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 17 Aug 2016 10:55:38 -0700 Subject: [PATCH 10/15] Test on Chef 12.13.37 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 25f99cbe..f480cf67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ gemfile: gemfiles/chefspec.gemfile env: - CHEF_VERSION=master + - CHEF_VERSION=12.13.37 - CHEF_VERSION=12.12.15 - CHEF_VERSION=12.11.18 - CHEF_VERSION=12.10.24 From dd65a6185966bd16fe6aa48ee0fd348b678159dd Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 17 Aug 2016 15:39:54 -0700 Subject: [PATCH 11/15] Update the readme for the Chef 12 requirement Signed-off-by: Tim Smith --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 2e925720..1f6bebcb 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ What people are saying Important Notes --------------- -- **ChefSpec 3.0+ requires Ruby 2.1 or higher!** +- **ChefSpec requires Ruby 2.1 or later and Chef 12.0.2 or later!** - **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!** - **Each resource matcher is self-documented using [Yard](http://rubydoc.info/github/sethvargo/chefspec) and has a corresponding aruba test from the [examples directory](https://github.com/sethvargo/chefspec/tree/master/examples).** - **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. @@ -35,8 +35,6 @@ Notes on Compatibility with Chef Versions ----------------------------------------- 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: -- Chef 12 prior to Chef 12.0.2 is not supported due to the lack of a declared resource type. This was fixed in [Chef 12.0.2](https://github.com/chef/chef/blob/12.0.2/lib/chef/resource.rb#L422-428). - 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. From a0167f19e9f14288a23defe1ba368f5cda48e1de Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 17 Aug 2016 15:40:28 -0700 Subject: [PATCH 12/15] Remove @not_chef_11s from feature defs Signed-off-by: Tim Smith --- features/chocolatey_package.feature | 7 ------- features/dsc_resource.feature | 7 ------- features/reboot.feature | 7 ------- features/step_into.feature | 7 ------- features/windows_package.feature | 7 ------- features/windows_service.feature | 7 ------- 6 files changed, 42 deletions(-) diff --git a/features/chocolatey_package.feature b/features/chocolatey_package.feature index f940262e..366bd9db 100644 --- a/features/chocolatey_package.feature +++ b/features/chocolatey_package.feature @@ -1,10 +1,3 @@ -@not_chef_11_14_2 -@not_chef_11_14_6 -@not_chef_11_16_0 -@not_chef_11_16_2 -@not_chef_11_16_4 -@not_chef_11_18_0 -@not_chef_11_18_6 @not_chef_12_0_3 @not_chef_12_1_0 @not_chef_12_1_1 diff --git a/features/dsc_resource.feature b/features/dsc_resource.feature index 267f818a..0ba5a043 100644 --- a/features/dsc_resource.feature +++ b/features/dsc_resource.feature @@ -1,10 +1,3 @@ -@not_chef_11_14_2 -@not_chef_11_14_6 -@not_chef_11_16_0 -@not_chef_11_16_2 -@not_chef_11_16_4 -@not_chef_11_18_0 -@not_chef_11_18_6 @not_chef_12_0_3 @not_chef_12_1_0 @not_chef_12_1_1 diff --git a/features/reboot.feature b/features/reboot.feature index 90bd8577..bda3190d 100644 --- a/features/reboot.feature +++ b/features/reboot.feature @@ -1,10 +1,3 @@ -@not_chef_11_14_2 -@not_chef_11_14_6 -@not_chef_11_16_0 -@not_chef_11_16_2 -@not_chef_11_16_4 -@not_chef_11_18_0 -@not_chef_11_18_6 Feature: The reboot matcher Background: * I am using the "reboot" cookbook diff --git a/features/step_into.feature b/features/step_into.feature index dd8db1ab..812d6f67 100644 --- a/features/step_into.feature +++ b/features/step_into.feature @@ -1,10 +1,3 @@ -@not_chef_11_14_2 -@not_chef_11_14_6 -@not_chef_11_16_0 -@not_chef_11_16_2 -@not_chef_11_16_4 -@not_chef_11_18_0 -@not_chef_11_18_6 Feature: The step_into matcher Background: * I am using the "step_into" cookbook diff --git a/features/windows_package.feature b/features/windows_package.feature index 1b4b0326..da967cd4 100644 --- a/features/windows_package.feature +++ b/features/windows_package.feature @@ -1,10 +1,3 @@ -@not_chef_11_14_2 -@not_chef_11_14_6 -@not_chef_11_16_0 -@not_chef_11_16_2 -@not_chef_11_16_4 -@not_chef_11_18_0 -@not_chef_11_18_6 @not_chef_12_0_3 @not_chef_12_1_0 @not_chef_12_1_1 diff --git a/features/windows_service.feature b/features/windows_service.feature index a65e745c..9f8a0014 100644 --- a/features/windows_service.feature +++ b/features/windows_service.feature @@ -1,10 +1,3 @@ -@not_chef_11_14_2 -@not_chef_11_14_6 -@not_chef_11_16_0 -@not_chef_11_16_2 -@not_chef_11_16_4 -@not_chef_11_18_0 -@not_chef_11_18_6 Feature: The windows_service matcher Background: * I am using the "windows_service" cookbook From 7f95e30c385fcfe3683c26caeb395733c1b7aa7e Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 17 Aug 2016 15:56:36 -0700 Subject: [PATCH 13/15] Remove workaround for LWRP issues in Chef 11 Signed-off-by: Tim Smith --- spec/unit/extensions/lwrp_base_spec.rb | 96 -------------------------- 1 file changed, 96 deletions(-) delete mode 100644 spec/unit/extensions/lwrp_base_spec.rb diff --git a/spec/unit/extensions/lwrp_base_spec.rb b/spec/unit/extensions/lwrp_base_spec.rb deleted file mode 100644 index 3337674f..00000000 --- a/spec/unit/extensions/lwrp_base_spec.rb +++ /dev/null @@ -1,96 +0,0 @@ -require 'spec_helper' - -# Chef 12 fixed resource inheritance issues -if Chef::VERSION.to_f < 12.0 - module ChefSpec - module Extensions - describe :LWRPBase do - describe '#remove_existing_lwrp' do - before do - Chef::Provider::MysqlDatabase = nil - Chef::Resource::MysqlDatabase = Class.new(Chef::Resource) - end - - after do - [Chef::Provider, Chef::Resource].each do |mod| - next unless mod.const_defined?(:MysqlDatabase, false) - mod.send(:remove_const, :MysqlDatabase) - end - end - - context Chef::Provider do - before do - Chef::Provider::LWRPBase.remove_existing_lwrp('MysqlDatabase') - end - - it 'removes the provider if it already exists' do - expect(Chef::Provider.constants).to_not include(:MysqlDatabase) - end - - it 'does not remove resource' do - expect(Chef::Resource.constants).to include(:MysqlDatabase) - end - - it 'does not throw an error if the resource does not already exist' do - expect { - Chef::Provider::LWRPBase.remove_existing_lwrp 'Human' - }.to_not raise_error - end - end - - context Chef::Resource do - let!(:resource_class) { Chef::Resource::MysqlDatabase } - - before do - Chef::Resource::LWRPBase.remove_existing_lwrp('MysqlDatabase') - end - - it 'removes the resource if it already exists' do - expect(Chef::Resource.constants).to_not include(:MysqlDatabase) - end - - if Chef::Resource.respond_to?(:resource_classes) - it 'removes the resource from Chef::Resource.resource_classes' do - expect(Chef::Resource.resource_classes).to_not include(resource_class) - end - end - - it 'does not remove the provider' do - Chef::Resource::LWRPBase.remove_existing_lwrp('MysqlDatabase') - expect(Chef::Provider.constants).to include(:MysqlDatabase) - end - - it 'does not throw an error if the resource does not already exist' do - expect { - Chef::Resource::LWRPBase.remove_existing_lwrp 'Human' - }.to_not raise_error - end - end - end - end - - describe '#build_from_file' do - let(:args){ %w{mycookbook thisfile context} } - - shared_context "wrapping" do - it 'wraps the existing chef build_from_file method' do - klass = mod::LWRPBase - allow(klass).to receive(:build_from_file_without_removal) - expect(klass).to receive(:build_from_file_without_removal).with(*args) - klass.build_from_file(*args) - end - end - - context Chef::Provider do - let(:mod){ Chef::Provider } - include_context "wrapping" - end - - context Chef::Resource do - let(:mod){ Chef::Resource } - include_context "wrapping" - end - end - end - end -end From 05c708d660f805c13302ab264d96fcea90faf49d Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 17 Aug 2016 16:14:09 -0700 Subject: [PATCH 14/15] Disable subscribes and notifications for chef < 12.5.1 The additional of additional matchers broken versions of chef that lack these Signed-off-by: Tim Smith --- features/notifications.feature | 10 ++++++++++ features/subscribes.feature | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/features/notifications.feature b/features/notifications.feature index 4c8ecb2d..9ef24325 100644 --- a/features/notifications.feature +++ b/features/notifications.feature @@ -1,3 +1,13 @@ +@not_chef_12_0_3 +@not_chef_12_1_0 +@not_chef_12_1_1 +@not_chef_12_1_2 +@not_chef_12_2_1 +@not_chef_12_3_0 +@not_chef_12_4_0 +@not_chef_12_4_3 +@not_chef_12_5_1 + Feature: The notifications matcher Background: * I am using the "notifications" cookbook diff --git a/features/subscribes.feature b/features/subscribes.feature index 72080681..36a6792e 100644 --- a/features/subscribes.feature +++ b/features/subscribes.feature @@ -1,3 +1,13 @@ +@not_chef_12_0_3 +@not_chef_12_1_0 +@not_chef_12_1_1 +@not_chef_12_1_2 +@not_chef_12_2_1 +@not_chef_12_3_0 +@not_chef_12_4_0 +@not_chef_12_4_3 +@not_chef_12_5_1 + Feature: The subscribes matcher Background: * I am using the "subscribes" cookbook From 910e74273c6a66c29f6eaa075b4afaa12ff23c4b Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 17 Aug 2016 16:40:11 -0700 Subject: [PATCH 15/15] Remove extra tags that aren't needed Signed-off-by: Tim Smith --- features/chocolatey_package.feature | 3 --- features/dsc_resource.feature | 2 -- features/notifications.feature | 3 --- features/subscribes.feature | 3 --- features/windows_package.feature | 2 -- 5 files changed, 13 deletions(-) diff --git a/features/chocolatey_package.feature b/features/chocolatey_package.feature index 366bd9db..0e7e42bf 100644 --- a/features/chocolatey_package.feature +++ b/features/chocolatey_package.feature @@ -1,10 +1,7 @@ @not_chef_12_0_3 -@not_chef_12_1_0 -@not_chef_12_1_1 @not_chef_12_1_2 @not_chef_12_2_1 @not_chef_12_3_0 -@not_chef_12_4_0 @not_chef_12_4_3 @not_chef_12_5_1 @not_chef_12_6_0 diff --git a/features/dsc_resource.feature b/features/dsc_resource.feature index 0ba5a043..b3912b73 100644 --- a/features/dsc_resource.feature +++ b/features/dsc_resource.feature @@ -1,6 +1,4 @@ @not_chef_12_0_3 -@not_chef_12_1_0 -@not_chef_12_1_1 @not_chef_12_1_2 Feature: The dsc_resource matcher Background: diff --git a/features/notifications.feature b/features/notifications.feature index 9ef24325..70b32f0f 100644 --- a/features/notifications.feature +++ b/features/notifications.feature @@ -1,10 +1,7 @@ @not_chef_12_0_3 -@not_chef_12_1_0 -@not_chef_12_1_1 @not_chef_12_1_2 @not_chef_12_2_1 @not_chef_12_3_0 -@not_chef_12_4_0 @not_chef_12_4_3 @not_chef_12_5_1 diff --git a/features/subscribes.feature b/features/subscribes.feature index 36a6792e..a81c1a3c 100644 --- a/features/subscribes.feature +++ b/features/subscribes.feature @@ -1,10 +1,7 @@ @not_chef_12_0_3 -@not_chef_12_1_0 -@not_chef_12_1_1 @not_chef_12_1_2 @not_chef_12_2_1 @not_chef_12_3_0 -@not_chef_12_4_0 @not_chef_12_4_3 @not_chef_12_5_1 diff --git a/features/windows_package.feature b/features/windows_package.feature index da967cd4..a7356410 100644 --- a/features/windows_package.feature +++ b/features/windows_package.feature @@ -1,6 +1,4 @@ @not_chef_12_0_3 -@not_chef_12_1_0 -@not_chef_12_1_1 @not_chef_12_1_2 @not_chef_12_2_1 @not_chef_12_3_0