aws-sdk-core 2.0.0.rc1 → 2.0.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/README.md +6 -3
  4. data/Rakefile +2 -0
  5. data/apis/AutoScaling-2011-01-01.json +1 -0
  6. data/apis/CloudFormation-2010-05-15.json +75 -0
  7. data/apis/CloudFront-2012-05-05.json +1 -0
  8. data/apis/CloudFront-2013-05-12.json +1 -0
  9. data/apis/CloudFront-2013-08-26.json +1 -0
  10. data/apis/CloudSearch-2011-02-01.json +1 -0
  11. data/apis/CloudWatch-2010-08-01.json +1 -0
  12. data/apis/DataPipeline-2012-10-29.json +1 -0
  13. data/apis/DirectConnect-2012-10-25.json +1 -0
  14. data/apis/DynamoDB-2011-12-05.json +1 -0
  15. data/apis/DynamoDB-2012-08-10.json +1 -0
  16. data/apis/EC2-2013-06-15.json +1 -0
  17. data/apis/EC2-2013-10-01.json +1 -0
  18. data/apis/EMR-2009-03-31.json +1 -0
  19. data/apis/ElastiCache-2012-11-15.json +1 -0
  20. data/apis/ElastiCache-2013-06-15.json +1 -0
  21. data/apis/ElasticBeanstalk-2010-12-01.json +1 -0
  22. data/apis/ElasticLoadBalancing-2012-06-01.json +73 -0
  23. data/apis/ElasticTranscoder-2012-09-25.json +231 -0
  24. data/apis/Glacier-2012-06-01.json +2 -0
  25. data/apis/IAM-2010-05-08.json +1 -0
  26. data/apis/ImportExport-2010-06-01.json +1 -0
  27. data/apis/OpsWorks-2013-02-18.json +1 -0
  28. data/apis/RDS-2013-01-10.json +1 -0
  29. data/apis/RDS-2013-02-12.json +1 -0
  30. data/apis/RDS-2013-05-15.json +1 -0
  31. data/apis/Redshift-2012-12-01.json +1 -0
  32. data/apis/Route53-2012-12-12.json +1 -0
  33. data/apis/S3-2006-03-01.json +5 -0
  34. data/apis/SDB-2009-04-15.json +1 -0
  35. data/apis/SES-2010-12-01.json +1 -0
  36. data/apis/SNS-2010-03-31.json +1 -0
  37. data/apis/SQS-2012-11-05.json +1 -0
  38. data/apis/STS-2011-06-15.json +1 -0
  39. data/apis/SWF-2012-01-25.json +1 -0
  40. data/apis/StorageGateway-2012-06-30.json +1 -0
  41. data/apis/StorageGateway-2013-06-30.json +2018 -0
  42. data/apis/Support-2013-04-15.json +1 -0
  43. data/apis/source/cloudformation-2010-05-15.json +118 -12
  44. data/apis/source/elasticloadbalancing-2012-06-01.json +347 -220
  45. data/apis/source/elastictranscoder-2012-09-25.json +315 -5
  46. data/apis/source/s3-2006-03-01.json +3 -0
  47. data/apis/source/storagegateway-2013-06-30.json +12560 -0
  48. data/apis/source/storagegateway-2013-06-30.paginators.json +28 -0
  49. data/doc-src/plugins/apis.rb +44 -1
  50. data/doc-src/templates/default/fulldoc/html/setup.rb +1 -1
  51. data/features/common/step_definitions.rb +3 -5
  52. data/features/env.rb +2 -0
  53. data/features/glacier/client.feature +8 -0
  54. data/features/glacier/step_definitions.rb +7 -7
  55. data/features/s3/step_definitions.rb +2 -3
  56. data/lib/aws.rb +75 -69
  57. data/lib/aws/api/service_translators/glacier.rb +1 -0
  58. data/lib/aws/api/translator.rb +13 -8
  59. data/lib/aws/credentials.rb +5 -5
  60. data/lib/aws/instance_profile_credentials.rb +113 -0
  61. data/lib/aws/plugins/credentials.rb +2 -1
  62. data/lib/aws/plugins/glacier_account_id.rb +11 -0
  63. data/lib/aws/plugins/glacier_checksums.rb +7 -3
  64. data/lib/aws/plugins/instance_profile_credentials.rb +14 -0
  65. data/lib/aws/plugins/s3_bucket_dns.rb +17 -14
  66. data/lib/aws/plugins/s3_md5s.rb +3 -3
  67. data/lib/aws/service.rb +10 -9
  68. data/lib/aws/signers/s3.rb +2 -2
  69. data/lib/aws/signers/v2.rb +1 -1
  70. data/lib/aws/signers/v4.rb +2 -2
  71. data/lib/aws/version.rb +1 -1
  72. data/lib/aws/xml/serializer.rb +1 -1
  73. data/spec/aws/instance_profile_credentials_spec.rb +94 -0
  74. data/spec/aws/operations_spec.rb +1 -1
  75. data/spec/aws/plugins/credentials_spec.rb +2 -2
  76. data/spec/fixtures/operations/glacier/account_id_param.yml +13 -0
  77. data/spec/fixtures/operations/glacier/custom_account_id.yml +11 -0
  78. data/spec/fixtures/operations/glacier/default_account_id.yml +10 -0
  79. data/spec/fixtures/operations/s3/content_type_header.yml +12 -0
  80. data/spec/fixtures/operations/s3/md5_checksum_disabled.yml +1 -1
  81. data/tasks/apis.rake +2 -2
  82. data/tasks/docs.rake +2 -1
  83. data/tasks/handlers.rake +30 -0
  84. data/vendor/seahorse/lib/seahorse/client.rb +1 -0
  85. data/vendor/seahorse/lib/seahorse/client/base.rb +0 -18
  86. data/vendor/seahorse/lib/seahorse/client/block_io.rb +0 -7
  87. data/vendor/seahorse/lib/seahorse/client/configuration.rb +57 -37
  88. data/vendor/seahorse/lib/seahorse/client/handler_list.rb +115 -78
  89. data/vendor/seahorse/lib/seahorse/client/http/endpoint.rb +19 -15
  90. data/vendor/seahorse/lib/seahorse/client/http/request.rb +0 -15
  91. data/vendor/seahorse/lib/seahorse/client/logging/formatter.rb +0 -7
  92. data/vendor/seahorse/lib/seahorse/client/managed_file.rb +14 -0
  93. data/vendor/seahorse/lib/seahorse/client/net_http/handler.rb +1 -3
  94. data/vendor/seahorse/lib/seahorse/client/plugins/content_length.rb +1 -1
  95. data/vendor/seahorse/lib/seahorse/client/plugins/endpoint.rb +81 -10
  96. data/vendor/seahorse/lib/seahorse/client/plugins/restful_bindings.rb +1 -71
  97. data/vendor/seahorse/lib/seahorse/client/request.rb +26 -3
  98. data/vendor/seahorse/spec/seahorse/client/base_spec.rb +1 -5
  99. data/vendor/seahorse/spec/seahorse/client/configuration_spec.rb +1 -10
  100. data/vendor/seahorse/spec/seahorse/client/handler_list_spec.rb +10 -10
  101. data/vendor/seahorse/spec/seahorse/client/http/endpoint_spec.rb +46 -14
  102. data/vendor/seahorse/spec/seahorse/client/http/request_spec.rb +1 -42
  103. data/vendor/seahorse/spec/seahorse/client/logging/formatter_spec.rb +1 -6
  104. data/vendor/seahorse/spec/seahorse/client/logging/handler_spec.rb +1 -1
  105. data/vendor/seahorse/spec/seahorse/client/net_http/handler_spec.rb +5 -4
  106. data/vendor/seahorse/spec/seahorse/client/param_converter_spec.rb +1 -0
  107. data/vendor/seahorse/spec/seahorse/client/plugins/{restful_bindings/uri_path_builder_spec.rb → endpoint/request_uri_builder_spec.rb} +3 -3
  108. data/vendor/seahorse/spec/seahorse/client/plugins/endpoint_spec.rb +1 -11
  109. data/vendor/seahorse/spec/seahorse/client/request_spec.rb +63 -13
  110. metadata +21 -3
