Here were the main changes necessary:
* Fixed the class loader so it only loads mongrel if it's available.
* Fixed the test runner to skip example groups contained in non-runnable
  example groups.
* Fixed the Mongrel tests to use quoted class names instead of constants,
  since the constants themselves would be absent.

Signed-off-by: Luke Kanies <[EMAIL PROTECTED]>
---
 lib/puppet/network/http.rb             |   14 ++++++++------
 spec/integration/indirector/rest.rb    |    4 ++--
 spec/unit/network/http.rb              |   12 +++++++++---
 spec/unit/network/http/mongrel.rb      |    6 +++---
 spec/unit/network/http/mongrel/rest.rb |   16 ++++++++++++++--
 spec/unit/network/http/webrick.rb      |    1 +
 spec/unit/network/http/webrick/rest.rb |    1 +
 test/lib/puppettest/runnable_test.rb   |    3 +++
 8 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/lib/puppet/network/http.rb b/lib/puppet/network/http.rb
index 062c67c..c219859 100644
--- a/lib/puppet/network/http.rb
+++ b/lib/puppet/network/http.rb
@@ -1,13 +1,15 @@
 class Puppet::Network::HTTP
     def self.server_class_by_type(kind)
-        return Puppet::Network::HTTP::WEBrick if kind.to_sym == :webrick
-        if kind.to_sym == :mongrel
+        case kind.to_sym
+        when :webrick:
+            require 'puppet/network/http/webrick'
+            return Puppet::Network::HTTP::WEBrick
+        when :mongrel:
             raise ArgumentError, "Mongrel is not installed on this platform" 
unless Puppet.features.mongrel?
+            require 'puppet/network/http/mongrel'
             return Puppet::Network::HTTP::Mongrel 
+        else
+            raise ArgumentError, "Unknown HTTP server name [#{kind}]"
         end
-        raise ArgumentError, "Unknown HTTP server name [#{kind}]"
     end
 end
-
-require 'puppet/network/http/webrick'
-require 'puppet/network/http/mongrel'
diff --git a/spec/integration/indirector/rest.rb 
b/spec/integration/indirector/rest.rb
index 7edd0b8..9efcdcb 100755
--- a/spec/integration/indirector/rest.rb
+++ b/spec/integration/indirector/rest.rb
@@ -118,7 +118,7 @@ describe Puppet::Indirector::REST do
                 end
     
                 it 'should return the instance of the model class associated 
with the provided lookup key' do
-                    
Puppet::TestIndirectedFoo.search('bar').collect(&:value).should == 
@model_instances.collect(&:value)
+                    Puppet::TestIndirectedFoo.search('bar').collect { |i| 
i.value }.should == @model_instances.collect { |i| i.value }
                 end
     
                 it 'should set a version timestamp on model instances' do
@@ -334,7 +334,7 @@ describe Puppet::Indirector::REST do
                 end
     
                 it 'should return the instance of the model class associated 
with the provided lookup key' do
-                    
Puppet::TestIndirectedFoo.search('bar').collect(&:value).should == 
@model_instances.collect(&:value)
+                    Puppet::TestIndirectedFoo.search('bar').collect { |i| 
i.value }.should == @model_instances.collect { |i| i.value }
                 end
     
                 it 'should set an expiration on model instances' do
diff --git a/spec/unit/network/http.rb b/spec/unit/network/http.rb
index 79a0a88..1fa025b 100755
--- a/spec/unit/network/http.rb
+++ b/spec/unit/network/http.rb
@@ -12,9 +12,15 @@ describe Puppet::Network::HTTP do
         Puppet::Network::HTTP.server_class_by_type(:webrick).should 
be(Puppet::Network::HTTP::WEBrick)
     end
     
-    if Puppet.features.mongrel?
-        it "should return the mongrel HTTP server class when asked for a 
mongrel server" do
-            Puppet::Network::HTTP.server_class_by_type(:mongrel).should 
be(Puppet::Network::HTTP::Mongrel)
+    describe "when asked for a mongrel server" do
+        if Puppet.features.mongrel?
+            it "should return the mongrel server class" do
+                Puppet::Network::HTTP.server_class_by_type(:mongrel).should 
be(Puppet::Network::HTTP::Mongrel)
+            end
+        else
+            it "should fail" do
+                lambda { Puppet::Network::HTTP.server_class_by_type(:mongrel) 
}.should raise_error(ArgumentError)
+            end
         end
     end
     
diff --git a/spec/unit/network/http/mongrel.rb 
b/spec/unit/network/http/mongrel.rb
index ccfca2f..3a9cfb5 100755
--- a/spec/unit/network/http/mongrel.rb
+++ b/spec/unit/network/http/mongrel.rb
@@ -6,7 +6,7 @@
 require File.dirname(__FILE__) + '/../../../spec_helper'
 require 'puppet/network/http'
 
-describe Puppet::Network::HTTP::Mongrel, "after initializing" do
+describe "Puppet::Network::HTTP::Mongrel", "after initializing" do
     confine "Mongrel is not available" => Puppet.features.mongrel?
     
     it "should not be listening" do
@@ -14,7 +14,7 @@ describe Puppet::Network::HTTP::Mongrel, "after initializing" 
do
     end
 end
 
-describe Puppet::Network::HTTP::Mongrel, "when turning on listening" do
+describe "Puppet::Network::HTTP::Mongrel", "when turning on listening" do
     confine "Mongrel is not available" => Puppet.features.mongrel?
 
     before do
