diff options
| author | Rick Bradley <rick@rickbradley.com> | 2007-10-15 12:04:30 -0500 |
|---|---|---|
| committer | Rick Bradley <rick@rickbradley.com> | 2007-10-15 12:04:30 -0500 |
| commit | ec71e05a162ec299982b90707cc16231c608997b (patch) | |
| tree | c16376f369f5ad880b17f47888c9cea33a9008bb /spec/unit/network/http | |
| parent | 31384fea2263d9ee0e65312b4a0b956436022e63 (diff) | |
More unit specs for mongrel and webrick; more code to make them work, yo.
Diffstat (limited to 'spec/unit/network/http')
| -rw-r--r-- | spec/unit/network/http/mongrel.rb | 53 | ||||
| -rw-r--r-- | spec/unit/network/http/webrick.rb | 52 |
2 files changed, 105 insertions, 0 deletions
diff --git a/spec/unit/network/http/mongrel.rb b/spec/unit/network/http/mongrel.rb new file mode 100644 index 000000000..3e40efe79 --- /dev/null +++ b/spec/unit/network/http/mongrel.rb @@ -0,0 +1,53 @@ +#!/usr/bin/env ruby +# +# Created by Rick Bradley on 2007-10-15. +# Copyright (c) 2007. All rights reserved. + +require File.dirname(__FILE__) + '/../../../spec_helper' +require 'puppet/network/http' + +describe Puppet::Network::HTTP::Mongrel, "when turning on listening" do + before do + @server = Puppet::Network::HTTP::Mongrel.new + end + + it "should fail if already listening" do + @server.listen(:foo => :bar) + Proc.new { @server.listen(:foo => :bar) }.should raise_error(RuntimeError) + end + + it "should require at least one handler" do + Proc.new { @server.listen }.should raise_error(ArgumentError) + end + + it "should order a mongrel server to start" do + mock_mongrel = mock('mongrel httpserver') + mock_mongrel.expects(:run) + Mongrel::HttpServer.expects(:new).returns(mock_mongrel) + @server.listen(:foo => :bar) + 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 be able to specify the address on which mongrel will listen" + it "should be able to specify the port on which mongrel will listen" +end + +describe Puppet::Network::HTTP::WEBRick, "when turning off listening" do + before do + @mock_mongrel = mock('mongrel httpserver') + @mock_mongrel.stubs(:run) + Mongrel::HttpServer.stubs(:new).returns(@mock_mongrel) + @server = Puppet::Network::HTTP::Mongrel.new + end + + it "should fail unless listening" do + Proc.new { @server.unlisten }.should raise_error(RuntimeError) + end + + it "should order mongrel server to stop" do + @server.listen(:foo => :bar) + @mock_mongrel.expects(:graceful_shutdown) + @server.unlisten + end +end diff --git a/spec/unit/network/http/webrick.rb b/spec/unit/network/http/webrick.rb new file mode 100644 index 000000000..d162288fc --- /dev/null +++ b/spec/unit/network/http/webrick.rb @@ -0,0 +1,52 @@ +#!/usr/bin/env ruby +# +# Created by Rick Bradley on 2007-10-15. +# Copyright (c) 2007. All rights reserved. + +require File.dirname(__FILE__) + '/../../../spec_helper' +require 'puppet/network/http' + +describe Puppet::Network::HTTP::WEBRick, "when turning on listening" do + before do + @server = Puppet::Network::HTTP::WEBRick.new + end + + it "should fail if already listening" do + Puppet.stubs(:start) + @server.listen(:foo => :bar) + Proc.new { @server.listen(:foo => :bar) }.should raise_error(RuntimeError) + end + + it "should require at least one handler" do + Proc.new { @server.listen }.should raise_error(ArgumentError) + end + + it "should order a webrick server to start" do + Puppet.expects(:start) + @server.listen(:foo => :bar) + end + + it "should instantiate a specific handler (webrick+rest, e.g.) for each handler, for each protocol being served (xmlrpc, rest, etc.)" + it "should mount handlers on a webrick path" + + it "should be able to specify the address on which webrick will listen" + it "should be able to specify the port on which webrick will listen" +end + +describe Puppet::Network::HTTP::WEBRick, "when turning off listening" do + before do + @server = Puppet::Network::HTTP::WEBRick.new + end + + it "should fail unless listening" do + Proc.new { @server.unlisten }.should raise_error(RuntimeError) + end + + it "should order webrick server to stop" do + Puppet.stubs(:start).returns(true) + @server.should respond_to(:shutdown) + @server.expects(:shutdown) + @server.listen(:foo => :bar) + @server.unlisten + end +end |
