azure 0.7.0.pre → 0.7.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.env_sample +3 -1
  3. data/.gitignore +15 -0
  4. data/LICENSE.txt +1 -1
  5. data/README.md +322 -248
  6. data/Rakefile +3 -1
  7. data/azure.gemspec +18 -14
  8. data/lib/azure.rb +124 -38
  9. data/lib/azure/base_management/base_management_service.rb +57 -69
  10. data/lib/azure/base_management/location.rb +1 -1
  11. data/lib/azure/base_management/management_http_request.rb +55 -58
  12. data/lib/azure/base_management/serialization.rb +5 -0
  13. data/lib/azure/base_management/sql_management_http_request.rb +10 -20
  14. data/lib/azure/blob/auth/shared_access_signature.rb +82 -76
  15. data/lib/azure/blob/blob_service.rb +196 -171
  16. data/lib/azure/client.rb +31 -0
  17. data/lib/azure/client_services.rb +98 -0
  18. data/lib/azure/cloud_service_management/cloud_service_management_service.rb +8 -10
  19. data/lib/azure/configurable.rb +290 -0
  20. data/lib/azure/core/auth/authorizer.rb +1 -1
  21. data/lib/azure/core/auth/shared_key.rb +48 -40
  22. data/lib/azure/core/auth/shared_key_lite.rb +9 -9
  23. data/lib/azure/core/auth/signer.rb +15 -12
  24. data/lib/azure/core/error.rb +2 -3
  25. data/lib/azure/core/filtered_service.rb +4 -3
  26. data/lib/azure/core/http/http_error.rb +10 -12
  27. data/lib/azure/core/http/http_request.rb +82 -69
  28. data/lib/azure/core/http/http_response.rb +12 -56
  29. data/lib/azure/core/http/signer_filter.rb +3 -4
  30. data/lib/azure/core/service.rb +8 -25
  31. data/lib/azure/core/signed_service.rb +7 -5
  32. data/lib/azure/core/utility.rb +45 -6
  33. data/lib/azure/default.rb +126 -0
  34. data/lib/azure/http_client.rb +85 -0
  35. data/lib/azure/queue/queue.rb +0 -1
  36. data/lib/azure/queue/queue_service.rb +6 -4
  37. data/lib/azure/queue/serialization.rb +0 -1
  38. data/lib/azure/service/storage_service.rb +9 -6
  39. data/lib/azure/service_bus/auth/shared_access_signer.rb +44 -0
  40. data/lib/azure/service_bus/auth/wrap_service.rb +5 -4
  41. data/lib/azure/service_bus/auth/wrap_signer.rb +14 -6
  42. data/lib/azure/service_bus/service_bus_service.rb +34 -30
  43. data/lib/azure/sql_database_management/errors.rb +11 -0
  44. data/lib/azure/sql_database_management/firewall_rule.rb +30 -0
  45. data/lib/azure/sql_database_management/serialization.rb +40 -53
  46. data/lib/azure/sql_database_management/sql_database_management_service.rb +141 -130
  47. data/lib/azure/sql_database_management/{sql_database.rb → sql_server.rb} +4 -3
  48. data/lib/azure/storage_management/storage_management_service.rb +9 -10
  49. data/lib/azure/table/auth/shared_key.rb +17 -50
  50. data/lib/azure/table/auth/shared_key_lite.rb +3 -3
  51. data/lib/azure/table/serialization.rb +24 -24
  52. data/lib/azure/table/table_service.rb +21 -18
  53. data/lib/azure/version.rb +1 -1
  54. data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +6 -12
  55. data/lib/azure/virtual_machine_management/serialization.rb +4 -1
  56. data/lib/azure/virtual_machine_management/virtual_machine.rb +1 -0
  57. data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +29 -37
  58. data/lib/azure/virtual_network_management/virtual_network_management_service.rb +5 -6
  59. data/test/fixtures/list_locations.xml +150 -0
  60. data/test/fixtures/list_sql_database.xml +6 -18
  61. data/test/fixtures/list_sql_server_firewall.xml +18 -18
  62. data/test/fixtures/management_certificate.pfx +0 -0
  63. data/test/fixtures/virtual_machine.xml +1 -0
  64. data/test/integration/affinity_group/Create_Affinity_test.rb +1 -1
  65. data/test/integration/affinity_group/Update_Affinity_test.rb +4 -0
  66. data/test/integration/blob/blob_gb18030_test.rb +29 -29
  67. data/test/integration/blob/blob_pages_test.rb +16 -16
  68. data/test/integration/blob/container/create_container_test.rb +6 -6
  69. data/test/integration/blob/container/root_container_test.rb +2 -1
  70. data/test/integration/database/create_sql_server_firewall_test.rb +26 -31
  71. data/test/integration/database/create_sql_server_test.rb +6 -6
  72. data/test/integration/database/delete_sql_server_firewall_test.rb +18 -24
  73. data/test/integration/database/delete_sql_server_test.rb +9 -22
  74. data/test/integration/database/list_sql_server_firewall_test.rb +7 -8
  75. data/test/integration/database/list_sql_servers_test.rb +4 -4
  76. data/test/integration/database/reset_password_sql_server_test.rb +9 -11
  77. data/test/integration/location/RoleSize_List_test.rb +35 -0
  78. data/test/integration/queue/list_queues_test.rb +0 -1
  79. data/test/integration/service_bus/queues_scenario_test.rb +11 -11
  80. data/test/integration/service_bus/queues_test.rb +2 -2
  81. data/test/integration/service_bus/subscriptions_test.rb +25 -25
  82. data/test/integration/service_bus/topics_scenario_test.rb +6 -6
  83. data/test/integration/service_bus/topics_test.rb +15 -15
  84. data/test/integration/table/query_entities_test.rb +1 -0
  85. data/test/integration/table/table_acl_test.rb +9 -9
  86. data/test/integration/test_helper.rb +11 -9
  87. data/test/integration/vm/VM_Create_test.rb +23 -20
  88. data/test/integration/vnet/Virtual_Network_list_test.rb +1 -1
  89. data/test/test_helper.rb +5 -0
  90. data/test/unit/affinity_group/affinity_group_test.rb +4 -4
  91. data/test/unit/base_management/base_management_service_test.rb +19 -0
  92. data/test/unit/base_management/location_test.rb +6 -6
  93. data/test/unit/base_management/role_size_test.rb +50 -0
  94. data/test/unit/blob/auth/shared_access_signature_test.rb +19 -19
  95. data/test/unit/blob/blob_service_test.rb +583 -582
  96. data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +2 -2
  97. data/test/unit/config/azure_test.rb +112 -0
  98. data/test/unit/config/client_test.rb +37 -0
  99. data/test/unit/core/auth/shared_key_lite_test.rb +15 -15
  100. data/test/unit/core/auth/shared_key_test.rb +26 -26
  101. data/test/unit/core/http/http_error_test.rb +13 -14
  102. data/test/unit/core/http/http_request_test.rb +78 -53
  103. data/test/unit/core/http/http_response_test.rb +2 -27
  104. data/test/unit/core/http/retry_policy_test.rb +3 -3
  105. data/test/unit/core/utility_test.rb +122 -0
  106. data/test/unit/database/serialization_test.rb +17 -20
  107. data/test/unit/database/sql_database_server_service_test.rb +97 -40
  108. data/test/unit/http_client_test.rb +74 -0
  109. data/test/unit/service/storage_service_test.rb +105 -101
  110. data/test/unit/storage_management/storage_management_service_test.rb +28 -28
  111. data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +4 -4
  112. data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +37 -20
  113. data/test/unit/vnet/virtual_network_management_service_test.rb +1 -1
  114. metadata +91 -20
  115. data/lib/azure/core.rb +0 -41
  116. data/lib/azure/core/configuration.rb +0 -218
