summaryrefslogtreecommitdiffstats
path: root/spec/unit/network/http/mongrel
diff options
context:
space:
mode:
authorRick Bradley <rick@rickbradley.com>2007-10-16 11:13:17 -0500
committerRick Bradley <rick@rickbradley.com>2007-10-16 11:13:17 -0500
commitb8c877c121f6b376cd44b13cb90d69c41d0fb004 (patch)
tree703a7a66f7d54618fb001e5be6b003dcc0900796 /spec/unit/network/http/mongrel
parent3c370b3570d39c18799085793e083898cda72e68 (diff)
Registration now built for {webrick,mongrel} REST handlers.
Diffstat (limited to 'spec/unit/network/http/mongrel')
-rw-r--r--spec/unit/network/http/mongrel/rest.rb24
1 files changed, 19 insertions, 5 deletions
diff --git a/spec/unit/network/http/mongrel/rest.rb b/spec/unit/network/http/mongrel/rest.rb
index 46a82183b..49562e866 100644
--- a/spec/unit/network/http/mongrel/rest.rb
+++ b/spec/unit/network/http/mongrel/rest.rb
@@ -9,6 +9,9 @@ require 'puppet/network/http'
describe Puppet::Network::HTTP::MongrelREST, "when initializing" do
before do
@mock_mongrel = mock('Mongrel server')
+ @mock_mongrel.stubs(:register)
+ @mock_model = mock('indirected model')
+ Puppet::Indirector::Indirection.stubs(:model).with(:foo).returns(@mock_model)
@params = { :server => @mock_mongrel, :handler => :foo }
end
@@ -21,17 +24,28 @@ describe Puppet::Network::HTTP::MongrelREST, "when initializing" do
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::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
+ it "should fail if the indirection is not known" 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"
+
+ it "should register itself with the mongrel server for the singular HTTP methods" do
+ @mock_mongrel.expects(:register).with do |*args|
+ args.first == '/foo' and args.last.is_a? Puppet::Network::HTTP::MongrelREST
+ end
+ Puppet::Network::HTTP::MongrelREST.new(@params)
+ end
+
+ it "should register itself with the mongrel server for the plural GET method" do
+ @mock_mongrel.expects(:register).with do |*args|
+ args.first == '/foos' and args.last.is_a? Puppet::Network::HTTP::MongrelREST
+ end
+ Puppet::Network::HTTP::MongrelREST.new(@params)
+ end
end
describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do