summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorRick Bradley <rick@rickbradley.com>2008-04-02 20:41:16 -0500
committerLuke Kanies <luke@madstop.com>2008-04-11 13:11:28 -0500
commitaed13754459e11bcc04a0b14228f5f53b4cd4c4c (patch)
tree68fbdb393a7217aa4646e17a50ac86f8c50d579b /spec
parent75bf05d516ebdace19703c1c1bca5d2cc65d1001 (diff)
downloadpuppet-aed13754459e11bcc04a0b14228f5f53b4cd4c4c.tar.gz
puppet-aed13754459e11bcc04a0b14228f5f53b4cd4c4c.tar.xz
puppet-aed13754459e11bcc04a0b14228f5f53b4cd4c4c.zip
make sure unit indirector specs are working with #save; fill out network_put pending specs
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/indirector/rest.rb56
1 files changed, 53 insertions, 3 deletions
diff --git a/spec/unit/indirector/rest.rb b/spec/unit/indirector/rest.rb
index fb3790e0c..38ab0d634 100755
--- a/spec/unit/indirector/rest.rb
+++ b/spec/unit/indirector/rest.rb
@@ -41,6 +41,17 @@ describe Puppet::Indirector::REST do
it "should use the escaped provided path"
it "should return the results of the DELETE request"
end
+
+ describe "when doing a network put" do
+ it "should escape the provided path"
+ it "should look up the appropriate remote server"
+ it "should look up the appropriate remote port"
+ it "should use the delete http method"
+ it "should use the appropriate remote server"
+ it "should use the appropriate remote port"
+ it "should use the escaped provided path"
+ it "should return the results of the DELETE request"
+ end
describe "when doing a find" do
before :each do
@@ -165,8 +176,47 @@ describe Puppet::Indirector::REST do
end
describe "when doing a save" do
- it "should deserialize result data into a boolean"
- it "should generate an error when result data deserializes improperly"
- it "should generate an error when result data specifies an error"
+ before :each do
+ @result = { :foo => 'bar'}.to_yaml
+ @searcher.stubs(:network_put).returns(@result) # neuter the network connection
+ @model.stubs(:from_yaml).returns(@instance)
+ end
+
+ it "should save the model instance over the network" do
+ @searcher.expects(:network_put).returns(@result)
+ @searcher.save(@instance)
+ end
+
+ it "should save the model instance using the named indirection" do
+ @searcher.expects(:network_put).with do |path, data|
+ path =~ %r{^#{@indirection.name.to_s}/} and
+ data == @instance.to_yaml
+ end.returns(@result)
+ @searcher.save(@instance)
+ end
+
+ it "should deserialize result data to a Model instance" do
+ @model.expects(:from_yaml)
+ @searcher.save(@instance)
+ end
+
+ it "should return the resulting deserialized Model instance" do
+ @searcher.save(@instance).should == @instance
+ end
+
+ it "should return nil when deserialized model instance is nil" do
+ @model.stubs(:from_yaml).returns(nil)
+ @searcher.save(@instance).should be_nil
+ end
+
+ it "should generate an error when result data deserializes improperly" do
+ @model.stubs(:from_yaml).raises(ArgumentError)
+ lambda { @searcher.save(@instance) }.should raise_error(ArgumentError)
+ end
+
+ it "should generate an error when result data specifies an error" do
+ @searcher.stubs(:network_put).returns(RuntimeError.new("bogus").to_yaml)
+ lambda { @searcher.save(@instance) }.should raise_error(RuntimeError)
+ end
end
end