@@ -0,0 +1,74 @@
1
+ require 'test_helper'
2
+
3
+ describe Azure::HttpClient do
4
+ subject { Azure }
5
+
6
+ let :uri do
7
+ URI('https://management.core.windows.net')
8
+ end
9
+
10
+ describe '#agents' do
11
+
12
+ describe 'ssl vs non ssl uris' do
13
+ it 'should set verify true if using ssl' do
14
+ Azure.agents(uri).ssl[:verify].must_equal true
15
+ end
16
+
17
+ it 'should not set ssl if not using ssl' do
18
+ Azure.agents('http://localhost').ssl.must_be_empty
19
+ end
20
+ end
21
+
22
+ describe 'when using a ca_file' do
23
+ before do
24
+ Azure.config.ca_file = './blah.pem'
25
+ end
26
+
27
+ after do
28
+ Azure.config.ca_file = nil
29
+ end
30
+
31
+ it 'should set ca_file option on the http connection' do
32
+ Azure.agents(uri).ssl[:ca_file].must_equal './blah.pem'
33
+ end
34
+ end
35
+
36
+ describe 'when not using a ca_file' do
37
+ it 'should not set ca_file option on the http connection' do
38
+ Azure.agents(uri).ssl[:ca_file].must_be_nil
39
+ end
40
+ end
41
+
42
+ describe 'when using a http proxy' do
43
+ let(:proxy_uri){ URI('http://localhost:80') }
44
+
45
+ before do
46
+ ENV['HTTP_PROXY'] = proxy_uri.to_s
47
+ end
48
+
49
+ after do
50
+ ENV['HTTP_PROXY'] = nil
51
+ end
52
+
53
+ it 'should set the proxy configuration information on the http connection' do
54
+ Azure.agents(uri).proxy.uri.must_equal proxy_uri
55
+ end
56
+ end
57
+
58
+ describe 'when using a https proxy' do
59
+ let(:proxy_uri){ URI('https://localhost:443') }
60
+
61
+ before do
62
+ ENV['HTTPS_PROXY'] = proxy_uri.to_s
63
+ end
64
+
65
+ after do
66
+ ENV['HTTPS_PROXY'] = nil
67
+ end
68
+
69
+ it 'should set the proxy configuration information on the http connection' do
70
+ Azure.agents(uri).proxy.uri.must_equal proxy_uri
71
+ end
72
+ end
73
+ end
74
+ end
@@ -12,77 +12,79 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  #--------------------------------------------------------------------------
15
- require "test_helper"
16
- require "azure/service/storage_service"
17
- require "azure/core/http/http_request"
18
- require "azure/core/http/signer_filter"
19
- require "azure/service/storage_service_properties"
15
+ require 'test_helper'
16
+ require 'azure/service/storage_service'
17
+ require 'azure/core/http/http_request'
18
+ require 'azure/core/http/signer_filter'
19
+ require 'azure/service/storage_service_properties'
20
20
 
