diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | chef.gemspec | 2 | ||||
-rw-r--r-- | lib/chef/resource/ips_package.rb | 2 | ||||
-rw-r--r-- | lib/chef/resource/paludis_package.rb | 2 | ||||
-rw-r--r-- | lib/chef/resource/reboot.rb | 2 | ||||
-rw-r--r-- | lib/chef/resource/windows_package.rb | 2 | ||||
-rw-r--r-- | spec/functional/audit/rspec_formatter_spec.rb | 5 | ||||
-rw-r--r-- | spec/functional/audit/runner_spec.rb | 5 | ||||
-rw-r--r-- | spec/support/audit_helper.rb | 65 | ||||
-rw-r--r-- | spec/unit/audit/runner_spec.rb | 6 |
10 files changed, 16 insertions, 76 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index c161ac5adc..10829a08d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,7 @@ * Useradd functional tests fail randomly * Add comments to trusted_certs_content * fixes a bug where providers would not get defined if a top-level ruby constant with the same name was already defined (ark cookbook, chrome cookbook) +* Fix a bug in `reboot`, `ips_package`, `paludis_package`, `windows_package` resources where `action :nothing` was not permitted ## 12.0.3 * [**Phil Dibowitz**](https://github.com/jaymzh): diff --git a/chef.gemspec b/chef.gemspec index 91e303664b..907ad271e9 100644 --- a/chef.gemspec +++ b/chef.gemspec @@ -36,7 +36,7 @@ Gem::Specification.new do |s| s.add_dependency 'plist', '~> 3.1.0' # Audit mode requires these, so they are non-developmental dependencies now - %w(rspec-core rspec-expectations rspec-mocks).each { |gem| s.add_dependency gem, "~> 3.1.0" } + %w(rspec-core rspec-expectations rspec-mocks).each { |gem| s.add_dependency gem, "~> 3.2" } s.add_dependency "rspec_junit_formatter", "~> 0.2.0" s.add_dependency "serverspec", "~> 2.7" s.add_dependency "specinfra", "~> 2.10" diff --git a/lib/chef/resource/ips_package.rb b/lib/chef/resource/ips_package.rb index 77b3387946..c0e699e31a 100644 --- a/lib/chef/resource/ips_package.rb +++ b/lib/chef/resource/ips_package.rb @@ -28,7 +28,7 @@ class Chef def initialize(name, run_context = nil) super(name, run_context) @resource_name = :ips_package - @allowed_actions = [ :install, :remove, :upgrade ] + @allowed_actions.push(:install, :remove, :upgrade) @accept_license = false end diff --git a/lib/chef/resource/paludis_package.rb b/lib/chef/resource/paludis_package.rb index 7eddf8690b..552c96857a 100644 --- a/lib/chef/resource/paludis_package.rb +++ b/lib/chef/resource/paludis_package.rb @@ -28,7 +28,7 @@ class Chef def initialize(name, run_context=nil) super(name, run_context) @resource_name = :paludis_package - @allowed_actions = [ :install, :remove, :upgrade ] + @allowed_actions.push(:install, :remove, :upgrade) @timeout = 3600 end end diff --git a/lib/chef/resource/reboot.rb b/lib/chef/resource/reboot.rb index d6caafdea8..c111b23d2e 100644 --- a/lib/chef/resource/reboot.rb +++ b/lib/chef/resource/reboot.rb @@ -28,7 +28,7 @@ class Chef super @resource_name = :reboot @provider = Chef::Provider::Reboot - @allowed_actions = [:request_reboot, :reboot_now, :cancel] + @allowed_actions.push(:request_reboot, :reboot_now, :cancel) @reason = "Reboot by Chef" @delay_mins = 0 diff --git a/lib/chef/resource/windows_package.rb b/lib/chef/resource/windows_package.rb index b1ef2c288e..16cfcf865e 100644 --- a/lib/chef/resource/windows_package.rb +++ b/lib/chef/resource/windows_package.rb @@ -29,7 +29,7 @@ class Chef def initialize(name, run_context=nil) super - @allowed_actions = [ :install, :remove ] + @allowed_actions.push(:install, :remove) @resource_name = :windows_package @source ||= source(@package_name) diff --git a/spec/functional/audit/rspec_formatter_spec.rb b/spec/functional/audit/rspec_formatter_spec.rb index 43d3c2f6dd..009374db68 100644 --- a/spec/functional/audit/rspec_formatter_spec.rb +++ b/spec/functional/audit/rspec_formatter_spec.rb @@ -19,9 +19,10 @@ # require 'spec_helper' -require 'spec/support/audit_helper' +require 'rspec/core/sandbox' require 'chef/audit/runner' require 'rspec/support/spec/in_sub_process' +require 'rspec/support/spec/stderr_splitter' require 'chef/audit/rspec_formatter' describe Chef::Audit::RspecFormatter do @@ -37,7 +38,7 @@ describe Chef::Audit::RspecFormatter do let!(:formatter) { Chef::Audit::RspecFormatter.new(output) } around(:each) do |ex| - Sandboxing.sandboxed { ex.run } + RSpec::Core::Sandbox.sandboxed { ex.run } end it "should not close the output using our formatter" do diff --git a/spec/functional/audit/runner_spec.rb b/spec/functional/audit/runner_spec.rb index aa35548f2f..4bb58118f6 100644 --- a/spec/functional/audit/runner_spec.rb +++ b/spec/functional/audit/runner_spec.rb @@ -17,9 +17,10 @@ # require 'spec_helper' -require 'spec/support/audit_helper' +require 'rspec/core/sandbox' require 'chef/audit/runner' require 'rspec/support/spec/in_sub_process' +require 'rspec/support/spec/stderr_splitter' require 'tempfile' ## @@ -42,7 +43,7 @@ describe Chef::Audit::Runner do let(:stdout) { StringIO.new } around(:each) do |ex| - Sandboxing.sandboxed { ex.run } + RSpec::Core::Sandbox.sandboxed { ex.run } end before do diff --git a/spec/support/audit_helper.rb b/spec/support/audit_helper.rb deleted file mode 100644 index 8fd3f4d719..0000000000 --- a/spec/support/audit_helper.rb +++ /dev/null @@ -1,65 +0,0 @@ -# This code comes from https://github.com/rspec/rspec-core/blob/master/spec/spec_helper.rb and -# https://github.com/rspec/rspec-core/blob/master/spec/support/sandboxing.rb - -# To leverage the sandboxing use an `around` block: -# around(:each) do |ex| -# Sandboxing.sandboxed { ex.run } -# end - -# rspec-core did not include a license on Github -# TODO when this API is exposed publicly from rspec-core, get rid of this copy pasta - -# Adding these as writers is necessary, otherwise we cannot set the new configuration. -# Only want to do this in the specs. -class << RSpec - attr_writer :configuration, :world -end - -class NullObject - private - def method_missing(method, *args, &block) - # ignore - end -end - -# TODO remove this when RSPec exposes this functionality publically -# https://github.com/rspec/rspec-core/pull/1808 -module Sandboxing - def self.sandboxed(&block) - orig_load_path = $LOAD_PATH.dup - orig_config = RSpec.configuration - orig_world = RSpec.world - orig_example = RSpec.current_example - new_config = RSpec::Core::Configuration.new - new_config.expose_dsl_globally = false - new_config.expecting_with_rspec = true - new_world = RSpec::Core::World.new(new_config) - RSpec.configuration = new_config - RSpec.world = new_world - object = Object.new - object.extend(RSpec::Core::SharedExampleGroup) - - (class << RSpec::Core::ExampleGroup; self; end).class_exec do - alias_method :orig_run, :run - def run(reporter=nil) - RSpec.current_example = nil - orig_run(reporter || NullObject.new) - end - end - - RSpec::Mocks.with_temporary_scope do - object.instance_exec(&block) - end - ensure - (class << RSpec::Core::ExampleGroup; self; end).class_exec do - remove_method :run - alias_method :run, :orig_run - remove_method :orig_run - end - - RSpec.configuration = orig_config - RSpec.world = orig_world - RSpec.current_example = orig_example - $LOAD_PATH.replace(orig_load_path) - end -end diff --git a/spec/unit/audit/runner_spec.rb b/spec/unit/audit/runner_spec.rb index 67590fecf9..893064e067 100644 --- a/spec/unit/audit/runner_spec.rb +++ b/spec/unit/audit/runner_spec.rb @@ -17,11 +17,13 @@ # require 'spec_helper' -require 'spec/support/audit_helper' +require 'rspec/core/sandbox' require 'chef/audit/runner' require 'chef/audit/audit_event_proxy' require 'chef/audit/rspec_formatter' require 'rspec/support/spec/in_sub_process' +require 'rspec/support/spec/stderr_splitter' + describe Chef::Audit::Runner do include RSpec::Support::InSubProcess @@ -31,7 +33,7 @@ describe Chef::Audit::Runner do let(:runner) { Chef::Audit::Runner.new(run_context) } around(:each) do |ex| - Sandboxing.sandboxed { ex.run } + RSpec::Core::Sandbox.sandboxed { ex.run } end describe "#initialize" do |