@@ -82,7 +82,7 @@ describe Puppet::Network::HTTP::Mongrel, "when turning on 
listening" do
     end
 end
 
-describe Puppet::Network::HTTP::Mongrel, "when turning off listening" do
+describe "Puppet::Network::HTTP::Mongrel", "when turning off listening" do
     confine "Mongrel is not available" => Puppet.features.mongrel?
     
     before do
diff --git a/spec/unit/network/http/mongrel/rest.rb 
b/spec/unit/network/http/mongrel/rest.rb
index 3df9251..de5254a 100755
--- a/spec/unit/network/http/mongrel/rest.rb
+++ b/spec/unit/network/http/mongrel/rest.rb
@@ -3,10 +3,12 @@
 require File.dirname(__FILE__) + '/../../../../spec_helper'
 require 'puppet/network/http'
 
-describe Puppet::Network::HTTP::MongrelREST, "when initializing" do
+describe "Puppet::Network::HTTP::MongrelREST", "when initializing" do
     confine "Mongrel is not available" => Puppet.features.mongrel?
 
     before do
+        require 'puppet/network/http/mongrel/rest'
+
         @mock_mongrel = mock('Mongrel server')
         @mock_mongrel.stubs(:register)
         @mock_model = mock('indirected model')
@@ -33,7 +35,7 @@ describe Puppet::Network::HTTP::MongrelREST, "when 
initializing" do
     end
 end
 
-describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do
+describe "Puppet::Network::HTTP::MongrelREST", "when receiving a request" do
     confine "Mongrel is not available" => Puppet.features.mongrel?
 
     before do
@@ -131,6 +133,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when 
receiving a request" do
     end
 
     describe "and determining the request parameters", :shared => true do
+        confine "Mongrel is not available" => Puppet.features.mongrel?
+
         before do
             @mock_request.stubs(:params).returns({})
         end
@@ -198,6 +202,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when 
receiving a request" do
     end
 
     describe "when finding a model instance" do |variable|
+        confine "Mongrel is not available" => Puppet.features.mongrel?
+
         it "should fail to find model if key is not specified" do
             @mock_request.stubs(:params).returns({ 
Mongrel::Const::REQUEST_METHOD => 'GET', Mongrel::Const::REQUEST_PATH => 
'/foo'})
             @mock_response.expects(:start).with(404)
@@ -236,6 +242,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when 
receiving a request" do
     end
 
     describe "when destroying a model instance" do |variable|
+        confine "Mongrel is not available" => Puppet.features.mongrel?
+
         it "should fail to destroy model if key is not specified" do
             @mock_request.stubs(:params).returns({ 
Mongrel::Const::REQUEST_METHOD => 'DELETE', Mongrel::Const::REQUEST_PATH => 
'/foo'})
             @mock_response.expects(:start).with(404)
@@ -281,6 +289,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when 
receiving a request" do
     end
 
     describe "when saving a model instance" do |variable|    
+        confine "Mongrel is not available" => Puppet.features.mongrel?
+
         it "should fail to save model if data is not specified" do
             @mock_request.stubs(:params).returns({ 
Mongrel::Const::REQUEST_METHOD => 'PUT', Mongrel::Const::REQUEST_PATH => 
'/foo'})
             @mock_request.stubs(:body).returns('')
@@ -319,6 +329,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when 
receiving a request" do
     end
 
     describe "when searching for model instances" do |variable|
+        confine "Mongrel is not available" => Puppet.features.mongrel?
+
         it "should use a common method for determining the request parameters" 
do
             setup_search_request('QUERY_STRING' => 'foo=baz&bar=xyzzy')
             @handler.expects(:params).returns(:foo => :baz, :bar => :xyzzy)
diff --git a/spec/unit/network/http/webrick.rb 
b/spec/unit/network/http/webrick.rb
index 78bd391..9b024ae 100755
--- a/spec/unit/network/http/webrick.rb
+++ b/spec/unit/network/http/webrick.rb
@@ -5,6 +5,7 @@
 
 require File.dirname(__FILE__) + '/../../../spec_helper'
 require 'puppet/network/http'
+require 'puppet/network/http/webrick'
 
 describe Puppet::Network::HTTP::WEBrick, "after initializing" do
     it "should not be listening" do
diff --git a/spec/unit/network/http/webrick/rest.rb 
b/spec/unit/network/http/webrick/rest.rb
index 45e5f0b..17d47e5 100755
--- a/spec/unit/network/http/webrick/rest.rb
+++ b/spec/unit/network/http/webrick/rest.rb
@@ -2,6 +2,7 @@
 
 require File.dirname(__FILE__) + '/../../../../spec_helper'
 require 'puppet/network/http'
+require 'puppet/network/http/webrick/rest'
 
 describe Puppet::Network::HTTP::WEBrickREST, "when initializing" do
     before do
diff --git a/test/lib/puppettest/runnable_test.rb 
b/test/lib/puppettest/runnable_test.rb
index e4b0f90..e3cde50 100644
--- a/test/lib/puppettest/runnable_test.rb
+++ b/test/lib/puppettest/runnable_test.rb
@@ -15,6 +15,9 @@ module PuppetTest
         # Evaluate all of our tests to see if any of them are false
         # and thus whether this test is considered not runnable.
         def runnable?
+            if superclass.respond_to?(:runnable?) and ! superclass.runnable?
+                return false
+            end
             @messages ||= []
             return false unless @messages.empty?
             return true unless defined? @confines
-- 
1.5.3.7


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

Reply via email to