@@ -18,12 +18,12 @@ module Seahorse
18
18
  expect(handlers.to_a).to eq([handler])
19
19
  end
20
20
 
21
- it 'handlers added latter have a higher priority' do
21
+ it 'handlers added first have a higher priority' do
22
22
  handler1 = Class.new
23
23
  handler2 = Class.new
24
24
  handlers.add(handler1)
25
25
  handlers.add(handler2)
26
- expect(handlers.to_a).to eq([handler1, handler2])
26
+ expect(handlers.to_a).to eq([handler2, handler1])
27
27
  end
28
28
 
29
29
  it 'returns the handler class' do
@@ -53,7 +53,7 @@ module Seahorse
53
53
  handlers.add('h2', step: :validate)
54
54
  handlers.add('h3', step: :build)
55
55
  handlers.add('h4', step: :build)
56
- expect(handlers.to_a).to eq(%w(h3 h4 h1 h2))
56
+ expect(handlers.to_a).to eq(%w(h4 h3 h2 h1))
57
57
  end
58
58
 
59
59
  end
@@ -78,7 +78,7 @@ module Seahorse
78
78
  handlers.add('y', priority: 20, step: :validate)
79
79
  handlers.add('z', priority: 20, step: :validate)
80
80
  handlers.add('-', step: :send)
