Sha256: 850a0dbf97d6e0e2941f8723a2d73a0929253dd0a38cc18fffe40eaa3efb0cad

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require "test_helper"
require "azure/request"

describe Azure::Request do
  describe "#calculate_headers" do
    let :clock do
      clock = MiniTest::Mock.new
      clock.stub(:now, "Sun, 03 May 2012 21:21:52 GMT")
      clock
    end

    it "sets the Date and x-ms-date headers" do
      request = Azure::Request.new(:get, URI("/"), nil, clock)

      request.headers["x-ms-date"].must_equal clock.now
    end

    it "sets the Content-Type" do
      request = Azure::Request.new(:get, URI("/"), "<body/>")

      request.headers["Content-Type"].must_equal "application/atom+xml; charset=utf-8"
    end

    it "sets the Content-Type, Length, and MD5 if passed a body" do
      request = Azure::Request.new(:get, URI("/"), "<body/>")

      request.headers["Content-Length"].must_equal "7"
      request.headers["Content-MD5"].must_equal Base64.strict_encode64(Digest::MD5.digest("<body/>"))
    end

    it "leaves the Content-Type, Length, and MD5 blank if the body is nil" do
      request = Azure::Request.new(:get, URI("/"))

      request.headers["Content-Length"].must_equal "0"
      request.headers["Content-MD5"].must_be_nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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