summaryrefslogtreecommitdiffstats
path: root/spec/unit/indirector
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-09-18 12:48:12 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-11-20 07:27:20 +1100
commit089ac3e37dd1418751bc4dfe152e09fbacbc5122 (patch)
tree857232720ead186d188cf94c126baf846d509692 /spec/unit/indirector
parent28e1bc6e7b866727adfd16cba5418e08f1dd2fd8 (diff)
downloadpuppet-089ac3e37dd1418751bc4dfe152e09fbacbc5122.tar.gz
puppet-089ac3e37dd1418751bc4dfe152e09fbacbc5122.tar.xz
puppet-089ac3e37dd1418751bc4dfe152e09fbacbc5122.zip
Fixing #2617 - using the searched-for REST name
This allows a separation between the wrapper class and its internals, which is (at least) necessary for the CA cert, which might not be found using the internal name. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/indirector')
-rwxr-xr-xspec/unit/indirector/rest.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/spec/unit/indirector/rest.rb b/spec/unit/indirector/rest.rb
index d98e6f5c6..d12e3c642 100755
--- a/spec/unit/indirector/rest.rb
+++ b/spec/unit/indirector/rest.rb
@@ -29,7 +29,7 @@ describe Puppet::Indirector::REST do
before do
Puppet::Indirector::Terminus.stubs(:register_terminus_class)
@model = stub('model', :supported_formats => %w{}, :convert_from => nil)
- @instance = stub('model instance')
+ @instance = stub('model instance', :name= => nil)
@indirection = stub('indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model)
Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
@@ -201,9 +201,11 @@ describe Puppet::Indirector::REST do
it "should deserialize and return the http response" do
@connection.expects(:get).returns @response
- @searcher.expects(:deserialize).with(@response).returns "myobject"
- @searcher.find(@request).should == 'myobject'
+ instance = stub 'object', :name= => nil
+ @searcher.expects(:deserialize).with(@response).returns instance
+
+ @searcher.find(@request).should == instance
end
it "should use the URI generated by the Handler module" do
@@ -224,6 +226,12 @@ describe Puppet::Indirector::REST do
@searcher.find(@request).should equal(@instance)
end
+ it "should set the name of the resulting instance to the asked-for name" do
+ @searcher.expects(:deserialize).with(@response).returns @instance
+ @instance.expects(:name=).with "foo bar"
+ @searcher.find(@request)
+ end
+
it "should generate an error when result data deserializes fails" do
@searcher.expects(:deserialize).raises(ArgumentError)
lambda { @searcher.find(@request) }.should raise_error(ArgumentError)