summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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