81
- expect(handlers.to_a).to eq(%w(- a b c m n o x y z))
81
+ expect(handlers.to_a).to eq(%w(- c b a o n m z y x))
82
82
  end
83
83
 
84
84
  end
@@ -138,7 +138,7 @@ module Seahorse
138
138
  handlers.add('handler1', operations: ['operation1'])
139
139
  handlers.add('handler2', operations: ['operation1'])
140
140
  handlers.add('handler3', operations: ['operation2'])
141
- expect(handlers.for('operation1').to_a).to eq(%w(handler1 handler2))
141
+ expect(handlers.for('operation1').to_a).to eq(%w(handler2 handler1))
142
142
  end
143
143
 
144
144
  end
@@ -184,7 +184,7 @@ module Seahorse
184
184
  handlers2 = handlers.for('operation')
185
185
  handlers2.add('handler2')
186
186
  expect(handlers.to_a).to eq(['handler1'])
187
- expect(handlers2.to_a).to eq(['handler1', 'handler2'])
187
+ expect(handlers2.to_a).to eq(['handler2', 'handler1'])
188
188
  end
189
189
 
190
190
  it 'copies operation handlers with the given name' do
@@ -207,8 +207,8 @@ module Seahorse
207
207
  it 'accpets operation names as symbols' do
208
208
  handlers.add('handler1', operations: [:operation])
209
209
  handlers.add('handler2', operations: ['operation'])
210
- expect(handlers.for('operation').to_a).to eq(%w(handler1 handler2))
211
- expect(handlers.for(:operation).to_a).to eq(%w(handler1 handler2))
210
+ expect(handlers.for('operation').to_a).to eq(%w(handler2 handler1))
211
+ expect(handlers.for(:operation).to_a).to eq(%w(handler2 handler1))
212
212
  end
213
213
 
214
214
  end
@@ -229,8 +229,8 @@ module Seahorse
229
229
  it 'does not construct handlers that are not classes' do
230
230
  handler1 = double('handler1')
231
231
  handler2 = double('handler2')
232
- expect(handler1).to receive(:handler=).with(nil)
233
- expect(handler2).to receive(:handler=).with(handler1)
232
+ expect(handler2).to receive(:handler=).with(nil)
233
+ expect(handler1).to receive(:handler=).with(handler2)
234
234
  handlers.add(handler1)
235
235
  handlers.add(handler2)
236
236
  handlers.to_stack
@@ -11,12 +11,12 @@ module Seahorse
11
11
  end
12
12
 
13
13
  it 'can be constructed from a URI::HTTP' do
14
- uri = 'http://foo.com'
14
+ uri = 'http://foo.com/'
15
15
  expect(Endpoint.new(URI.parse(uri))).to eq(uri)
16
16
  end
17
17
 
18
18
  it 'can be constructed from a URI::HTTPS' do
19
- uri = 'https://foo.com'
19
+ uri = 'https://foo.com/'
20
20
  expect(Endpoint.new(URI.parse(uri))).to eq(uri)
21
21
  end
22
22
 
@@ -45,16 +45,12 @@ module Seahorse
45
45
  expect(Endpoint.new('foo.com').scheme).to eq('https')
46
46
  end
47
47
 
48
- it 'looks for the :ssl_default options when picking the default scheme' do
49
- expect(Endpoint.new('foo.com', ssl_default: false).scheme).to eq('http')
50
- end
51
-
52
48
  it 'can be changed' do
53
- endpoint = Endpoint.new('http://foo.com')
49
+ endpoint = Endpoint.new('http://foo.com/')
54
50
  endpoint.scheme = 'https'
55
51
  expect(endpoint.port).to eq(80)
56
52
  expect(endpoint.scheme).to eq('https')
