summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chef.gemspec2
-rw-r--r--spec/functional/audit/rspec_formatter_spec.rb5
-rw-r--r--spec/functional/audit/runner_spec.rb5
-rw-r--r--spec/support/audit_helper.rb65
-rw-r--r--spec/unit/audit/runner_spec.rb6
5 files changed, 11 insertions, 72 deletions
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/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