diff options
author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-10 17:50:36 -0700 |
---|---|---|
committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-12 16:12:07 -0700 |
commit | dc2675df2805d1e2dbf3c50a49152bcfd78f922f (patch) | |
tree | b7c986a4dea98589ad7e10f66f4bd0ed5475e70d /spec | |
parent | 7228f580a22cc13dc66a93d81bf57a5bad80a73f (diff) | |
download | puppet-dc2675df2805d1e2dbf3c50a49152bcfd78f922f.tar.gz puppet-dc2675df2805d1e2dbf3c50a49152bcfd78f922f.tar.xz puppet-dc2675df2805d1e2dbf3c50a49152bcfd78f922f.zip |
(#6770) Improve test robustness against 'require'
We hit another situation where we crudely flushed the internal set of faces,
but require thought we had already loaded the file defining one. This fooled
our autoloader and raised more annoying problems.
Reviewed-By: Matt Robinson <matt@puppetlabs.com>
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/unit/interface/face_collection_spec.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/spec/unit/interface/face_collection_spec.rb b/spec/unit/interface/face_collection_spec.rb index b83bd50d3..e6e03c3d2 100755 --- a/spec/unit/interface/face_collection_spec.rb +++ b/spec/unit/interface/face_collection_spec.rb @@ -8,9 +8,14 @@ describe Puppet::Interface::FaceCollection do # To avoid cross-pollution we have to save and restore both the hash # containing all the interface data, and the array used by require. Restoring # both means that we don't leak side-effects across the code. --daniel 2011-04-06 + # + # Worse luck, we *also* need to flush $" of anything defining a face, + # because otherwise we can cross-pollute from other test files and end up + # with no faces loaded, but the require value set true. --daniel 2011-04-10 before :each do @original_faces = subject.instance_variable_get("@faces").dup @original_required = $".dup + $".delete_if do |path| path =~ %r{/faces/.*\.rb$} end subject.instance_variable_get("@faces").clear end @@ -75,18 +80,14 @@ describe Puppet::Interface::FaceCollection do end it "should attempt to load the default faces for the specified version :current" do - subject.expects(:require).never # except... subject.expects(:require).with('puppet/faces/fozzie') subject['fozzie', :current] end end describe "::face?" do - before :each do - subject.instance_variable_get("@faces")[:foo]['0.0.1'] = 10 - end - it "should return true if the faces specified is registered" do + subject.instance_variable_get("@faces")[:foo]['0.0.1'] = 10 subject.face?("foo", '0.0.1').should == true end |