57
- expect(endpoint).to eq('https://foo.com:80')
53
+ expect(endpoint).to eq('https://foo.com:80/')
58
54
  end
59
55
 
60
56
  end
@@ -91,10 +87,10 @@ module Seahorse
91
87
  end
92
88
 
93
89
  it 'can be changed' do
94
- endpoint = Endpoint.new('http://foo.com')
90
+ endpoint = Endpoint.new('http://foo.com/')
95
91
  endpoint.host = 'bar.com'
96
92
  expect(endpoint.host).to eq('bar.com')
97
- expect(endpoint).to eq('http://bar.com')
93
+ expect(endpoint).to eq('http://bar.com/')
98
94
  end
99
95
 
100
96
  end
@@ -115,11 +111,47 @@ module Seahorse
115
111
  end
116
112
 
117
113
  it 'can be changed' do
118
- endpoint = Endpoint.new('http://foo.com')
114
+ endpoint = Endpoint.new('http://foo.com/')
119
115
  endpoint.port = 443
120
116
  expect(endpoint.scheme).to eq('http')
121
117
  expect(endpoint.port).to eq(443)
122
- expect(endpoint).to eq('http://foo.com:443')
118
+ expect(endpoint).to eq('http://foo.com:443/')
119
+ end
120
+
121
+ end
122
+
123
+ describe '#request_uri' do
124
+
125
+ it 'defaults to /' do
126
+ expect(Endpoint.new('foo.com').request_uri).to eq('/')
127
+ end
128
+
129
+ it 'can be set in the constructor' do
130
+ expect(Endpoint.new('foo.com/bar?a=b').request_uri).to eq('/bar?a=b')
131
+ end
132
+
133
+ end
134
+
135
+ describe '#path' do
136
+
137
+ it 'defaults to /' do
138
+ expect(Endpoint.new('foo.com').path).to eq('/')
139
+ end
140
+
141
+ it 'can be set in the constructor' do
142
+ expect(Endpoint.new('foo.com/bar?a=b').path).to eq('/bar')
143
+ end
144
+
145
+ end
146
+
147
+ describe '#querystring' do
148
+
149
+ it 'defaults to nil' do
150
+ expect(Endpoint.new('foo.com').querystring).to be(nil)
151
+ end
152
+
153
+ it 'can be set in the constructor' do
154
+ expect(Endpoint.new('foo.com/bar?a=b').querystring).to eq('a=b')
123
155
  end
124
156
 
125
157
  end
@@ -138,7 +170,7 @@ module Seahorse
138
170
  endpoint = Endpoint.new('foo.com')
139
171
  endpoint.user = 'abc'
140
172
  expect(endpoint.user).to eq('abc')
141
- expect(endpoint).to eq('https://abc@foo.com')
173
+ expect(endpoint).to eq('https://abc@foo.com/')
142
174
  end
143
175
 
144
176
  end
@@ -158,7 +190,7 @@ module Seahorse
158
190
  endpoint.user = 'u'
159
191
  endpoint.password = 'p'
160
192
  expect(endpoint.password).to eq('p')
161
- expect(endpoint).to eq('https://u:p@foo.com')
193
+ expect(endpoint).to eq('https://u:p@foo.com/')
162
194
  end
163
195
 
164
196
  end
@@ -15,7 +15,7 @@ module Seahorse
15
15
  end
16
16
 
17
17
  it 'can be set in the constructor' do
18
- endpoint = 'http://foo.com'
18
+ endpoint = 'http://foo.com/'
19
19
  req = request(endpoint: endpoint)
20
20
  expect(req.endpoint).to eq(endpoint)
21
21
  end
@@ -35,47 +35,6 @@ module Seahorse
35
35
 
36
36
  end
37
37
 
38
- describe '#path' do
39
-
40
- it 'defaults to GET' do
41
- expect(request.path).to eq('/')
42
- end
43
-
44
- it 'can be set in the constructor' do
45
- req = request(path: '/path?abc=xyz')
46
- expect(req.path).to eq('/path?abc=xyz')
47
- end
48
-
49
- end
50
-
51
- describe '#pathname' do
52
-
53
- it 'returns the path up to but not including the querystring' do
54
- req = request(path: '/path?query')
55
- expect(req.pathname).to eq('/path')
56
- end
57
-
58
- it 'returns the full path when a querystring is not present' do
59
- req = request(path: '/path')
60
- expect(req.pathname).to eq('/path')
61
- end
62
-
63
- end
64
-
65
- describe '#querystring' do
66
-
67
- it 'returns the querystring portion of the path' do
68
- req = request(path: '/path?query')
69
- expect(req.querystring).to eq('query')
70
- end
71
-
72
- it 'returns the empty string when not present' do
73
- req = request(path: '/path')
74
- expect(req.querystring).to eq('')
75
- end
76
-
77
- end
78
-
79
38
  describe '#headers' do
