From ef8ebe0df4da0a0cd2f599308f40bd707ab18d92 Mon Sep 17 00:00:00 2001 From: Rick Bradley Date: Mon, 15 Oct 2007 15:04:10 -0500 Subject: Implementing address & port support for new webrick server. --- spec/unit/network/http/webrick.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/unit/network/http/webrick.rb b/spec/unit/network/http/webrick.rb index 9ab97e831..804be4c33 100644 --- a/spec/unit/network/http/webrick.rb +++ b/spec/unit/network/http/webrick.rb @@ -14,9 +14,12 @@ end describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do before do + Puppet.stubs(:start) + Puppet.stubs(:newservice) + @mock_webrick = mock('webrick') + WEBrick::HTTPServer.stubs(:new).returns(@mock_webrick) @server = Puppet::Network::HTTP::WEBrick.new @listen_params = { :address => "127.0.0.1", :port => 31337, :handlers => { :foo => :bar }} - Puppet.stubs(:start) end it "should fail if already listening" do @@ -41,7 +44,12 @@ describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do @server.listen(@listen_params) end - it "should tell webrick to listen on the specified address and port" + it "should tell webrick to listen on the specified address and port" do + WEBrick::HTTPServer.expects(:new).with {|args| + args[:Port] == 31337 and args[:BindAddress] == "127.0.0.1" + }.returns(@mock_webrick) + @server.listen(@listen_params) + end it "should be listening" do @server.listen(@listen_params) @@ -54,10 +62,13 @@ end describe Puppet::Network::HTTP::WEBrick, "when turning off listening" do before do + Puppet.stubs(:start) + Puppet.stubs(:newservice) + @mock_webrick = mock('webrick') + WEBrick::HTTPServer.stubs(:new).returns(@mock_webrick) @server = Puppet::Network::HTTP::WEBrick.new @server.stubs(:shutdown) @listen_params = { :address => "127.0.0.1", :port => 31337, :handlers => { :foo => :bar }} - Puppet.stubs(:start).returns(true) end it "should fail unless listening" do -- cgit