|
124 | 124 | it 'json response should ok' do
|
125 | 125 | stub_request(:get, "https://ros.aliyuncs.com/")
|
126 | 126 | .to_return(status: 200, headers: { 'Content-Type': 'application/json' }, body: { ok: true }.to_json)
|
127 | | - response = roa_client.get(uri: '/') |
| 127 | + response = roa_client.get(uri: '/',headers: {'content-type': 'application/json'}) |
128 | 128 | expect(response.body).to eq({ ok: true }.to_json)
|
129 | 129 | end
|
130 | 130 | end
|
|
133 | 133 | it 'json response should ok' do
|
134 | 134 | stub_request(:get, "https://ros.aliyuncs.com/")
|
135 | 135 | .to_return(status: 204, headers: { 'Content-Type': 'application/json' }, body: '')
|
136 | | - response = roa_client.get(uri: '/') |
| 136 | + response = roa_client.get(uri: '/',headers: {'content-type': 'application/json'}) |
137 | 137 | expect(response.body).to eq('')
|
138 | 138 | end
|
139 | 139 | end
|
|
146 | 146 | stub_request(:get, "https://ros.aliyuncs.com/")
|
147 | 147 | .to_return(status: status, headers: headers, body: body)
|
148 | 148 | expect {
|
149 | | - roa_client.get(uri: '/') |
| 149 | + roa_client.get(uri: '/',headers: {'content-type': 'application/json'}) |
150 | 150 | }.to raise_error(StandardError, 'code: 400, error message requestid: requestid')
|
151 | 151 | end
|
152 | 152 | end
|
|
167 | 167 | it 'xml response should ok' do
|
168 | 168 | stub_request(:get, "https://ros.aliyuncs.com/")
|
169 | 169 | .to_return(status: status, headers: headers, body: body)
|
170 | | - response = roa_client.get(uri: '/') |
| 170 | + response = roa_client.get(uri: '/',headers: {'content-type': 'application/json'}) |
171 | 171 | expect(response.body).to eq(body)
|
172 | 172 | end
|
173 | 173 | end
|
|
189 | 189 | stub_request(:get, "https://ros.aliyuncs.com/")
|
190 | 190 | .to_return(status: status, headers: headers, body: body)
|
191 | 191 | expect {
|
192 | | - roa_client.get(uri: '/') |
| 192 | + roa_client.get(uri: '/',headers: {'content-type': 'application/json'}) |
193 | 193 | }.to raise_error(ROAClient::ACSError, 'error message host_id: hostid, request_id: requestid')
|
194 | 194 | end
|
195 | 195 | end
|
196 | 196 |
|
197 | 197 | describe 'request(200) with plain response should ok' do
|
198 | 198 | it 'plain response should ok' do
|
199 | 199 | stub_request(:get, "https://ros.aliyuncs.com/").to_return(status: 200, body: 'plain text')
|
200 | | - response = roa_client.get(uri: '/') |
| 200 | + response = roa_client.get(uri: '/',headers: {'content-type': 'application/json'}) |
201 | 201 | expect(response.body).to eq('plain text')
|
202 | 202 | end
|
203 | 203 | end
|
204 | 204 |
|
205 | 205 | describe 'post should ok' do
|
206 | 206 | it 'should ok' do
|
207 | | - stub_request(:get, "https://ros.aliyuncs.com/") |
| 207 | + stub_request(:post, "https://ros.aliyuncs.com/") |
208 | 208 | .to_return(status: 200, headers: { 'content-type': 'application/json' }, body: { ok: true }.to_json)
|
209 | | - response = roa_client.post(uri: '/', body: 'text') |
| 209 | + response = roa_client.post(uri: '/', headers: {'content-type': 'application/json'},body: 'text') |
210 | 210 | expect(response.body).to eq('{"ok":true}')
|
211 | 211 | end
|
212 | 212 | it 'should ok with query' do
|
213 | | - stub_request(:get, "https://ros.aliyuncs.com/?k=v") |
| 213 | + stub_request(:post, "https://ros.aliyuncs.com/?k=v") |
214 | 214 | .to_return(status: 200, headers: { 'content-type': 'application/json' }, body: { ok: true }.to_json)
|
215 | | - response = roa_client.post(uri: '/', params: { k: 'v' }, body: 'text') |
| 215 | + response = roa_client.post(uri: '/', headers: {'content-type': 'application/json'},params: { k: 'v' }, body: 'text') |
216 | 216 | expect(response.body).to eq('{"ok":true}')
|
217 | 217 | end
|
218 | 218 | end
|
219 | 219 |
|
220 | 220 | describe 'put should ok' do
|
221 | 221 | it 'should ok' do
|
222 | | - stub_request(:get, "https://ros.aliyuncs.com/") |
| 222 | + stub_request(:put, "https://ros.aliyuncs.com/") |
223 | 223 | .to_return(status: 200, headers: { 'content-type': 'application/json' }, body: { ok: true }.to_json)
|
224 | | - response = roa_client.put(uri: '/', body: 'text') |
| 224 | + response = roa_client.put(uri: '/', headers: {'content-type': 'application/json'},body: 'text') |
225 | 225 | expect(response.body).to eq('{"ok":true}')
|
226 | 226 | end
|
227 | 227 | end
|
228 | 228 |
|
229 | 229 | describe 'delete should ok' do
|
230 | 230 | it 'should ok' do
|
231 | | - stub_request(:get, "https://ros.aliyuncs.com/") |
| 231 | + stub_request(:delete, "https://ros.aliyuncs.com/") |
232 | 232 | .to_return(status: 200, headers: { 'content-type': 'application/json' }, body: { ok: true }.to_json)
|
233 | | - response = roa_client.delete(uri: '/') |
| 233 | + response = roa_client.delete(uri: '/',headers: {'content-type': 'application/json'}) |
234 | 234 | expect(response.body).to eq('{"ok":true}')
|
235 | 235 | end
|
236 | 236 | end
|
|
0 commit comments