Sha256: d82d2f38a9ff1b5a70858c66a06c9de9b27afa653312970417d01e9bc21ed587

Contents?: true

Size: 1.91 KB

Versions: 14

Compression:

Stored size: 1.91 KB

Contents

#-------------------------------------------------------------------------
# # Copyright (c) Microsoft and contributors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#--------------------------------------------------------------------------
require "test_helper"
require "azure/core/http/http_error"

describe Azure::Core::Http::HTTPError do
  let :http_response do
    double(:body=> Fixtures[:http_error], :status_code=> 409, :uri=>'http://dummy.uri')
  end

  subject do
    Azure::Core::Http::HTTPError.new(http_response)
  end

  it "is an instance of Azure::Core::Error" do
    subject.must_be_kind_of Azure::Core::Error
  end

  it "lets us see the original uri" do
    subject.uri.must_equal 'http://dummy.uri'
  end

  it "lets us see the errors'status code" do
    subject.status_code.must_equal 409
  end

  it "lets us see the error's type" do
    subject.type.must_equal "TableAlreadyExists"
  end

  it "lets us see the error's description" do
    subject.description.must_equal "The table specified already exists."
  end

  it "generates an error message that wraps both the type and description" do
    subject.message.must_equal "TableAlreadyExists (409): The table specified already exists."
  end

  it "sets the type to unknown if the response body is not an XML" do
    http_response.body = "\r\nInvalid request\r\n"

    subject.type.must_equal "Unknown"
    subject.description.must_equal "Invalid request"
  end
end

Version data entries

14 entries across 14 versions & 4 rubygems

Version Path
stuartpreston-azure-sdk-for-ruby-0.7.1 test/unit/core/http/http_error_test.rb
stuartpreston-azure-sdk-for-ruby-0.7.0 test/unit/core/http/http_error_test.rb
stuartpreston-azure-sdk-for-ruby-0.6.9 test/unit/core/http/http_error_test.rb
stuartpreston-azure-sdk-for-ruby-0.6.7 test/unit/core/http/http_error_test.rb
stuartpreston-azure-sdk-for-ruby-0.6.6 test/unit/core/http/http_error_test.rb
stuartpreston-azure-sdk-for-ruby-0.6.5 test/unit/core/http/http_error_test.rb
azurex-0.6.7 test/unit/core/http/http_error_test.rb
azurex-0.6.6 test/unit/core/http/http_error_test.rb
azurex-0.6.5 test/unit/core/http/http_error_test.rb
azure-multistorage-0.6.4 test/unit/core/http/http_error_test.rb
azure-0.6.4 test/unit/core/http/http_error_test.rb
azure-0.6.3 test/unit/core/http/http_error_test.rb
azure-0.6.2 test/unit/core/http/http_error_test.rb
azure-0.6.1 test/unit/core/http/http_error_test.rb