diff --git a/.travis.yml b/.travis.yml index e863cb82..f480cf67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,8 @@ before_install: - gem install bundler rvm: - - 2.1 - - 2.2 + - 2.1.9 + - 2.2.5 branches: only: @@ -19,36 +19,22 @@ 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 + - CHEF_VERSION=12.9.41 - CHEF_VERSION=12.8.1 - CHEF_VERSION=12.7.2 - 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: 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/Gemfile b/Gemfile index 851fabc2..fa75df15 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,3 @@ source 'https://rubygems.org' + gemspec diff --git a/README.md b/README.md index 4ef8abf3..cb87d8a0 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. @@ -872,9 +870,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). @@ -1162,11 +1161,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 diff --git a/chefspec.gemspec b/chefspec.gemspec index e3a855ac..3424417f 100644 --- a/chefspec.gemspec +++ b/chefspec.gemspec @@ -23,11 +23,11 @@ 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 'fauxhai', '~> 3.2' + s.add_dependency 'chef', '>= 12.0' + s.add_dependency 'fauxhai', '~> 3.6' s.add_dependency 'rspec', '~> 3.0' # Development Dependencies diff --git a/features/chocolatey_package.feature b/features/chocolatey_package.feature index f940262e..0e7e42bf 100644 --- a/features/chocolatey_package.feature +++ b/features/chocolatey_package.feature @@ -1,17 +1,7 @@ -@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 @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 267f818a..b3912b73 100644 --- a/features/dsc_resource.feature +++ b/features/dsc_resource.feature @@ -1,13 +1,4 @@ -@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 @not_chef_12_1_2 Feature: The dsc_resource matcher Background: diff --git a/features/notifications.feature b/features/notifications.feature index a9f981f9..5af8f744 100644 --- a/features/notifications.feature +++ b/features/notifications.feature @@ -1,3 +1,10 @@ +@not_chef_12_0_3 +@not_chef_12_1_2 +@not_chef_12_2_1 +@not_chef_12_3_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/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/subscribes.feature b/features/subscribes.feature index ff1a8acd..0c22d5c0 100644 --- a/features/subscribes.feature +++ b/features/subscribes.feature @@ -1,3 +1,10 @@ +@not_chef_12_0_3 +@not_chef_12_1_2 +@not_chef_12_2_1 +@not_chef_12_3_0 +@not_chef_12_4_3 +@not_chef_12_5_1 + Feature: The subscribes matcher Background: * I am using the "subscribes" cookbook diff --git a/features/windows_package.feature b/features/windows_package.feature index 1b4b0326..a7356410 100644 --- a/features/windows_package.feature +++ b/features/windows_package.feature @@ -1,13 +1,4 @@ -@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 @not_chef_12_1_2 @not_chef_12_2_1 @not_chef_12_3_0 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 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 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