summaryrefslogtreecommitdiffstats
path: root/spec/unit/network/http/mongrel
diff options
context:
space:
mode:
authorRick Bradley <rick@rickbradley.com>2007-10-16 10:15:14 -0500
committerRick Bradley <rick@rickbradley.com>2007-10-16 10:15:14 -0500
commitc06edda4c94ef9aa685ed44d7031bb39c4a2b0cc (patch)
treec8fedbe14686ac205c212258ac526cd6483982c8 /spec/unit/network/http/mongrel
parentab4c7fa825e0d1f702adc215c7ff6d445d3b6559 (diff)
downloadpuppet-c06edda4c94ef9aa685ed44d7031bb39c4a2b0cc.tar.gz
puppet-c06edda4c94ef9aa685ed44d7031bb39c4a2b0cc.tar.xz
puppet-c06edda4c94ef9aa685ed44d7031bb39c4a2b0cc.zip
First pass through initializers of {mongrel, webrick} REST handlers; hooks into Indirection to look up models from indirected names.
Diffstat (limited to 'spec/unit/network/http/mongrel')
-rw-r--r--spec/unit/network/http/mongrel/rest.rb46
-rw-r--r--spec/unit/network/http/mongrel/xmlrpc.rb0
2 files changed, 46 insertions, 0 deletions
diff --git a/spec/unit/network/http/mongrel/rest.rb b/spec/unit/network/http/mongrel/rest.rb
new file mode 100644
index 000000000..4a6524ef6
--- /dev/null
+++ b/spec/unit/network/http/mongrel/rest.rb
@@ -0,0 +1,46 @@
+#!/usr/bin/env ruby
+#
+# Created by Rick Bradley on 2007-10-16.
+# Copyright (c) 2007. All rights reserved.
+
+require File.dirname(__FILE__) + '/../../../../spec_helper'
+require 'puppet/network/http'
+
+describe Puppet::Network::HTTP::MongrelREST, "when initializing" do
+ before do
+ @mock_mongrel = mock('Mongrel server')
+ @params = { :server => @mock_mongrel, :handlers => [ :foo ] }
+ end
+
+ it "should require access to a Mongrel server" do
+ Proc.new { Puppet::Network::HTTP::MongrelREST.new(@params.delete_if {|k,v| :server == k })}.should raise_error(ArgumentError)
+ end
+
+ it "should require at least one indirection name" do
+ Proc.new { Puppet::Network::HTTP::MongrelREST.new(@params.delete_if {|k,v| :handlers == k })}.should raise_error(ArgumentError)
+ end
+
+ it "should look up the indirection model from the indirection name" do
+ mock_model = mock('indirected model')
+ Puppet::Indirector::Indirection.expects(:model).with(:foo).returns(mock_model)
+ Puppet::Network::HTTP::MongrelREST.new(@params)
+ end
+
+ it "should fail if a handler is not indirected" do
+ Puppet::Indirector::Indirection.expects(:model).with(:foo).returns(nil)
+ Proc.new { Puppet::Network::HTTP::MongrelREST.new(@params) }.should raise_error(ArgumentError)
+ end
+
+ it "should register a listener for each indirection with the provided Mongrel server"
+end
+
+describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do
+ it "should unpack request information from Mongrel"
+ it "should unpack parameters from the request for passing to controller methods"
+ it "should call the controller find method if the request represents a singular HTTP GET"
+ it "should call the controller search method if the request represents a plural HTTP GET"
+ it "should call the controller destroy method if the request represents an HTTP DELETE"
+ it "should call the controller save method if the request represents an HTTP PUT"
+ it "should serialize the result from the controller method for return back to Mongrel"
+ it "should serialize a controller expection result for return back to Mongrel"
+end
diff --git a/spec/unit/network/http/mongrel/xmlrpc.rb b/spec/unit/network/http/mongrel/xmlrpc.rb
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/spec/unit/network/http/mongrel/xmlrpc.rb