21
21
  describe Azure::Service::StorageService do
22
22
 
23
- let(:uri){ URI.parse "http://dummy.uri/resource" }
24
- let(:verb){ :get }
23
+ let(:uri) { URI.parse 'http://dummy.uri/resource' }
24
+ let(:verb) { :get }
25
+ let(:x_ms_version) {'2014-02-14'}
25
26
 
26
27
  subject do
27
28
  storage_service = Azure::Service::StorageService.new
28
- storage_service.host = "http://dumyhost.uri"
29
+ storage_service.host = 'http://dumyhost.uri'
29
30
  storage_service
30
31
  end
31
32
 
32
- describe "#call" do
33
- let(:mock_request){ mock() }
34
- let(:mock_signer_filter){ mock() }
35
-
36
- before do
37
- Azure::Core::Http::HttpRequest.stubs(:new).with(verb, uri, nil).returns(mock_request)
33
+ describe '#call' do
34
+ let(:mock_request) { mock() }
35
+ let(:mock_signer_filter) { mock() }
36
+ let(:mock_headers) { {
37
+ 'Other-Header' => 'SomeValue',
38
+ 'Custom-Header' => 'PreviousValue',
39
+ 'connection' => 'PreviousValue'
40
+ } }
41
+
42
+ before do
43
+ Azure::Core::Http::HttpRequest.stubs(:new).with(verb, uri, anything).returns(mock_request)
38
44
  Azure::Core::Http::SignerFilter.stubs(:new).returns(mock_signer_filter)
