summaryrefslogtreecommitdiffstats
path: root/spec/unit/network/http/webrick.rb
diff options
context:
space:
mode:
authorRick Bradley <rick@rickbradley.com>2007-10-16 13:57:56 -0500
committerRick Bradley <rick@rickbradley.com>2007-10-16 13:57:56 -0500
commit2a497fff66a7827059b712e84dcaff171ccab6be (patch)
tree1e66995191c44dd3e5951f13a1dd73263bf60395 /spec/unit/network/http/webrick.rb
parent6ab78f62ee589e542fd653a54109c0f5141ea026 (diff)
downloadpuppet-2a497fff66a7827059b712e84dcaff171ccab6be.tar.gz
puppet-2a497fff66a7827059b712e84dcaff171ccab6be.tar.xz
puppet-2a497fff66a7827059b712e84dcaff171ccab6be.zip
Refactored to use a Handler base class for server+protocol handlers. Finally eliminated dependency on Puppet.start, etc., from WEBrick HTTP server class. {webrick,mongrel}+REST now support request handling uniformly; need encode/decode next.
Diffstat (limited to 'spec/unit/network/http/webrick.rb')
-rw-r--r--spec/unit/network/http/webrick.rb14
1 files changed, 4 insertions, 10 deletions
diff --git a/spec/unit/network/http/webrick.rb b/spec/unit/network/http/webrick.rb
index 9ba04f164..3ed223e7e 100644
--- a/spec/unit/network/http/webrick.rb
+++ b/spec/unit/network/http/webrick.rb
@@ -14,10 +14,8 @@ end
describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do
before do
- Puppet.stubs(:start)
- Puppet.stubs(:newservice)
@mock_webrick = mock('webrick')
- @mock_webrick.stubs(:mount)
+ [:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)}
WEBrick::HTTPServer.stubs(:new).returns(@mock_webrick)
@server = Puppet::Network::HTTP::WEBrick.new
@listen_params = { :address => "127.0.0.1", :port => 31337, :handlers => [ :node, :configuration ], :protocols => [ :rest, :xmlrpc ] }
@@ -45,7 +43,7 @@ describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do
end
it "should order a webrick server to start" do
- Puppet.expects(:start)
+ @mock_webrick.expects(:start)
@server.listen(@listen_params)
end
@@ -92,13 +90,10 @@ end
describe Puppet::Network::HTTP::WEBrick, "when turning off listening" do
before do
- Puppet.stubs(:start)
- Puppet.stubs(:newservice)
@mock_webrick = mock('webrick')
- @mock_webrick.stubs(:mount)
+ [:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)}
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 => [ :node, :configuration ], :protocols => [ :rest, :xmlrpc ] }
end
@@ -107,8 +102,7 @@ describe Puppet::Network::HTTP::WEBrick, "when turning off listening" do
end
it "should order webrick server to stop" do
- @server.should respond_to(:shutdown)
- @server.expects(:shutdown)
+ @mock_webrick.expects(:shutdown)
@server.listen(@listen_params)
@server.unlisten
end