Sha256: 3a86606f4a27fbd791bc5a204fda4bcb328723e773ad867dd80007363f4006cc

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

require 'test_helper'
require "azure/response"

describe Azure::Response do
  it "can act as an error" do
    http_response = MiniTest::Mock.new
    http_response.stub(:body, Fixtures[:error])
    http_response.stub(:code, "409")

    response = Azure::Response.new(http_response)

    assert_raises(Azure::HTTPError) do
      raise response
    end
  end

  it "converts net/http headers into strings" do
    http_response = MiniTest::Mock.new
    http_response.stub(:to_hash, { "Content-Type" => ["text/xml"] })

    response = Azure::Response.new(http_response)
    response.headers["Content-Type"].must_equal "text/xml"
  end

  describe Azure::Response::HeaderHash do
    subject do
      Azure::Response::HeaderHash.new(
        "FooBar" => ["1"], "bazqux" => ["2"], "QUXFOO" => ["3"]
      )
    end

    it "returns the header values as strings, not arrays" do
      subject["FooBar"].must_equal "1"
      subject["bazqux"].must_equal "2"
      subject["QUXFOO"].must_equal "3"
    end

    it "obtains keys in a case-insensitive fashion" do
      subject["foobar"].must_equal "1"
      subject["BaZqUx"].must_equal "2"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
azure-0.1.1 test/unit/response_test.rb
azure-0.1.0 test/unit/response_test.rb