80
39
 
81
40
  it 'defaults to a Http::Headers' do
@@ -62,7 +62,7 @@ module Seahorse
62
62
  it 'provides a :http_request_endpoint replacement' do
63
63
  response.context.http_request.endpoint =
64
64
  Http::Endpoint.new('http://foo.com:123')
65
- expect(format(':http_request_endpoint')).to eq('http://foo.com:123')
65
+ expect(format(':http_request_endpoint')).to eq('http://foo.com:123/')
66
66
  end
67
67
 
68
68
  it 'provides a :http_request_scheme replacement' do
@@ -92,11 +92,6 @@ module Seahorse
92
92
  expect(format(':http_request_port')).to eq('123')
93
93
  end
94
94
 
95
- it 'provides a :http_request_path replacement' do
96
- response.context.http_request.path = '/foo?bar=1'
97
- expect(format(':http_request_path')).to eq('/foo?bar=1')
98
- end
99
-
100
95
  it 'provides a :http_request_headers replacement' do
101
96
  response.context.http_request.headers = { 'foo' => 'bar' }
102
97
  expect(format(':http_request_headers')).to eq('{"foo"=>"bar"}')
@@ -41,7 +41,7 @@ module Seahorse
41
41
  resp = handle!
42
42
  expect(resp.context[:logging_started_at]).to be_kind_of(Time)
43
43
  expect(resp.context[:logging_completed_at]).to be_kind_of(Time)
44
- expect(resp.context[:logging_started_at]).to be < resp.context[:logging_completed_at]
44
+ expect(resp.context[:logging_started_at]).to be <= resp.context[:logging_completed_at]
45
45
  end
46
46
 
47
47
  it 'sends the formatted message to the logger' do
@@ -183,14 +183,14 @@ module Seahorse
183
183
  describe 'request path' do
184
184
 
185
185
  it 'sends the request with the correct request uri' do
186
- http_request.path = '/path'
187
- stub_request(:any, "#{endpoint}/path")
186
+ http_request.endpoint.request_uri = '/path'
187
+ stub_request(:any, http_request.endpoint)
188
188
  make_request
189
189
  end
190
190
 
191
191
  it 'sends the request with the querystring' do
192
- http_request.path = '/abc?mno=xyz'
193
- stub_request(:any, "#{endpoint}/abc?mno=xyz")
192
+ http_request.endpoint.request_uri = '/abc?mno=xyz'
193
+ stub_request(:any, http_request.endpoint)
194
194
  make_request
195
195
  end
196
196
 
@@ -221,6 +221,7 @@ module Seahorse
221
221
  it 'populates the response body' do
222
222
  stub_request(:any, endpoint).to_return(body: 'response-body')
223
223
  resp_body = make_request.http_response.body
224
+ resp_body.rewind
224
225
  expect(resp_body.read).to eq('response-body')
225
226
  end
226
227
 
@@ -271,6 +271,7 @@ module Seahorse
271
271
  it 'accepts io objects (like tempfiles)' do
272
272
  file = Tempfile.new('abc')
273
273
  expect(ParamConverter.c(shape_class, file)).to be(file)
274
+ file.close
274
275
  file.delete
275
276
  end
276
277
 
@@ -3,14 +3,14 @@ require 'spec_helper'
3
3
  module Seahorse
4
4
  module Client
5
5
  module Plugins
6
- class RestfulBindings
7
- describe UriPathBuilder do
6
+ class Endpoint
7
+ describe RequestUriBuilder do
8
8
 
9
9
  let(:rules) {{ 'type' => 'input', 'members' => {} }}
10
10
 
11
11
  def path_for(pattern, params)
12
12
  input = Model::Shapes::Shape.from_hash(rules)
13
- UriPathBuilder.new(pattern, input.uri_members).path(params)
13
+ RequestUriBuilder.new(pattern, input.uri_members).path(params)
14
14
  end
15
15
 
16
16
  it 'does not modify paths without placeholders' do
