Skip to content
Browse files

Merge pull request #602 from cprice-puppet/bug/2.7.x/13439-spec-api-i…

…ncompatibility

(#13439) refactor spec helper for spec compatibility between 2.7 and master
  • Loading branch information...
2 parents 56ce669 + f5487bd commit 2d51b642fcd1fd835d3a5d21bb09b3b74718c874 @pcarlisle pcarlisle committed
Showing with 23 additions and 11 deletions.
  1. +20 −0 lib/puppet/util/settings.rb
  2. +3 −11 spec/spec_helper.rb
View
20 lib/puppet/util/settings.rb
@@ -921,4 +921,24 @@ def set_metadata(meta)
end
end
end
+
+ def initialize_everything_for_tests()
+ # these globals are set by Application
+ $puppet_application_mode = nil
+ $puppet_application_name = nil
+ # Set the confdir and vardir to gibberish so that tests
+ # have to be correctly mocked.
+ self[:confdir] = "/dev/null"
+ self[:vardir] = "/dev/null"
+
+ # Avoid opening ports to the outside world
+ self[:bindaddress] = "127.0.0.1"
+ end
+ private :initialize_everything_for_tests
+
+ def clear_everything_for_tests()
+ self.clear
+ end
+ private :clear_everything_for_tests
+
end
View
14 spec/spec_helper.rb
@@ -62,15 +62,14 @@ module PuppetSpec
}
end
- # these globals are set by Application
- $puppet_application_mode = nil
- $puppet_application_name = nil
# REVISIT: I think this conceals other bad tests, but I don't have time to
# fully diagnose those right now. When you read this, please come tell me
# I suck for letting this float. --daniel 2011-04-21
Signal.stubs(:trap)
+ Puppet.settings.send(:initialize_everything_for_tests)
+
# Longer keys are secure, but they sure make for some slow testing - both
# in terms of generating keys, and in terms of anything the next step down
# the line doing validation or whatever. Most tests don't care how long
@@ -82,13 +81,6 @@ module PuppetSpec
Puppet[:req_bits] = 512
Puppet[:keylength] = 512
- # Set the confdir and vardir to gibberish so that tests
- # have to be correctly mocked.
- Puppet[:confdir] = "/dev/null"
- Puppet[:vardir] = "/dev/null"
-
- # Avoid opening ports to the outside world
- Puppet.settings[:bindaddress] = "127.0.0.1"
@logs = []
Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(@logs))
@@ -97,7 +89,7 @@ module PuppetSpec
end
config.after :each do
- Puppet.settings.clear
+ Puppet.settings.send(:clear_everything_for_tests)
Puppet::Node::Environment.clear
Puppet::Util::Storage.clear
Puppet::Util::ExecutionStub.reset

0 comments on commit 2d51b64

Please sign in to comment.
Something went wrong with that request. Please try again.