Added before and after hooks to store and restore environment data so
that changes to the hash do not persist between runs.

Signed-off-by: Adrien Thebo <adr...@puppetlabs.com>
---
Local-branch: ticket/master/8615
 spec/spec_helper.rb |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 483d4dc..e298ca7 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -16,9 +16,18 @@ Dir["#{dir}/monkey_patches/*.rb"].map { |file| require file }
 RSpec.configure do |config|
   config.mock_with :mocha
 
-  # Ensure that we don't accidentally cache between test cases.
+  # Ensure that we don't accidentally cache facts and environment
+  # between test cases.
   config.before :each do
     Facter::Util::Loader.any_instance.stubs(:load_all)
     Facter.clear
+    @old_env = {}
+    ENV.each_key {|k| @old_env[k] = ENV[k]}
+  end
+
+  config.after :each do
+    @old_env.each_pair {|k, v| ENV[k] = v}
+    to_remove = ENV.keys.reject {|key| @old_env.include? key }
+    to_remove.each {|key| ENV.delete key }
   end
 end
-- 
1.7.6

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to puppet-dev@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to