test/unit/service/storage_service_test.rb in azure-0.6.4 vs test/unit/service/storage_service_test.rb in azure-0.7.0.pre
- old
+ new
@@ -19,11 +19,11 @@
require "azure/service/storage_service_properties"
describe Azure::Service::StorageService do
let(:uri){ URI.parse "http://dummy.uri/resource" }
- let(:method){ :get }
+ let(:verb){ :get }
subject do
storage_service = Azure::Service::StorageService.new
storage_service.host = "http://dumyhost.uri"
storage_service
@@ -32,19 +32,19 @@
describe "#call" do
let(:mock_request){ mock() }
let(:mock_signer_filter){ mock() }
before do
- Azure::Core::Http::HttpRequest.stubs(:new).with(method, uri, nil).returns(mock_request)
+ Azure::Core::Http::HttpRequest.stubs(:new).with(verb, uri, nil).returns(mock_request)
Azure::Core::Http::SignerFilter.stubs(:new).returns(mock_signer_filter)
mock_request.expects(:call)
end
it "adds a SignerFilter to the HTTP pipeline" do
mock_request.expects(:with_filter).with(mock_signer_filter)
- subject.call(method, uri)
+ subject.call(verb, uri)
end
describe "when passed the optional headers arguement" do
before do
mock_request.expects(:with_filter).with(mock_signer_filter)
@@ -56,11 +56,11 @@
"connection"=>"PreviousValue"
}}
it "merges the custom headers with the HttpRequest headers" do
mock_request.expects(:headers).returns(mock_headers).at_least(2)
- subject.call(method, uri, nil, { "Custom-Header"=>"CustomValue"} )
+ subject.call(verb, uri, nil, { "Custom-Header"=>"CustomValue"} )
mock_headers["Other-Header"].must_equal "SomeValue"
mock_headers["Custom-Header"].must_equal "CustomValue"
mock_headers["connection"].must_equal "keep-alive"
end
@@ -70,12 +70,12 @@
before do
mock_request.expects(:with_filter).with(mock_signer_filter)
end
it "passes the body to the to HttpRequest" do
- Azure::Core::Http::HttpRequest.stubs(:new).with(method, uri, 'body').returns(mock_request)
- subject.call(method, uri, "body")
+ Azure::Core::Http::HttpRequest.stubs(:new).with(verb, uri, 'body').returns(mock_request)
+ subject.call(verb, uri, "body")
end
end
describe "when with_filter was called" do
before do
@@ -90,11 +90,11 @@
subject.with_filter filter1
mock_request.expects(:with_filter).with(filter)
mock_request.expects(:with_filter).with(filter1)
- subject.call(method, uri)
+ subject.call(verb, uri)
end
end
end
describe "#with_filter" do
@@ -140,24 +140,25 @@
response.stubs(:body).returns(service_properties_xml)
response
}
let(:service_properties_uri) { URI.parse 'http://dummy.uri/service/properties' }
+ let(:service_properties_headers) { {"x-ms-version" => "2013-08-15"} }
before do
Azure::Service::Serialization.stubs(:service_properties_from_xml).with(service_properties_xml).returns(service_properties)
subject.stubs(:service_properties_uri).returns(service_properties_uri)
- subject.stubs(:call).with(:get, service_properties_uri).returns(response)
+ subject.stubs(:call).with(:get, service_properties_uri, nil, service_properties_headers).returns(response)
end
it "calls the service_properties_uri method to determine the correct uri" do
subject.expects(:service_properties_uri).returns(service_properties_uri)
subject.get_service_properties
end
it "gets the response from the HTTP API" do
- subject.expects(:call).with(:get, service_properties_uri).returns(response)
+ subject.expects(:call).with(:get, service_properties_uri, nil, service_properties_headers).returns(response)
subject.get_service_properties
end
it "deserializes the response from xml" do
Azure::Service::Serialization.expects(:service_properties_from_xml).with(service_properties_xml).returns(service_properties)
@@ -178,23 +179,24 @@
response.stubs(:success?).returns(true)
response
}
let(:service_properties_uri) { URI.parse 'http://dummy.uri/service/properties' }
+ let(:service_properties_headers) { {"x-ms-version" => "2013-08-15"} }
before do
Azure::Service::Serialization.stubs(:service_properties_to_xml).with(service_properties).returns(service_properties_xml)
subject.stubs(:service_properties_uri).returns(service_properties_uri)
- subject.stubs(:call).with(:put, service_properties_uri, service_properties_xml).returns(response)
+ subject.stubs(:call).with(:put, service_properties_uri, service_properties_xml, service_properties_headers).returns(response)
end
it "calls the service_properties_uri method to determine the correct uri" do
subject.expects(:service_properties_uri).returns(service_properties_uri)
subject.set_service_properties service_properties
end
it "posts to the HTTP API" do
- subject.expects(:call).with(:put, service_properties_uri, service_properties_xml).returns(response)
+ subject.expects(:call).with(:put, service_properties_uri, service_properties_xml, service_properties_headers).returns(response)
subject.set_service_properties service_properties
end
it "serializes the StorageServiceProperties object to xml" do
Azure::Service::Serialization.expects(:service_properties_to_xml).with(service_properties).returns(service_properties_xml)
\ No newline at end of file