diff options
| author | Luke Kanies <luke@madstop.com> | 2008-07-21 17:19:17 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-07-29 00:47:02 -0500 |
| commit | bf5b086ca7fb89f941873e95feae2fc2b259037a (patch) | |
| tree | 7f340bf518148e6a528d5ff13f8d0103e47fc549 /spec/unit | |
| parent | 1f15725263812be347c42a2ea3777fee7b2129c9 (diff) | |
| download | puppet-bf5b086ca7fb89f941873e95feae2fc2b259037a.tar.gz puppet-bf5b086ca7fb89f941873e95feae2fc2b259037a.tar.xz puppet-bf5b086ca7fb89f941873e95feae2fc2b259037a.zip | |
The REST terminus now provides an Accept header with supported formats.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit')
| -rwxr-xr-x | spec/unit/indirector/rest.rb | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/spec/unit/indirector/rest.rb b/spec/unit/indirector/rest.rb index 1f802b603..4a3b9d2d0 100755 --- a/spec/unit/indirector/rest.rb +++ b/spec/unit/indirector/rest.rb @@ -39,7 +39,7 @@ end describe Puppet::Indirector::REST do before do Puppet::Indirector::Terminus.stubs(:register_terminus_class) - @model = stub('model') + @model = stub('model', :supported_formats => %w{}) @instance = stub('model instance') @indirection = stub('indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model) Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection) @@ -91,7 +91,17 @@ describe Puppet::Indirector::REST do it "should use the provided path" do @mock_result = stub('mock result', :body => 'result') @mock_connection = stub('mock http connection') - @mock_connection.expects(:get).with('/foo').returns(@mock_result) + @mock_connection.expects(:get).with { |path, args| path == '/foo' }.returns(@mock_result) + @searcher.stubs(:network).returns(@mock_connection) + @searcher.network_fetch('foo') + end + + it "should provide an Accept header containing the list of supported formats joined with commas" do + @mock_result = stub('mock result', :body => 'result') + @mock_connection = stub('mock http connection') + @mock_connection.expects(:get).with { |path, args| args["Accept"] == "supported, formats" }.returns(@mock_result) + + @searcher.model.expects(:supported_formats).returns %w{supported formats} @searcher.stubs(:network).returns(@mock_connection) @searcher.network_fetch('foo') end @@ -111,10 +121,20 @@ describe Puppet::Indirector::REST do it "should use the DELETE http method" do @mock_result = stub('mock result', :body => 'result') - @mock_connection = mock('mock http connection', :delete => @mock_result) + @mock_connection = mock('mock http connection') + @mock_connection.expects(:delete).with { |path, args| path == '/foo' }.returns @mock_result @searcher.stubs(:network).returns(@mock_connection) @searcher.network_delete('foo') end + + it "should provide an Accept header containing the list of supported formats joined with commas" do + @mock_result = stub('mock result', :body => 'result') + @mock_connection = mock('mock http connection') + @mock_connection.expects(:delete).with { |path, args| args['Accept'] == "supported, formats" }.returns @mock_result + @searcher.stubs(:network).returns(@mock_connection) + @searcher.model.expects(:supported_formats).returns %w{supported formats} + @searcher.network_delete('foo') + end end describe "when doing a network put" do @@ -140,7 +160,7 @@ describe Puppet::Indirector::REST do it "should use the provided path" do @mock_result = stub('mock result', :body => 'result') @mock_connection = stub('mock http connection') - @mock_connection.expects(:put).with {|path, data| path == '/foo' }.returns(@mock_result) + @mock_connection.expects(:put).with {|path, data, args| path == '/foo' }.returns(@mock_result) @searcher.stubs(:network).returns(@mock_connection) @searcher.network_put('foo', @data) end @@ -148,10 +168,19 @@ describe Puppet::Indirector::REST do it "should use the provided data" do @mock_result = stub('mock result', :body => 'result') @mock_connection = stub('mock http connection') - @mock_connection.expects(:put).with {|path, data| data == @data }.returns(@mock_result) + @mock_connection.expects(:put).with {|path, data, args| data == @data }.returns(@mock_result) @searcher.stubs(:network).returns(@mock_connection) @searcher.network_put('foo', @data) end + + it "should provide an Accept header containing the list of supported formats joined with commas" do + @mock_result = stub('mock result', :body => 'result') + @mock_connection = mock('mock http connection') + @mock_connection.expects(:put).with { |path, data, args| args['Accept'] == "supported, formats" }.returns @mock_result + @searcher.stubs(:network).returns(@mock_connection) + @searcher.model.expects(:supported_formats).returns %w{supported formats} + @searcher.network_put('foo', @data) + end end describe "when doing a find" do |
