summaryrefslogtreecommitdiffstats
path: root/spec/unit/network/http/mongrel.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/network/http/mongrel.rb')
-rw-r--r--spec/unit/network/http/mongrel.rb36
1 files changed, 31 insertions, 5 deletions
diff --git a/spec/unit/network/http/mongrel.rb b/spec/unit/network/http/mongrel.rb
index f964e6844..6c8b65582 100644
--- a/spec/unit/network/http/mongrel.rb
+++ b/spec/unit/network/http/mongrel.rb
@@ -18,7 +18,7 @@ describe Puppet::Network::HTTP::Mongrel, "when turning on listening" do
@mock_mongrel = mock('mongrel')
@mock_mongrel.stubs(:run)
Mongrel::HttpServer.stubs(:new).returns(@mock_mongrel)
- @listen_params = { :address => "127.0.0.1", :port => 31337, :handlers => { :foo => :bar }}
+ @listen_params = { :address => "127.0.0.1", :port => 31337, :handlers => [ :node, :configuration ], :protocols => [ :rest, :xmlrpc ] }
end
it "should fail if already listening" do
@@ -30,6 +30,10 @@ describe Puppet::Network::HTTP::Mongrel, "when turning on listening" do
Proc.new { @server.listen(@listen_params.delete_if {|k,v| :handlers == k}) }.should raise_error(ArgumentError)
end
+ it "should require at least one protocol" do
+ Proc.new { @server.listen(@listen_params.delete_if {|k,v| :protocols == k}) }.should raise_error(ArgumentError)
+ end
+
it "should require a listening address to be specified" do
Proc.new { @server.listen(@listen_params.delete_if {|k,v| :address == k})}.should raise_error(ArgumentError)
end
@@ -56,8 +60,31 @@ describe Puppet::Network::HTTP::Mongrel, "when turning on listening" do
@server.should be_listening
end
- it "should instantiate a specific handler (mongrel+rest, e.g.) for each handler, for each protocol being served (xmlrpc, rest, etc.)"
- it "should mount handlers on a mongrel path"
+ it "should instantiate a specific handler (mongrel+rest, e.g.) for each named handler, for each named protocol)" do
+ @listen_params[:handlers].each do |handler|
+ @listen_params[:protocols].each do |protocol|
+ mock_handler = mock("handler instance for [#{protocol}]+[#{handler}]")
+ mock_handler_class = mock("handler class for [#{protocol}]+[#{handler}]")
+ mock_handler_class.expects(:new).returns(mock_handler)
+ @server.expects(:class_for_protocol_handler).with(protocol, handler).returns(mock_handler_class)
+ end
+ end
+ @server.listen(@listen_params)
+ end
+
+ it "should mount each handler on a mongrel path" do
+ pending "a moment of clarity"
+ @listen_params[:handlers].each do |handler|
+ @listen_params[:protocols].each do |protocol|
+ mock_handler = mock("handler instance for [#{protocol}]+[#{handler}]")
+ mock_handler_class = mock("handler class for [#{protocol}]+[#{handler}]")
+ mock_handler_class.stubs(:new).returns(mock_handler)
+ @server.stubs(:class_for_protocol_handler).with(protocol, handler).returns(mock_handler_class)
+ # TODO / FIXME : HERE -- need to begin resolving the model behind the indirection
+ end
+ end
+ @server.listen(@listen_params)
+ end
end
describe Puppet::Network::HTTP::Mongrel, "when turning off listening" do
@@ -65,9 +92,8 @@ describe Puppet::Network::HTTP::Mongrel, "when turning off listening" do
@mock_mongrel = mock('mongrel httpserver')
@mock_mongrel.stubs(:run)
Mongrel::HttpServer.stubs(:new).returns(@mock_mongrel)
-
@server = Puppet::Network::HTTP::Mongrel.new
- @listen_params = { :address => "127.0.0.1", :port => 31337, :handlers => { :foo => :bar }}
+ @listen_params = { :address => "127.0.0.1", :port => 31337, :handlers => [ :node, :configuration ], :protocols => [ :rest, :xmlrpc ] }
end
it "should fail unless listening" do