39
45
 
40
46
  mock_request.expects(:call)
41
47
  end
42
48
 
43
- it "adds a SignerFilter to the HTTP pipeline" do
49
+ it 'adds a SignerFilter to the HTTP pipeline' do
44
50
  mock_request.expects(:with_filter).with(mock_signer_filter)
45
51
  subject.call(verb, uri)
46
52
  end
47
53
 
48
- describe "when passed the optional headers arguement" do
54
+ describe 'when passed the optional headers arguement' do
49
55
  before do
56
+ Azure::Core::Http::HttpRequest.stubs(:new).with(verb,
57
+ uri,
58
+ {
59
+ body: nil,
60
+ headers: {'Custom-Header' => 'CustomValue'},
61
+ client: nil
62
+ }).returns(mock_request)
50
63
  mock_request.expects(:with_filter).with(mock_signer_filter)
51
64
  end
52
65
 
53
- let(:mock_headers) {{
54
- "Other-Header"=>"SomeValue",
55
- "Custom-Header"=>"PreviousValue",
56
- "connection"=>"PreviousValue"
57
- }}
58
-
59
- it "merges the custom headers with the HttpRequest headers" do
60
- mock_request.expects(:headers).returns(mock_headers).at_least(2)
61
- subject.call(verb, uri, nil, { "Custom-Header"=>"CustomValue"} )
62
-
63
- mock_headers["Other-Header"].must_equal "SomeValue"
64
- mock_headers["Custom-Header"].must_equal "CustomValue"
65
- mock_headers["connection"].must_equal "keep-alive"
66
+ it 'passes the custom headers into the request initializer' do
67
+ subject.call(verb, uri, nil, {'Custom-Header' => 'CustomValue'})
66
68
  end
67
69
  end
68
70
 
69
- describe "when passed the optional body arguement" do
71
+ describe 'when passed the optional body arguement' do
70
72
  before do
71
73
  mock_request.expects(:with_filter).with(mock_signer_filter)
72
74
  end
73
75
 
74
- it "passes the body to the to HttpRequest" do
76
+ it 'passes the body to the to HttpRequest' do
75
77
  Azure::Core::Http::HttpRequest.stubs(:new).with(verb, uri, 'body').returns(mock_request)
76
- subject.call(verb, uri, "body")
78
+ subject.call(verb, uri, 'body')
77
79
  end
78
80
  end
79
81
 
80
- describe "when with_filter was called" do
82
+ describe 'when with_filter was called' do
81
83
  before do
82
84
  mock_request.expects(:with_filter).with(mock_signer_filter)
83
85
  end
84
86
 
85
- it "builds the HTTP pipeline by passing the filters to the HTTPRequest" do
87
+ it 'builds the HTTP pipeline by passing the filters to the HTTPRequest' do
86
88
  filter = mock()
87
89
  filter1 = mock()
88
90
 
@@ -91,40 +93,42 @@ describe Azure::Service::StorageService do
91
93
 
92
94
  mock_request.expects(:with_filter).with(filter)
93
95
  mock_request.expects(:with_filter).with(filter1)
94
-
96
+
95
97
  subject.call(verb, uri)
96
98
  end
97
99
  end
98
100
  end
99
101
 
100
- describe "#with_filter" do
101
- it "appends filters to a list of filters that will be used in the #call method" do
102
+ describe '#with_filter' do
103
+ it 'appends filters to a list of filters that will be used in the #call method' do
102
104
  initial_length = subject.filters.length
103
105
  filter = mock()
104
106
  subject.with_filter filter
105
107
  subject.filters.length.must_equal initial_length + 1
