[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Nick Lewis nick at puppetlabs.com
Tue May 10 08:03:36 UTC 2011


The following commit has been merged in the experimental branch:
commit 7ed5251f80b0e37caf6e255875860157f95ee935
Author: Nick Lewis <nick at puppetlabs.com>
Date:   Thu Jan 6 15:24:13 2011 -0800

    maint: Work-around for a Mocha bug
    
    Mocha is leaving behind a copy of stubbed methods in the singleton class of the
    object on which the method is stubbed. So a later stub to any_instance of the
    class isn't seen by the original object.
    
    This change works around the problem by adding a follow-up "test" that removes
    the method from the singleton class.
    
    See: https://github.com/floehopper/mocha/issues#issue/20
    
    Paired-With: Paul Berry

diff --git a/spec/unit/application/agent_spec.rb b/spec/unit/application/agent_spec.rb
index cee6a0d..be39707 100755
--- a/spec/unit/application/agent_spec.rb
+++ b/spec/unit/application/agent_spec.rb
@@ -293,6 +293,14 @@ describe Puppet::Application::Agent do
       @puppetd.setup
     end
 
+    it "mocha work-around" do
+      # Mocha 0.9.10 and earlier leaves behind a bogus "use" method
+      # See https://github.com/floehopper/mocha/issues#issue/20
+      class << Puppet.settings
+        remove_method :use rescue nil
+      end
+    end
+
     it "should install a remote ca location" do
       Puppet::SSL::Host.expects(:ca_location=).with(:remote)
 
diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb
index e2b6ff5..6451195 100755
--- a/spec/unit/application/apply_spec.rb
+++ b/spec/unit/application/apply_spec.rb
@@ -177,7 +177,7 @@ describe Puppet::Application::Apply do
     describe "the main command" do
       before :each do
         Puppet.stubs(:[])
-        Puppet.settings.stubs(:use)
+        Puppet::Util::Settings.any_instance.stubs(:use)
         Puppet.stubs(:[]).with(:prerun_command).returns ""
         Puppet.stubs(:[]).with(:postrun_command).returns ""
         Puppet.stubs(:[]).with(:trace).returns(true)
diff --git a/spec/unit/application/master_spec.rb b/spec/unit/application/master_spec.rb
index cf85931..ea52b2f 100644
--- a/spec/unit/application/master_spec.rb
+++ b/spec/unit/application/master_spec.rb
@@ -119,7 +119,7 @@ describe Puppet::Application::Master do
       Puppet::Log.stubs(:level=)
       Puppet::SSL::CertificateAuthority.stubs(:instance)
       Puppet::SSL::CertificateAuthority.stubs(:ca?)
-      Puppet.settings.stubs(:use)
+      Puppet::Util::Settings.any_instance.stubs(:use)
 
       @master.options.stubs(:[]).with(any_parameters)
     end
@@ -183,6 +183,14 @@ describe Puppet::Application::Master do
       @master.setup
     end
 
+    it "mocha work-around" do
+      # Mocha 0.9.10 and earlier leaves behind a bogus "use" method
+      # See https://github.com/floehopper/mocha/issues#issue/20
+      class << Puppet.settings
+        remove_method :use rescue nil
+      end
+    end
+
     it "should cache class in yaml" do
       Puppet::Node.indirection.expects(:cache_class=).with(:yaml)
 
@@ -212,11 +220,20 @@ describe Puppet::Application::Master do
       end
 
       it "should tell Puppet.settings to use :ca category" do
+        Puppet.settings.stubs(:use)
         Puppet.settings.expects(:use).with(:ca)
 
         @master.setup
       end
 
+      it "mocha work-around" do
+        # Mocha 0.9.10 and earlier leaves behind a bogus "use" method
+        # See https://github.com/floehopper/mocha/issues#issue/20
+        class << Puppet.settings
+          remove_method :use rescue nil
+        end
+      end
+
       it "should instantiate the CertificateAuthority singleton" do
         Puppet::SSL::CertificateAuthority.expects(:instance)
 

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list