summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Bradley <rick@rickbradley.com>2007-10-16 15:56:03 -0500
committerRick Bradley <rick@rickbradley.com>2007-10-16 15:56:03 -0500
commitce349683b76ab9d21f4d89e2ec818c0755848a1d (patch)
tree9d57f4d6afdd960c163673bebec21c5aab2ae382
parent6cd0f371065da901d8cc3143d8859a389ca87582 (diff)
downloadpuppet-ce349683b76ab9d21f4d89e2ec818c0755848a1d.tar.gz
puppet-ce349683b76ab9d21f4d89e2ec818c0755848a1d.tar.xz
puppet-ce349683b76ab9d21f4d89e2ec818c0755848a1d.zip
Make the actual runtime be more robust when mongrel is not installed.
-rw-r--r--lib/puppet/network/http.rb5
-rw-r--r--spec/unit/network/http.rb7
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/puppet/network/http.rb b/lib/puppet/network/http.rb
index 044310d8e..062c67c71 100644
--- a/lib/puppet/network/http.rb
+++ b/lib/puppet/network/http.rb
@@ -1,7 +1,10 @@
class Puppet::Network::HTTP
def self.server_class_by_type(kind)
return Puppet::Network::HTTP::WEBrick if kind.to_sym == :webrick
- return Puppet::Network::HTTP::Mongrel if kind.to_sym == :mongrel
+ if kind.to_sym == :mongrel
+ raise ArgumentError, "Mongrel is not installed on this platform" unless Puppet.features.mongrel?
+ return Puppet::Network::HTTP::Mongrel
+ end
raise ArgumentError, "Unknown HTTP server name [#{kind}]"
end
end
diff --git a/spec/unit/network/http.rb b/spec/unit/network/http.rb
index 450d15487..cb99d4d4c 100644
--- a/spec/unit/network/http.rb
+++ b/spec/unit/network/http.rb
@@ -15,7 +15,12 @@ describe Puppet::Network::HTTP do
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)
end
-
+
+ it "should fail to return the mongrel HTTP server class if mongrel is not available " do
+ Puppet.features.expects(:mongrel?).returns(false)
+ Proc.new { Puppet::Network::HTTP.server_class_by_type(:mongrel) }.should raise_error(ArgumentError)
+ end
+
it "should return an error when asked for an unknown server" do
Proc.new { Puppet::Network::HTTP.server_class_by_type :foo }.should raise_error(ArgumentError)
end