106
108
  end
107
109
 
108
- it "accepts object instances as filters" do
110
+ it 'accepts object instances as filters' do
109
111
  filter = mock()
110
112
  subject.with_filter filter
111
113
  subject.filters.last.must_equal filter
112
114
  end
113
115
 
114
- it "accepts blocks as filters" do
115
- subject.with_filter do |a,b| end
116
+ it 'accepts blocks as filters' do
117
+ subject.with_filter do |a, b|
118
+ end
116
119
  subject.filters.last.class.must_equal Proc
117
120
  end
118
121
 
119
- it "preserves the order of the filters" do
122
+ it 'preserves the order of the filters' do
120
123
  subject.filters = []
121
-
124
+
122
125
  filter = mock()
123
126
  filter1 = mock()
124
-
127
+
125
128
  subject.with_filter filter
126
129
  subject.with_filter filter1
127
- subject.with_filter do |a,b| end
130
+ subject.with_filter do |a, b|
131
+ end
128
132
 
129
133
  subject.filters.first.must_equal filter
130
134
  subject.filters[1].must_equal filter1
@@ -132,159 +136,159 @@ describe Azure::Service::StorageService do
132
136
  end
133
137
  end
134
138
 
135
- describe "#get_service_properties" do
136
- let(:service_properties_xml) { Fixtures["storage_service_properties"] }
139
+ describe '#get_service_properties' do
140
+ let(:service_properties_xml) { Fixtures['storage_service_properties'] }
137
141
  let(:service_properties) { Azure::Service::StorageServiceProperties.new }
