summaryrefslogtreecommitdiffstats
path: root/spec/unit/network/http/webrick.rb
diff options
context:
space:
mode:
authorRick Bradley <rick@rickbradley.com>2007-10-15 15:04:10 -0500
committerRick Bradley <rick@rickbradley.com>2007-10-15 15:04:10 -0500
commitef8ebe0df4da0a0cd2f599308f40bd707ab18d92 (patch)
tree75f4f9b1198342b70354fbb7a755850eea77a820 /spec/unit/network/http/webrick.rb
parentc34efbccf1eec9957253d4fcdcb4ea9c79837ad8 (diff)
downloadpuppet-ef8ebe0df4da0a0cd2f599308f40bd707ab18d92.tar.gz
puppet-ef8ebe0df4da0a0cd2f599308f40bd707ab18d92.tar.xz
puppet-ef8ebe0df4da0a0cd2f599308f40bd707ab18d92.zip
Implementing address & port support for new webrick server.
Diffstat (limited to 'spec/unit/network/http/webrick.rb')
-rw-r--r--spec/unit/network/http/webrick.rb17
1 files changed, 14 insertions, 3 deletions
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