@@ -22,21 +22,11 @@ module Seahorse
22
22
  expect(client.config.endpoint).to eq('foo.com')
23
23
  end
24
24
 
25
- it 'adds an #ssl_default option to config' do
26
- expect(client.config.ssl_default).to be(true)
27
- end
28
-
29
25
  it 'populates the http request endpoint' do
30
26
  resp = client.build_request('operation').send_request
31
- expect(resp.context.http_request.endpoint).to eq('https://foo.com')
27
+ expect(resp.context.http_request.endpoint).to eq('https://foo.com/')
32
28
  end
33
29
 
34
- it 'defaults to http when ssl_default is false' do
35
- client = client(ssl_default: false)
36
- resp = client.build_request('operation').send_request
37
- expect(resp.context.http_request.endpoint).to eq('http://foo.com')
38
- end
39
-
40
30
  end
41
31
  end
42
32
  end
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'tempfile'
2
3
 
3
4
  module Seahorse
4
5
  module Client
@@ -63,7 +64,7 @@ module Seahorse
63
64
 
64
65
  end
65
66
 
66
- describe '#send_request with a block' do
67
+ describe '#send_request with a target' do
67
68
 
68
69
  let(:handler) do
69
70
  Proc.new do
@@ -78,24 +79,73 @@ module Seahorse
78
79
  allow(handlers).to receive(:to_stack).and_return(handler)
79
80
  end
80
81
 
81
- it 'streams data from the handler to the #send_request block' do
82
- data = []
83
- request.send_request { |chunk| data << chunk }
84
- expect(data).to eq(['part1', 'part2', 'part3'])
82
+ describe 'String target' do
83
+
84
+ it 'writes to the file named' do
85
+ tmpfile = Tempfile.new('tempfile')
86
+ tmpfile.close
87
+ request.send_request(target: tmpfile.path)
88
+ expect(File.read(tmpfile.path)).to eq("part1part2part3")
89
+ end
90
+
91
+ it 'closes the file before returning the response' do
92
+ tmpfile = Tempfile.new('tempfile')
93
+ tmpfile.close
94
+ resp = request.send_request(target: tmpfile.path)
95
+ expect(resp.context.http_response.body).to be_closed
96
+ end
97
+
85
98
  end
86
99
 
87
- it 'counts the bytes yielded' do
88
- resp = request.send_request { |chunk| }
89
- expect(resp.http_response.body.size).to eq(15)
100
+ describe 'Pathname target' do
101
+
102
+ it 'writes to the file named' do
103
+ tmpfile = Tempfile.new('tempfile')
104
+ tmpfile.close
105
+ request.send_request(target: Pathname.new(tmpfile.path))
106
+ expect(File.read(tmpfile.path)).to eq("part1part2part3")
107
+ end
108
+
109
+ it 'closes the file before returning the response' do
110
+ tmpfile = Tempfile.new('tempfile')
111
+ tmpfile.close
112
+ resp = request.send_request(target: Pathname.new(tmpfile.path))
113
+ expect(resp.context.http_response.body).to be_closed
114
+ end
115
+
90
116
  end
91
117
 
92
- it 'does not buffer the response chunks' do
93
- response = request.send_request { |chunk| }
94
- body = response.http_response.body
95
- expect(body.read).to eq('')
96
- expect { body.rewind }.to raise_error(NotImplementedError)
118
+ describe 'IO object target' do
119
+
120
+ it 'writes to the given object' do
121
+ buffer = StringIO.new('')
122
+ request.send_request(target: buffer)
123
+ expect(buffer.string).to eq("part1part2part3")
124
+ end
125
+
97
126
  end
98
127
 
128
+ describe 'Block target' do
129
+
130
+ it 'streams data from the handler to the #send_request block' do
131
+ data = []
132
+ request.send_request { |chunk| data << chunk }
133
+ expect(data).to eq(['part1', 'part2', 'part3'])
134
+ end
135
+
136
+ it 'counts the bytes yielded' do
137
+ resp = request.send_request { |chunk| }
138
+ expect(resp.http_response.body.size).to eq(15)
139
+ end
140
+
141
+ it 'does not buffer the response chunks' do
142
+ response = request.send_request { |chunk| }
143
+ body = response.http_response.body
144
+ expect(body.read).to eq('')
145
+ expect(body).not_to respond_to(:truncate)
146
+ end
147
+
148
+ end
99
149
  end
100
150
  end
101
151
  end