138
- let(:response) {
142
+ let(:response) {
139
143
  response = mock()
140
144
  response.stubs(:body).returns(service_properties_xml)
141
145
  response
142
146
  }
143
147
 
144
148
  let(:service_properties_uri) { URI.parse 'http://dummy.uri/service/properties' }
145
- let(:service_properties_headers) { {"x-ms-version" => "2013-08-15"} }
149
+ let(:service_properties_headers) { {'x-ms-version' => x_ms_version} }
146
150
 
147
- before do
151
+ before do
148
152
  Azure::Service::Serialization.stubs(:service_properties_from_xml).with(service_properties_xml).returns(service_properties)
149
153
  subject.stubs(:service_properties_uri).returns(service_properties_uri)
150
154
  subject.stubs(:call).with(:get, service_properties_uri, nil, service_properties_headers).returns(response)
151
155
  end
152
156
 
153
- it "calls the service_properties_uri method to determine the correct uri" do
157
+ it 'calls the service_properties_uri method to determine the correct uri' do
154
158
  subject.expects(:service_properties_uri).returns(service_properties_uri)
155
159
  subject.get_service_properties
156
160
  end
157
161
 
158
- it "gets the response from the HTTP API" do
162
+ it 'gets the response from the HTTP API' do
159
163
  subject.expects(:call).with(:get, service_properties_uri, nil, service_properties_headers).returns(response)
160
164
  subject.get_service_properties
161
165
  end
162
166
 
163
- it "deserializes the response from xml" do
167
+ it 'deserializes the response from xml' do
164
168
  Azure::Service::Serialization.expects(:service_properties_from_xml).with(service_properties_xml).returns(service_properties)
165
169
  subject.get_service_properties
166
170
  end
167
171
 
168
- it "returns a StorageServiceProperties instance" do
172
+ it 'returns a StorageServiceProperties instance' do
169
173
  result = subject.get_service_properties
170
174
  result.must_be_kind_of Azure::Service::StorageServiceProperties
171
175
  end
172
176
  end
173
177
 
174
- describe "#set_service_properties" do
175
- let(:service_properties_xml) { Fixtures["storage_service_properties"] }
178
+ describe '#set_service_properties' do
179
+ let(:service_properties_xml) { Fixtures['storage_service_properties'] }
176
180
  let(:service_properties) { Azure::Service::StorageServiceProperties.new }
177
- let(:response) {
181
+ let(:response) {
178
182
  response = mock()
179
183
  response.stubs(:success?).returns(true)
180
184
  response
181
185
  }
182
186
 
183
187
  let(:service_properties_uri) { URI.parse 'http://dummy.uri/service/properties' }
184
- let(:service_properties_headers) { {"x-ms-version" => "2013-08-15"} }
188
+ let(:service_properties_headers) { {'x-ms-version' => x_ms_version} }
185
189
 
186
- before do
190
+ before do
187
191
  Azure::Service::Serialization.stubs(:service_properties_to_xml).with(service_properties).returns(service_properties_xml)
188
192
  subject.stubs(:service_properties_uri).returns(service_properties_uri)
189
193
  subject.stubs(:call).with(:put, service_properties_uri, service_properties_xml, service_properties_headers).returns(response)
190
194
  end
191
195
 
192
- it "calls the service_properties_uri method to determine the correct uri" do
196
+ it 'calls the service_properties_uri method to determine the correct uri' do
193
197
  subject.expects(:service_properties_uri).returns(service_properties_uri)
194
198
  subject.set_service_properties service_properties
195
199
  end
196
200
 
197
- it "posts to the HTTP API" do
201
+ it 'posts to the HTTP API' do
198
202
  subject.expects(:call).with(:put, service_properties_uri, service_properties_xml, service_properties_headers).returns(response)
199
203
  subject.set_service_properties service_properties
200
204
  end
201
205
 
202
- it "serializes the StorageServiceProperties object to xml" do
206
+ it 'serializes the StorageServiceProperties object to xml' do
203
207
  Azure::Service::Serialization.expects(:service_properties_to_xml).with(service_properties).returns(service_properties_xml)
204
208
  subject.set_service_properties service_properties
205
209
  end
206
210
 
207
- it "returns nil on success" do
211
+ it 'returns nil on success' do
208
212
  result = subject.set_service_properties service_properties
209
213
  result.must_equal nil
210
214
  end
211
215
  end
212
216
 
213
- describe "service_properties_uri" do
214
- it "returns an instance of URI" do
217
+ describe 'service_properties_uri' do
218
+ it 'returns an instance of URI' do
215
219
  subject.service_properties_uri.must_be_kind_of URI
216
220
  end
217
221
 
218
- it "uses the value of the host property as the base of the url" do
222
+ it 'uses the value of the host property as the base of the url' do
219
223
  subject.service_properties_uri.to_s.must_include subject.host
220
- subject.host = "http://something.else"
224
+ subject.host = 'http://something.else'
221
225
  subject.service_properties_uri.to_s.must_include subject.host
222
226
  end
223
227
 
224
- it "sets a query string that specifies the storage service properties endpoint" do
225
- subject.service_properties_uri.query.must_include "restype=service&comp=properties"
228
+ it 'sets a query string that specifies the storage service properties endpoint' do
229
+ subject.service_properties_uri.query.must_include 'restype=service&comp=properties'
226
230
  end
227
231
  end
228
232
 
229
- describe "#add_metadata_to_headers" do
230
- it "prefixes header names with x-ms-meta- but does not modify the values" do
233
+ describe '#add_metadata_to_headers' do
234
+ it 'prefixes header names with x-ms-meta- but does not modify the values' do
231
235
  headers = {}
232
- subject.add_metadata_to_headers({"Foo"=> "Bar"}, headers)
233
- headers.keys.must_include "x-ms-meta-Foo"
234
- headers["x-ms-meta-Foo"].must_equal "Bar"
236
+ subject.add_metadata_to_headers({'Foo' => 'Bar'}, headers)
237
+ headers.keys.must_include 'x-ms-meta-Foo'
238
+ headers['x-ms-meta-Foo'].must_equal 'Bar'
235
239
  end
236
240
 
237
- it "updates any existing x-ms-meta-* headers with the new values" do
238
- headers = { "x-ms-meta-Foo"=> "Foo"}
239
- subject.add_metadata_to_headers({"Foo"=> "Bar"}, headers)
240
- headers["x-ms-meta-Foo"].must_equal "Bar"
241
+ it 'updates any existing x-ms-meta-* headers with the new values' do
242
+ headers = {'x-ms-meta-Foo' => 'Foo'}
243
+ subject.add_metadata_to_headers({'Foo' => 'Bar'}, headers)
244
+ headers['x-ms-meta-Foo'].must_equal 'Bar'
241
245
  end
242
246
  end
243
247
 
244
- describe "#generate_uri" do
245
- it "returns a URI instance" do
246
- subject.generate_uri().must_be_kind_of ::URI
248
+ describe '#generate_uri' do
249
+ it 'returns a URI instance' do
250
+ subject.generate_uri.must_be_kind_of ::URI
247
251
  end
248
252
 
249
- describe "when called with no arguments" do
250
- it "returns the StorageService host URL" do
251
- subject.generate_uri().to_s.must_equal "http://dumyhost.uri/"
253
+ describe 'when called with no arguments' do
254
+ it 'returns the StorageService host URL' do
255
+ subject.generate_uri.to_s.must_equal 'http://dumyhost.uri/'
252
256
  end
253
257
  end
254
258
 
255
- describe "when passed an optional path" do
256
- it "adds the path to the host url" do
257
- subject.generate_uri("resource/entity/").path.must_equal "/resource/entity/"
259
+ describe 'when passed an optional path' do
260
+ it 'adds the path to the host url' do
261
+ subject.generate_uri('resource/entity/').path.must_equal '/resource/entity/'
258
262
  end
259
263
 
260
- it "correctly joins the path if the host url contained a path" do
261
- subject.host = "http://dummy.uri/host/path"
262
- subject.generate_uri("resource/entity/").path.must_equal "/host/path/resource/entity/"
264
+ it 'correctly joins the path if the host url contained a path' do
265
+ subject.host = 'http://dummy.uri/host/path'
266
+ subject.generate_uri('resource/entity/').path.must_equal '/host/path/resource/entity/'
263
267
  end
264
268
  end
265
269
 
266
- describe "when passed an Hash of query parameters" do
270
+ describe 'when passed an Hash of query parameters' do
267
271
 
268
- it "encodes the keys" do
269
- subject.generate_uri('',{"key !" => "value"}).query.must_include "key+%21=value"
272
+ it 'encodes the keys' do
273
+ subject.generate_uri('', {'key !' => 'value'}).query.must_include 'key+%21=value'
270
274
  end
271
275
 
272
- it "encodes the values" do
273
- subject.generate_uri('',{"key" => "value !"}).query.must_include "key=value+%21"
276
+ it 'encodes the values' do
277
+ subject.generate_uri('', {'key' => 'value !'}).query.must_include 'key=value+%21'
274
278
  end
275
279
 
276
- it "sets the query string to the encoded result" do
277
- subject.generate_uri('',{ "key" => "value !", "key !"=>"value"}).query.must_equal "key=value+%21&key+%21=value"
280
+ it 'sets the query string to the encoded result' do
281
+ subject.generate_uri('', {'key' => 'value !', 'key !' => 'value'}).query.must_equal 'key=value+%21&key+%21=value'
278
282
  end
279
283
 
280
- describe "when the query parameters include a timeout key" do
281
- it "overrides the default timeout" do
282
- subject.generate_uri('', {"timeout" => 45}).query.must_equal "timeout=45"
284
+ describe 'when the query parameters include a timeout key' do
285
+ it 'overrides the default timeout' do
286
+ subject.generate_uri('', {'timeout' => 45}).query.must_equal 'timeout=45'
283
287
  end
284
288
  end
285
289
 
286
- describe "when the query parameters are nil" do
287
- it "does not include any query parameters" do
290
+ describe 'when the query parameters are nil' do
291
+ it 'does not include any query parameters' do
288
292
  subject.generate_uri('', nil).query.must_equal nil
289
293
  end
290
294
  end