diff options
author | tyler-ball <tyleraball@gmail.com> | 2015-02-03 15:45:04 -0800 |
---|---|---|
committer | tyler-ball <tyleraball@gmail.com> | 2015-02-04 08:38:22 -0800 |
commit | fe50d7921039c1659e55e7868b1381a83f066d1d (patch) | |
tree | f6bf49d6e83bc15a8f4fe86f9751b3704166bfcf /spec/support | |
parent | 235622a134cecf6696bcb451038618dc682108cc (diff) | |
download | chef-fe50d7921039c1659e55e7868b1381a83f066d1d.tar.gz |
Fixing Rspec 3.2 update. We were overriding private APIs which changed.tball/rspec32-fix
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/audit_helper.rb | 65 |
1 files changed, 0 insertions, 65 deletions
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 |