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

Matt Robinson matt at puppetlabs.com
Tue May 10 08:09:25 UTC 2011


The following commit has been merged in the experimental branch:
commit 1ac7f63f00c517c6dff67be8d927b968c7bcb6ea
Author: Matt Robinson <matt at puppetlabs.com>
Date:   Mon Mar 28 15:48:32 2011 -0700

    (#6830) Fix tests that depended on special inherited behavior
    
      class Foo
        def self.inherited(subclass)
          puts "#{subclass.inspect} inherited from #{self}"
        end
      end
    
      class Bar < Foo
      end
    
      a = Class.new(Bar) do
        def self.to_s
          "some other class"
        end
      end
    
    In Ruby 1.9 this prints
    
      Bar inherited from Foo
      #<Class:0x0000010086c198> inherited from Bar
    
    In Ruby 1.8 the to_s override used to be in effect so printed:
    
      Bar inherited from Foo
      some other class inherited from Bar
    
    Reviewed-by: Jesse Wolfe <jesse at puppetlabs.com>

diff --git a/spec/unit/indirector/active_record_spec.rb b/spec/unit/indirector/active_record_spec.rb
index 4765cc5..4fab17d 100755
--- a/spec/unit/indirector/active_record_spec.rb
+++ b/spec/unit/indirector/active_record_spec.rb
@@ -14,10 +14,9 @@ describe Puppet::Indirector::ActiveRecord do
     @indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
     Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
 
-    @active_record_class = Class.new(Puppet::Indirector::ActiveRecord) do
-      def self.to_s
-        "Mystuff::Testing"
-      end
+    module Testing; end
+    @active_record_class = class Testing::MyActiveRecord < Puppet::Indirector::ActiveRecord
+      self
     end
 
     @ar_model = mock 'ar_model'
diff --git a/spec/unit/indirector/code_spec.rb b/spec/unit/indirector/code_spec.rb
index 452d009..1c9e4d2 100755
--- a/spec/unit/indirector/code_spec.rb
+++ b/spec/unit/indirector/code_spec.rb
@@ -4,16 +4,15 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
 require 'puppet/indirector/code'
 
 describe Puppet::Indirector::Code do
-  before do
+  before :all do
     Puppet::Indirector::Terminus.stubs(:register_terminus_class)
     @model = mock 'model'
     @indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
     Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
 
-    @code_class = Class.new(Puppet::Indirector::Code) do
-      def self.to_s
-        "Mystuff::Testing"
-      end
+    module Testing; end
+    @code_class = class Testing::MyCode < Puppet::Indirector::Code
+      self
     end
 
     @searcher = @code_class.new
diff --git a/spec/unit/indirector/direct_file_server_spec.rb b/spec/unit/indirector/direct_file_server_spec.rb
index 8eab4ad..5d9af62 100755
--- a/spec/unit/indirector/direct_file_server_spec.rb
+++ b/spec/unit/indirector/direct_file_server_spec.rb
@@ -8,16 +8,15 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
 require 'puppet/indirector/direct_file_server'
 
 describe Puppet::Indirector::DirectFileServer do
-  before :each do
+  before :all do
     Puppet::Indirector::Terminus.stubs(:register_terminus_class)
     @model = mock 'model'
     @indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
     Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
 
-    @direct_file_class = Class.new(Puppet::Indirector::DirectFileServer) do
-      def self.to_s
-        "Testing::Mytype"
-      end
+    module Testing; end
+    @direct_file_class = class Testing::Mytype < Puppet::Indirector::DirectFileServer
+      self
     end
 
     @server = @direct_file_class.new
diff --git a/spec/unit/indirector/exec_spec.rb b/spec/unit/indirector/exec_spec.rb
index d4fb224..5abb00a 100755
--- a/spec/unit/indirector/exec_spec.rb
+++ b/spec/unit/indirector/exec_spec.rb
@@ -5,17 +5,17 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
 require 'puppet/indirector/exec'
 
 describe Puppet::Indirector::Exec do
-  before do
+  before :all do
     @indirection = stub 'indirection', :name => :testing
     Puppet::Indirector::Indirection.expects(:instance).with(:testing).returns(@indirection)
-    @exec_class = Class.new(Puppet::Indirector::Exec) do
-      def self.to_s
-        "Testing::Mytype"
-      end
-
+    module Testing; end
+    @exec_class = class Testing::MyTesting < Puppet::Indirector::Exec
       attr_accessor :command
+      self
     end
+  end
 
+  before :each do
     @searcher = @exec_class.new
     @searcher.command = ["/echo"]
 
diff --git a/spec/unit/indirector/file_server_spec.rb b/spec/unit/indirector/file_server_spec.rb
index a81d504..079eba0 100755
--- a/spec/unit/indirector/file_server_spec.rb
+++ b/spec/unit/indirector/file_server_spec.rb
@@ -10,18 +10,19 @@ require 'puppet/file_serving/configuration'
 
 describe Puppet::Indirector::FileServer do
 
-  before :each do
+  before :all do
     Puppet::Indirector::Terminus.stubs(:register_terminus_class)
     @model = mock 'model'
     @indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
     Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
 
-    @file_server_class = Class.new(Puppet::Indirector::FileServer) do
-      def self.to_s
-        "Testing::Mytype"
-      end
+    module Testing; end
+    @file_server_class = class Testing::MyFileServer < Puppet::Indirector::FileServer
+      self
     end
+  end
 
+  before :each do
     @file_server = @file_server_class.new
 
     @uri = "puppet://host/my/local/file"
diff --git a/spec/unit/indirector/file_spec.rb b/spec/unit/indirector/file_spec.rb
index 8fd197e..96d5b2a 100755
--- a/spec/unit/indirector/file_spec.rb
+++ b/spec/unit/indirector/file_spec.rb
@@ -5,16 +5,15 @@ require 'puppet/indirector/file'
 
 
 describe Puppet::Indirector::File do
-  before :each do
+  before :all do
     Puppet::Indirector::Terminus.stubs(:register_terminus_class)
     @model = mock 'model'
     @indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
     Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
 
-    @file_class = Class.new(Puppet::Indirector::File) do
-      def self.to_s
-        "Testing::Mytype"
-      end
+    module Testing; end
+    @file_class = class Testing::MyFile < Puppet::Indirector::File
+      self
     end
 
     @searcher = @file_class.new
diff --git a/spec/unit/indirector/ldap_spec.rb b/spec/unit/indirector/ldap_spec.rb
index 2178a87..ab5dab9 100755
--- a/spec/unit/indirector/ldap_spec.rb
+++ b/spec/unit/indirector/ldap_spec.rb
@@ -8,10 +8,9 @@ describe Puppet::Indirector::Ldap do
   before do
     @indirection = stub 'indirection', :name => :testing
     Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
-    @ldap_class = Class.new(Puppet::Indirector::Ldap) do
-      def self.to_s
-        "Testing::Mytype"
-      end
+    module Testing; end
+    @ldap_class = class Testing::MyLdap < Puppet::Indirector::Ldap
+      self
     end
 
     @connection = mock 'ldap'
diff --git a/spec/unit/indirector/memory_spec.rb b/spec/unit/indirector/memory_spec.rb
index f901032..751adb1 100755
--- a/spec/unit/indirector/memory_spec.rb
+++ b/spec/unit/indirector/memory_spec.rb
@@ -14,10 +14,9 @@ describe Puppet::Indirector::Memory do
     @indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
     Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
 
-    @memory_class = Class.new(Puppet::Indirector::Memory) do
-      def self.to_s
-        "Mystuff::Testing"
-      end
+    module Testing; end
+    @memory_class = class Testing::MyMemory < Puppet::Indirector::Memory
+      self
     end
 
     @searcher = @memory_class.new
diff --git a/spec/unit/indirector/plain_spec.rb b/spec/unit/indirector/plain_spec.rb
index 54c0233..dfaa701 100755
--- a/spec/unit/indirector/plain_spec.rb
+++ b/spec/unit/indirector/plain_spec.rb
@@ -10,10 +10,9 @@ describe Puppet::Indirector::Plain do
     @indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
     Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
 
-    @plain_class = Class.new(Puppet::Indirector::Plain) do
-      def self.to_s
-        "Mystuff::Testing"
-      end
+    module Testing; end
+    @plain_class = class Testing::MyPlain < Puppet::Indirector::Plain
+      self
     end
 
     @searcher = @plain_class.new
diff --git a/spec/unit/indirector/queue_spec.rb b/spec/unit/indirector/queue_spec.rb
index 49e5e10..6f5b44b 100755
--- a/spec/unit/indirector/queue_spec.rb
+++ b/spec/unit/indirector/queue_spec.rb
@@ -31,10 +31,9 @@ describe Puppet::Indirector::Queue, :if => Puppet.features.pson? do
     @model = mock 'model'
     @indirection = stub 'indirection', :name => :my_queue, :register_terminus_type => nil, :model => @model
     Puppet::Indirector::Indirection.stubs(:instance).with(:my_queue).returns(@indirection)
-    @store_class = Class.new(Puppet::Indirector::Queue) do
-      def self.to_s
-        'MyQueue::MyType'
-      end
+    module MyQueue; end
+    @store_class = class MyQueue::MyType < Puppet::Indirector::Queue
+      self
     end
     @store = @store_class.new
 
diff --git a/spec/unit/indirector/rest_spec.rb b/spec/unit/indirector/rest_spec.rb
index 547e68d..326d85f 100755
--- a/spec/unit/indirector/rest_spec.rb
+++ b/spec/unit/indirector/rest_spec.rb
@@ -26,19 +26,27 @@ shared_examples_for "a REST http call" do
 end
 
 describe Puppet::Indirector::REST do
-  before do
+  before :all do
     Puppet::Indirector::Terminus.stubs(:register_terminus_class)
     @model = stub('model', :supported_formats => %w{}, :convert_from => nil)
     @instance = stub('model instance', :name= => nil)
     @indirection = stub('indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model)
-    Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
+    Puppet::Indirector::Indirection.expects(:instance).returns(@indirection)
 
-    @rest_class = Class.new(Puppet::Indirector::REST) do
-      def self.to_s
-        "This::Is::A::Test::Class"
+    module This
+      module Is
+        module A
+          module Test
+          end
+        end
       end
     end
+    @rest_class = class This::Is::A::Test::Class < Puppet::Indirector::REST
+      self
+    end
+  end
 
+  before :each do
     @response = stub('mock response', :body => 'result', :code => "200")
     @response.stubs(:[]).with('content-type').returns "text/plain"
     @response.stubs(:[]).with('content-encoding').returns nil
diff --git a/spec/unit/indirector/ssl_file_spec.rb b/spec/unit/indirector/ssl_file_spec.rb
index 4549127..ca97cf4 100755
--- a/spec/unit/indirector/ssl_file_spec.rb
+++ b/spec/unit/indirector/ssl_file_spec.rb
@@ -8,15 +8,16 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
 require 'puppet/indirector/ssl_file'
 
 describe Puppet::Indirector::SslFile do
-  before do
-    @model = mock 'model'
+  before :all do
     @indirection = stub 'indirection', :name => :testing, :model => @model
     Puppet::Indirector::Indirection.expects(:instance).with(:testing).returns(@indirection)
-    @file_class = Class.new(Puppet::Indirector::SslFile) do
-      def self.to_s
-        "Testing::Mytype"
-      end
+    module Testing; end
+    @file_class = class Testing::MyType < Puppet::Indirector::SslFile
+      self
     end
+  end
+  before :each do
+    @model = mock 'model'
 
     @setting = :certdir
     @file_class.store_in @setting
diff --git a/spec/unit/indirector/yaml_spec.rb b/spec/unit/indirector/yaml_spec.rb
index 3501799..188e300 100755
--- a/spec/unit/indirector/yaml_spec.rb
+++ b/spec/unit/indirector/yaml_spec.rb
@@ -5,14 +5,15 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
 require 'puppet/indirector/yaml'
 
 describe Puppet::Indirector::Yaml, " when choosing file location" do
-  before :each do
+  before :all do
     @indirection = stub 'indirection', :name => :my_yaml, :register_terminus_type => nil
-    Puppet::Indirector::Indirection.stubs(:instance).with(:my_yaml).returns(@indirection)
-    @store_class = Class.new(Puppet::Indirector::Yaml) do
-      def self.to_s
-        "MyYaml::MyType"
-      end
+    Puppet::Indirector::Indirection.expects(:instance).with(:my_yaml).returns(@indirection)
+    module MyYaml; end
+    @store_class = class MyYaml::MyType < Puppet::Indirector::Yaml
+      self
     end
+  end
+  before :each do
     @store = @store_class.new
 
     @subject = Object.new

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list