diff options
author | Luke Kanies <luke@madstop.com> | 2009-02-25 17:29:42 -0800 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-03-20 18:27:07 +1100 |
commit | ff9c3ca4059a63523b07d89f1b967f6bf1c4bba4 (patch) | |
tree | e9f1692d21e1c868ae12aaae9c54f342a6ef3173 /spec/unit | |
parent | 87ec08e5d5efe1576e338861bc514b7b5c2a6d6a (diff) | |
download | puppet-ff9c3ca4059a63523b07d89f1b967f6bf1c4bba4.tar.gz puppet-ff9c3ca4059a63523b07d89f1b967f6bf1c4bba4.tar.xz puppet-ff9c3ca4059a63523b07d89f1b967f6bf1c4bba4.zip |
Adding tests for the REST query string usage
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit')
-rwxr-xr-x | spec/unit/indirector/rest.rb | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/spec/unit/indirector/rest.rb b/spec/unit/indirector/rest.rb index 8ed50d300..8710d77b8 100755 --- a/spec/unit/indirector/rest.rb +++ b/spec/unit/indirector/rest.rb @@ -244,6 +244,12 @@ describe Puppet::Indirector::REST do @searcher.find(@request) end + it "should include the query string" do + @searcher.expects(:query_string).with(@request).returns "?my_string" + @connection.expects(:get).with { |path, args| path.include?("?my_string") }.returns(@response) + @searcher.find(@request) + end + it "should provide an Accept header containing the list of supported formats joined with commas" do @connection.expects(:get).with { |path, args| args["Accept"] == "supported, formats" }.returns(@response) @@ -298,11 +304,9 @@ describe Puppet::Indirector::REST do @searcher.search(@request) end - it "should include all options in the query string" do - @request.stubs(:options).returns(:one => "two", :three => "four") - - should_path = "/%s/%s" % [@indirection.name.to_s, "foo"] - @connection.expects(:get).with { |path, args| path =~ /\?one=two&three=four$/ or path =~ /\?three=four&one=two$/ }.returns(@response) + it "should include the query string" do + @searcher.expects(:query_string).with(@request).returns "?my_string" + @connection.expects(:get).with { |path, args| path.include?("?my_string") }.returns(@response) @searcher.search(@request) end @@ -358,6 +362,12 @@ describe Puppet::Indirector::REST do @searcher.destroy(@request) end + it "should not include the query string" do + @searcher.expects(:query_string).never + @connection.stubs(:delete).returns @response + @searcher.destroy(@request) + end + it "should provide an Accept header containing the list of supported formats joined with commas" do @connection.expects(:delete).with { |path, args| args["Accept"] == "supported, formats" }.returns(@response) @@ -403,6 +413,12 @@ describe Puppet::Indirector::REST do @searcher.save(@request) end + it "should not include the query string" do + @searcher.expects(:query_string).never + @connection.stubs(:put).returns @response + @searcher.save(@request) + end + it "should serialize the instance using the default format and pass the result as the body of the request" do @instance.expects(:render).returns "serial_instance" @connection.expects(:put).with { |path, data, args| data == "serial_instance" }.returns @response |