vcr 2.4.0 → 2.5.0
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.
- checksums.yaml +15 -0
- data/.gitignore +3 -0
- data/.travis.yml +2 -0
- data/CHANGELOG.md +31 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +63 -46
- data/README.md +5 -2
- data/features/cassettes/allow_unused_http_interactions.feature +1 -1
- data/features/cassettes/automatic_re_recording.feature +1 -1
- data/features/cassettes/decompress.feature +3 -3
- data/features/cassettes/dynamic_erb.feature +2 -2
- data/features/cassettes/exclusive.feature +1 -1
- data/features/cassettes/naming.feature +1 -1
- data/features/cassettes/no_cassette.feature +6 -3
- data/features/cassettes/persistence.feature +1 -1
- data/features/cassettes/update_content_length_header.feature +1 -1
- data/features/configuration/allow_http_connections_when_no_cassette.feature +1 -1
- data/features/configuration/cassette_library_dir.feature +1 -1
- data/features/configuration/debug_logging.feature +5 -5
- data/features/configuration/filter_sensitive_data.feature +2 -2
- data/features/configuration/hook_into.feature +4 -7
- data/features/getting_started.md +2 -2
- data/features/hooks/before_playback.feature +5 -5
- data/features/hooks/before_record.feature +5 -5
- data/features/middleware/rack.feature +2 -2
- data/features/record_modes/all.feature +1 -1
- data/features/record_modes/new_episodes.feature +1 -1
- data/features/record_modes/none.feature +1 -1
- data/features/record_modes/once.feature +1 -1
- data/features/request_matching/custom_matcher.feature +1 -1
- data/features/request_matching/headers.feature +0 -2
- data/features/request_matching/playback_repeats.feature +1 -1
- data/features/request_matching/uri_without_param.feature +1 -1
- data/features/support/env.rb +1 -0
- data/features/test_frameworks/cucumber.feature +8 -8
- data/features/test_frameworks/rspec_macro.feature +2 -2
- data/features/test_frameworks/rspec_metadata.feature +1 -1
- data/gemfiles/typhoeus_old.gemfile +1 -1
- data/gemfiles/typhoeus_old.gemfile.lock +31 -57
- data/lib/vcr/cassette/migrator.rb +8 -1
- data/lib/vcr/configuration.rb +9 -2
- data/lib/vcr/library_hooks/excon.rb +2 -184
- data/lib/vcr/library_hooks/typhoeus.rb +1 -1
- data/lib/vcr/library_hooks/typhoeus_0.4.rb +4 -0
- data/lib/vcr/library_hooks/webmock.rb +1 -1
- data/lib/vcr/middleware/excon.rb +226 -0
- data/lib/vcr/version.rb +1 -1
- data/spec/acceptance/threading_spec.rb +28 -0
- data/spec/monkey_patches.rb +3 -7
- data/spec/quality_spec.rb +1 -1
- data/spec/spec_helper.rb +7 -4
- data/spec/support/http_library_adapters.rb +4 -3
- data/spec/support/shared_example_groups/excon.rb +22 -0
- data/spec/support/shared_example_groups/hook_into_http_library.rb +46 -46
- data/spec/support/shared_example_groups/request_hooks.rb +8 -8
- data/spec/vcr/cassette/erb_renderer_spec.rb +5 -5
- data/spec/vcr/cassette/http_interaction_list_spec.rb +52 -40
- data/spec/vcr/cassette/migrator_spec.rb +11 -11
- data/spec/vcr/cassette/persisters/file_system_spec.rb +11 -11
- data/spec/vcr/cassette/persisters_spec.rb +2 -2
- data/spec/vcr/cassette/serializers_spec.rb +13 -12
- data/spec/vcr/cassette_spec.rb +58 -58
- data/spec/vcr/configuration_spec.rb +43 -31
- data/spec/vcr/deprecations_spec.rb +3 -3
- data/spec/vcr/errors_spec.rb +25 -25
- data/spec/vcr/extensions/net_http_response_spec.rb +7 -7
- data/spec/vcr/library_hooks/excon_spec.rb +7 -85
- data/spec/vcr/library_hooks/fakeweb_spec.rb +15 -13
- data/spec/vcr/library_hooks/faraday_spec.rb +4 -4
- data/spec/vcr/library_hooks/typhoeus_0.4_spec.rb +5 -0
- data/spec/vcr/library_hooks/typhoeus_spec.rb +3 -3
- data/spec/vcr/library_hooks/webmock_spec.rb +13 -5
- data/spec/vcr/library_hooks_spec.rb +9 -9
- data/spec/vcr/middleware/faraday_spec.rb +10 -10
- data/spec/vcr/middleware/rack_spec.rb +20 -15
- data/spec/vcr/request_ignorer_spec.rb +3 -3
- data/spec/vcr/request_matcher_registry_spec.rb +88 -61
- data/spec/vcr/structs_spec.rb +85 -85
- data/spec/vcr/test_frameworks/cucumber_spec.rb +7 -7
- data/spec/vcr/test_frameworks/rspec_spec.rb +10 -10
- data/spec/vcr/util/hooks_spec.rb +20 -20
- data/spec/vcr/util/internet_connection_spec.rb +2 -2
- data/spec/vcr_spec.rb +50 -48
- data/vcr.gemspec +4 -4
- metadata +308 -372
data/spec/vcr/structs_spec.rb
CHANGED
@@ -18,26 +18,26 @@ shared_examples_for "a header normalizer" do
|
|
18
18
|
key = 'my-key'
|
19
19
|
key.instance_variable_set(:@foo, 7)
|
20
20
|
instance = with_headers(key => ['value1'])
|
21
|
-
YAML.dump(instance.headers).
|
21
|
+
expect(YAML.dump(instance.headers)).to eq(YAML.dump('my-key' => ['value1']))
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'ensures header values are serialized to yaml as raw strings' do
|
25
25
|
value = 'my-value'
|
26
26
|
value.instance_variable_set(:@foo, 7)
|
27
27
|
instance = with_headers('my-key' => [value])
|
28
|
-
YAML.dump(instance.headers).
|
28
|
+
expect(YAML.dump(instance.headers)).to eq(YAML.dump('my-key' => ['my-value']))
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'handles nested arrays' do
|
32
32
|
accept_encoding = [["gzip", "1.0"], ["deflate", "1.0"], ["sdch", "1.0"]]
|
33
33
|
instance = with_headers('accept-encoding' => accept_encoding)
|
34
|
-
instance.headers['accept-encoding'].
|
34
|
+
expect(instance.headers['accept-encoding']).to eq(accept_encoding)
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'handles nested arrays with floats' do
|
38
38
|
accept_encoding = [["gzip", 1.0], ["deflate", 1.0], ["sdch", 1.0]]
|
39
39
|
instance = with_headers('accept-encoding' => accept_encoding)
|
40
|
-
instance.headers['accept-encoding'].
|
40
|
+
expect(instance.headers['accept-encoding']).to eq(accept_encoding)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -45,11 +45,11 @@ shared_examples_for "a body normalizer" do
|
|
45
45
|
it "ensures the body is serialized to yaml as a raw string" do
|
46
46
|
body = "My String"
|
47
47
|
body.instance_variable_set(:@foo, 7)
|
48
|
-
YAML.dump(instance(body).body).
|
48
|
+
expect(YAML.dump(instance(body).body)).to eq(YAML.dump("My String"))
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'converts nil to a blank string' do
|
52
|
-
instance(nil).body.
|
52
|
+
expect(instance(nil).body).to eq("")
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'raises an error if given another type of object as the body' do
|
@@ -78,7 +78,7 @@ module VCR
|
|
78
78
|
|
79
79
|
it 'is initialized to the current time' do
|
80
80
|
Time.stub(:now => now)
|
81
|
-
VCR::HTTPInteraction.new.recorded_at.
|
81
|
+
expect(VCR::HTTPInteraction.new.recorded_at).to eq(now)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -111,23 +111,23 @@ module VCR
|
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'constructs an HTTP interaction from the given hash' do
|
114
|
-
HTTPInteraction.from_hash(hash).
|
114
|
+
expect(HTTPInteraction.from_hash(hash)).to eq(interaction)
|
115
115
|
end
|
116
116
|
|
117
117
|
it 'initializes the recorded_at timestamp from the hash' do
|
118
|
-
HTTPInteraction.from_hash(hash).recorded_at.
|
118
|
+
expect(HTTPInteraction.from_hash(hash).recorded_at).to eq(recorded_at)
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'uses a blank request when the hash lacks one' do
|
122
122
|
hash.delete('request')
|
123
123
|
i = HTTPInteraction.from_hash(hash)
|
124
|
-
i.request.
|
124
|
+
expect(i.request).to eq(Request.new)
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'uses a blank response when the hash lacks one' do
|
128
128
|
hash.delete('response')
|
129
129
|
i = HTTPInteraction.from_hash(hash)
|
130
|
-
i.response.
|
130
|
+
expect(i.response).to eq(Response.new(ResponseStatus.new))
|
131
131
|
end
|
132
132
|
|
133
133
|
it 'decodes the base64 body string' do
|
@@ -135,34 +135,34 @@ module VCR
|
|
135
135
|
hash['response']['body'] = body_hash('base64_string', Base64.encode64('res body'))
|
136
136
|
|
137
137
|
i = HTTPInteraction.from_hash(hash)
|
138
|
-
i.request.body.
|
139
|
-
i.response.body.
|
138
|
+
expect(i.request.body).to eq('req body')
|
139
|
+
expect(i.response.body).to eq('res body')
|
140
140
|
end
|
141
141
|
|
142
142
|
if ''.respond_to?(:encoding)
|
143
143
|
it 'force encodes the decoded base64 string as the original encoding' do
|
144
144
|
string = "café"
|
145
145
|
string.force_encoding("US-ASCII")
|
146
|
-
string.
|
146
|
+
expect(string).not_to be_valid_encoding
|
147
147
|
|
148
148
|
hash['request']['body'] = { 'base64_string' => Base64.encode64(string.dup), 'encoding' => 'US-ASCII' }
|
149
149
|
hash['response']['body'] = { 'base64_string' => Base64.encode64(string.dup), 'encoding' => 'US-ASCII' }
|
150
150
|
|
151
151
|
i = HTTPInteraction.from_hash(hash)
|
152
|
-
i.request.body.encoding.name.
|
153
|
-
i.response.body.encoding.name.
|
154
|
-
i.request.body.bytes.to_a.
|
155
|
-
i.response.body.bytes.to_a.
|
156
|
-
i.request.body.
|
157
|
-
i.response.body.
|
152
|
+
expect(i.request.body.encoding.name).to eq("US-ASCII")
|
153
|
+
expect(i.response.body.encoding.name).to eq("US-ASCII")
|
154
|
+
expect(i.request.body.bytes.to_a).to eq(string.bytes.to_a)
|
155
|
+
expect(i.response.body.bytes.to_a).to eq(string.bytes.to_a)
|
156
|
+
expect(i.request.body).not_to be_valid_encoding
|
157
|
+
expect(i.response.body).not_to be_valid_encoding
|
158
158
|
end
|
159
159
|
|
160
160
|
it 'does not attempt to force encode the decoded base64 string when there is no encoding given (i.e. if the cassette was recorded on ruby 1.8)' do
|
161
161
|
hash['request']['body'] = { 'base64_string' => Base64.encode64('foo') }
|
162
162
|
|
163
163
|
i = HTTPInteraction.from_hash(hash)
|
164
|
-
i.request.body.
|
165
|
-
i.request.body.encoding.name.
|
164
|
+
expect(i.request.body).to eq('foo')
|
165
|
+
expect(i.request.body.encoding.name).to eq("ASCII-8BIT")
|
166
166
|
end
|
167
167
|
|
168
168
|
it 'tries to encode strings to the original encoding' do
|
@@ -170,10 +170,10 @@ module VCR
|
|
170
170
|
hash['response']['body'] = { 'string' => "abc", 'encoding' => 'ISO-8859-1' }
|
171
171
|
|
172
172
|
i = HTTPInteraction.from_hash(hash)
|
173
|
-
i.request.body.
|
174
|
-
i.response.body.
|
175
|
-
i.request.body.encoding.name.
|
176
|
-
i.response.body.encoding.name.
|
173
|
+
expect(i.request.body).to eq("abc")
|
174
|
+
expect(i.response.body).to eq("abc")
|
175
|
+
expect(i.request.body.encoding.name).to eq("ISO-8859-1")
|
176
|
+
expect(i.response.body.encoding.name).to eq("ISO-8859-1")
|
177
177
|
end
|
178
178
|
|
179
179
|
it 'does not attempt to encode the string when there is no encoding given (i.e. if the cassette was recorded on ruby 1.8)' do
|
@@ -182,21 +182,21 @@ module VCR
|
|
182
182
|
hash['request']['body'] = { 'string' => string }
|
183
183
|
|
184
184
|
i = HTTPInteraction.from_hash(hash)
|
185
|
-
i.request.body.
|
186
|
-
i.request.body.encoding.name.
|
185
|
+
expect(i.request.body).to eq('foo')
|
186
|
+
expect(i.request.body.encoding.name).to eq("ISO-8859-1")
|
187
187
|
end
|
188
188
|
|
189
189
|
it 'force encodes to ASCII-8BIT (since it just means "no encoding" or binary)' do
|
190
190
|
string = "\u00f6"
|
191
191
|
string.encode("UTF-8")
|
192
|
-
string.
|
192
|
+
expect(string).to be_valid_encoding
|
193
193
|
hash['request']['body'] = { 'string' => string, 'encoding' => 'ASCII-8BIT' }
|
194
194
|
|
195
195
|
Request.should_not_receive(:warn)
|
196
196
|
i = HTTPInteraction.from_hash(hash)
|
197
|
-
i.request.body.
|
198
|
-
i.request.body.bytes.to_a.
|
199
|
-
i.request.body.encoding.name.
|
197
|
+
expect(i.request.body).to eq(string)
|
198
|
+
expect(i.request.body.bytes.to_a).to eq(string.bytes.to_a)
|
199
|
+
expect(i.request.body.encoding.name).to eq("ASCII-8BIT")
|
200
200
|
end
|
201
201
|
|
202
202
|
context 'when the string cannot be encoded as the original encoding' do
|
@@ -218,10 +218,10 @@ module VCR
|
|
218
218
|
|
219
219
|
it 'does not force the encoding' do
|
220
220
|
i = HTTPInteraction.from_hash(hash)
|
221
|
-
i.request.body.
|
222
|
-
i.response.body.
|
223
|
-
i.request.body.encoding.name.
|
224
|
-
i.response.body.encoding.name.
|
221
|
+
expect(i.request.body).to eq("\xFAbc")
|
222
|
+
expect(i.response.body).to eq("\xFAbc")
|
223
|
+
expect(i.request.body.encoding.name).not_to eq("ISO-8859-1")
|
224
|
+
expect(i.response.body.encoding.name).not_to eq("ISO-8859-1")
|
225
225
|
end
|
226
226
|
|
227
227
|
it 'prints a warning and informs users of the :preserve_exact_body_bytes option' do
|
@@ -243,18 +243,18 @@ module VCR
|
|
243
243
|
let(:hash) { interaction.to_hash }
|
244
244
|
|
245
245
|
it 'returns a nested hash containing all of the pertinent details' do
|
246
|
-
hash.keys.
|
246
|
+
expect(hash.keys).to match_array %w[ request response recorded_at ]
|
247
247
|
|
248
|
-
hash['recorded_at'].
|
248
|
+
expect(hash['recorded_at']).to eq(interaction.recorded_at.httpdate)
|
249
249
|
|
250
|
-
hash['request'].
|
250
|
+
expect(hash['request']).to eq({
|
251
251
|
'method' => 'get',
|
252
252
|
'uri' => 'http://foo.com/',
|
253
253
|
'body' => body_hash('string', 'req body'),
|
254
254
|
'headers' => { "bar" => ["foo"] }
|
255
255
|
})
|
256
256
|
|
257
|
-
hash['response'].
|
257
|
+
expect(hash['response']).to eq({
|
258
258
|
'status' => {
|
259
259
|
'code' => 200,
|
260
260
|
'message' => 'OK'
|
@@ -267,22 +267,22 @@ module VCR
|
|
267
267
|
|
268
268
|
it 'encodes the body as base64 when the configuration is so set' do
|
269
269
|
VCR.stub_chain(:configuration, :preserve_exact_body_bytes_for?).and_return(true)
|
270
|
-
hash['request']['body'].
|
271
|
-
hash['response']['body'].
|
270
|
+
expect(hash['request']['body']).to eq(body_hash('base64_string', Base64.encode64('req body')))
|
271
|
+
expect(hash['response']['body']).to eq(body_hash('base64_string', Base64.encode64('res body')))
|
272
272
|
end
|
273
273
|
|
274
274
|
it "sets the string's original encoding", :if => ''.respond_to?(:encoding) do
|
275
275
|
interaction.request.body.force_encoding('ISO-8859-10')
|
276
276
|
interaction.response.body.force_encoding('ASCII-8BIT')
|
277
277
|
|
278
|
-
hash['request']['body']['encoding'].
|
279
|
-
hash['response']['body']['encoding'].
|
278
|
+
expect(hash['request']['body']['encoding']).to eq('ISO-8859-10')
|
279
|
+
expect(hash['response']['body']['encoding']).to eq('ASCII-8BIT')
|
280
280
|
end
|
281
281
|
|
282
282
|
def assert_yielded_keys(hash, *keys)
|
283
283
|
yielded_keys = []
|
284
284
|
hash.each { |k, v| yielded_keys << k }
|
285
|
-
yielded_keys.
|
285
|
+
expect(yielded_keys).to eq(keys)
|
286
286
|
end
|
287
287
|
|
288
288
|
it 'yields the entries in the expected order so the hash can be serialized in that order' do
|
@@ -308,7 +308,7 @@ module VCR
|
|
308
308
|
end
|
309
309
|
|
310
310
|
it "returns the parsed uri" do
|
311
|
-
request.parsed_uri.
|
311
|
+
expect(request.parsed_uri).to eq uri
|
312
312
|
end
|
313
313
|
end
|
314
314
|
end
|
@@ -369,29 +369,29 @@ module VCR
|
|
369
369
|
|
370
370
|
[:request, :response].each do |part|
|
371
371
|
it "replaces the sensitive text in the #{part} header keys and values" do
|
372
|
-
filtered.send(part).headers.
|
372
|
+
expect(filtered.send(part).headers).to eq({
|
373
373
|
'x-http-AAA' => ['bar23', '23AAA'],
|
374
374
|
'x-http-bar' => ['AAA23', '18']
|
375
375
|
})
|
376
376
|
end
|
377
377
|
|
378
378
|
it "replaces the sensitive text in the #{part} body" do
|
379
|
-
filtered.send(part).body.
|
379
|
+
expect(filtered.send(part).body).to eq("The body AAA this is (AAA-Foo)")
|
380
380
|
end
|
381
381
|
end
|
382
382
|
|
383
383
|
it 'replaces the sensitive text in the response status' do
|
384
|
-
filtered.response.status.message.
|
384
|
+
expect(filtered.response.status.message).to eq('OK AAA')
|
385
385
|
end
|
386
386
|
|
387
387
|
it 'replaces sensitive text in the request URI' do
|
388
|
-
filtered.request.uri.
|
388
|
+
expect(filtered.request.uri).to eq('http://example-AAA.com/AAA/')
|
389
389
|
end
|
390
390
|
|
391
391
|
it 'handles numbers (such as the port) properly' do
|
392
392
|
request.uri = "http://foo.com:9000/bar"
|
393
393
|
subject.filter!(9000, "<PORT>")
|
394
|
-
request.uri.
|
394
|
+
expect(request.uri).to eq("http://foo.com:<PORT>/bar")
|
395
395
|
end
|
396
396
|
end
|
397
397
|
end
|
@@ -400,13 +400,13 @@ module VCR
|
|
400
400
|
[:uri, :method, :headers, :body].each do |method|
|
401
401
|
it "delegates ##{method} to the request" do
|
402
402
|
request = stub(method => "delegated value")
|
403
|
-
Request::Typed.new(request, :type).send(method).
|
403
|
+
expect(Request::Typed.new(request, :type).send(method)).to eq("delegated value")
|
404
404
|
end
|
405
405
|
end
|
406
406
|
|
407
407
|
describe "#type" do
|
408
408
|
it 'returns the initialized type' do
|
409
|
-
Request::Typed.new(stub, :ignored).type.
|
409
|
+
expect(Request::Typed.new(stub, :ignored).type).to be(:ignored)
|
410
410
|
end
|
411
411
|
end
|
412
412
|
|
@@ -414,11 +414,11 @@ module VCR
|
|
414
414
|
valid_types.each do |type|
|
415
415
|
describe "##{type}?" do
|
416
416
|
it "returns true if the type is set to :#{type}" do
|
417
|
-
Request::Typed.new(stub, type).send("#{type}?").
|
417
|
+
expect(Request::Typed.new(stub, type).send("#{type}?")).to be_true
|
418
418
|
end
|
419
419
|
|
420
420
|
it "returns false if the type is set to :other" do
|
421
|
-
Request::Typed.new(stub, :other).send("#{type}?").
|
421
|
+
expect(Request::Typed.new(stub, :other).send("#{type}?")).to be_false
|
422
422
|
end
|
423
423
|
end
|
424
424
|
end
|
@@ -427,13 +427,13 @@ module VCR
|
|
427
427
|
real_types = [:ignored, :recordable]
|
428
428
|
real_types.each do |type|
|
429
429
|
it "returns true if the type is set to :#{type}" do
|
430
|
-
Request::Typed.new(stub, type).
|
430
|
+
expect(Request::Typed.new(stub, type)).to be_real
|
431
431
|
end
|
432
432
|
end
|
433
433
|
|
434
434
|
(valid_types - real_types).each do |type|
|
435
435
|
it "returns false if the type is set to :#{type}" do
|
436
|
-
Request::Typed.new(stub, type).
|
436
|
+
expect(Request::Typed.new(stub, type)).not_to be_real
|
437
437
|
end
|
438
438
|
end
|
439
439
|
end
|
@@ -442,13 +442,13 @@ module VCR
|
|
442
442
|
stubbed_types = [:externally_stubbed, :stubbed_by_vcr]
|
443
443
|
stubbed_types.each do |type|
|
444
444
|
it "returns true if the type is set to :#{type}" do
|
445
|
-
Request::Typed.new(stub, type).
|
445
|
+
expect(Request::Typed.new(stub, type)).to be_stubbed
|
446
446
|
end
|
447
447
|
end
|
448
448
|
|
449
449
|
(valid_types - stubbed_types).each do |type|
|
450
450
|
it "returns false if the type is set to :#{type}" do
|
451
|
-
Request::Typed.new(stub, type).
|
451
|
+
expect(Request::Typed.new(stub, type)).not_to be_stubbed
|
452
452
|
end
|
453
453
|
end
|
454
454
|
end
|
@@ -462,23 +462,23 @@ module VCR
|
|
462
462
|
|
463
463
|
context 'when given no arguments' do
|
464
464
|
it 'returns the HTTP method' do
|
465
|
-
subject.method.
|
465
|
+
expect(subject.method).to eq(:get)
|
466
466
|
end
|
467
467
|
end
|
468
468
|
|
469
469
|
context 'when given an argument' do
|
470
470
|
it 'returns the method object for the named method' do
|
471
471
|
m = subject.method(:class)
|
472
|
-
m.
|
473
|
-
m.call.
|
472
|
+
expect(m).to be_a(Method)
|
473
|
+
expect(m.call).to eq(described_class)
|
474
474
|
end
|
475
475
|
end
|
476
476
|
|
477
477
|
it 'gets normalized to a lowercase symbol' do
|
478
|
-
VCR::Request.new("GET").method.
|
479
|
-
VCR::Request.new(:GET).method.
|
480
|
-
VCR::Request.new(:get).method.
|
481
|
-
VCR::Request.new("get").method.
|
478
|
+
expect(VCR::Request.new("GET").method).to eq(:get)
|
479
|
+
expect(VCR::Request.new(:GET).method).to eq(:get)
|
480
|
+
expect(VCR::Request.new(:get).method).to eq(:get)
|
481
|
+
expect(VCR::Request.new("get").method).to eq(:get)
|
482
482
|
end
|
483
483
|
end
|
484
484
|
|
@@ -488,19 +488,19 @@ module VCR
|
|
488
488
|
end
|
489
489
|
|
490
490
|
it 'removes the default http port' do
|
491
|
-
uri_for("http://foo.com:80/bar").
|
491
|
+
expect(uri_for("http://foo.com:80/bar")).to eq("http://foo.com/bar")
|
492
492
|
end
|
493
493
|
|
494
494
|
it 'removes the default https port' do
|
495
|
-
uri_for("https://foo.com:443/bar").
|
495
|
+
expect(uri_for("https://foo.com:443/bar")).to eq("https://foo.com/bar")
|
496
496
|
end
|
497
497
|
|
498
498
|
it 'does not remove a non-standard http port' do
|
499
|
-
uri_for("http://foo.com:81/bar").
|
499
|
+
expect(uri_for("http://foo.com:81/bar")).to eq("http://foo.com:81/bar")
|
500
500
|
end
|
501
501
|
|
502
502
|
it 'does not remove a non-standard https port' do
|
503
|
-
uri_for("https://foo.com:442/bar").
|
503
|
+
expect(uri_for("https://foo.com:442/bar")).to eq("https://foo.com:442/bar")
|
504
504
|
end
|
505
505
|
end
|
506
506
|
|
@@ -513,8 +513,8 @@ module VCR
|
|
513
513
|
:done
|
514
514
|
end
|
515
515
|
|
516
|
-
fiber.resume(subject).
|
517
|
-
fiber.resume.
|
516
|
+
expect(fiber.resume(subject)).to be_nil
|
517
|
+
expect(fiber.resume).to eq(:done)
|
518
518
|
end
|
519
519
|
|
520
520
|
it 'can be cast to a proc' do
|
@@ -603,23 +603,23 @@ module VCR
|
|
603
603
|
|
604
604
|
it "does nothing when no compression" do
|
605
605
|
resp = instance('Hello', nil)
|
606
|
-
resp.
|
606
|
+
expect(resp).not_to be_compressed
|
607
607
|
expect {
|
608
|
-
resp.decompress.
|
608
|
+
expect(resp.decompress).to equal(resp)
|
609
609
|
}.to_not change { resp.headers['content-length'] }
|
610
610
|
end
|
611
611
|
|
612
612
|
it "does nothing when encoding is 'identity'" do
|
613
613
|
resp = instance('Hello', 'identity')
|
614
|
-
resp.
|
614
|
+
expect(resp).not_to be_compressed
|
615
615
|
expect {
|
616
|
-
resp.decompress.
|
616
|
+
expect(resp.decompress).to equal(resp)
|
617
617
|
}.to_not change { resp.headers['content-length'] }
|
618
618
|
end
|
619
619
|
|
620
620
|
it "raises error for unrecognized encoding" do
|
621
621
|
resp = instance('Hello', 'flabbergaster')
|
622
|
-
resp.
|
622
|
+
expect(resp).not_to be_compressed
|
623
623
|
expect { resp.decompress }.
|
624
624
|
to raise_error(Errors::UnknownContentEncodingError, 'unknown content encoding: flabbergaster')
|
625
625
|
end
|
@@ -634,11 +634,11 @@ module VCR
|
|
634
634
|
|
635
635
|
gzipped = io.string
|
636
636
|
resp = instance(gzipped, 'gzip')
|
637
|
-
resp.
|
637
|
+
expect(resp).to be_compressed
|
638
638
|
expect {
|
639
|
-
resp.decompress.
|
640
|
-
resp.
|
641
|
-
resp.body.
|
639
|
+
expect(resp.decompress).to equal(resp)
|
640
|
+
expect(resp).not_to be_compressed
|
641
|
+
expect(resp.body).to eq(content)
|
642
642
|
}.to change { resp.headers['content-length'] }.
|
643
643
|
from([gzipped.bytesize.to_s]).
|
644
644
|
to([content.bytesize.to_s])
|
@@ -648,11 +648,11 @@ module VCR
|
|
648
648
|
it "inflates deflated response" do
|
649
649
|
deflated = Zlib::Deflate.deflate(content)
|
650
650
|
resp = instance(deflated, 'deflate')
|
651
|
-
resp.
|
651
|
+
expect(resp).to be_compressed
|
652
652
|
expect {
|
653
|
-
resp.decompress.
|
654
|
-
resp.
|
655
|
-
resp.body.
|
653
|
+
expect(resp.decompress).to equal(resp)
|
654
|
+
expect(resp).not_to be_compressed
|
655
|
+
expect(resp.body).to eq(content)
|
656
656
|
}.to change { resp.headers['content-length'] }.
|
657
657
|
from([deflated.bytesize.to_s]).
|
658
658
|
to([content.bytesize.to_s])
|