vcr 2.5.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +8 -8
  2. data/.travis.yml +0 -3
  3. data/CHANGELOG.md +32 -3
  4. data/Gemfile +33 -0
  5. data/Gemfile.lock +99 -119
  6. data/README.md +19 -7
  7. data/Rakefile +5 -9
  8. data/benchmarks/null_logging.rb +62 -0
  9. data/features/.nav +0 -1
  10. data/features/about_these_examples.md +1 -2
  11. data/features/cassettes/allow_unused_http_interactions.feature +15 -1
  12. data/features/cassettes/decompress.feature +6 -2
  13. data/features/cassettes/format.feature +20 -12
  14. data/features/cassettes/freezing_time.feature +68 -0
  15. data/features/configuration/cassette_library_dir.feature +5 -0
  16. data/features/configuration/preserve_exact_body_bytes.feature +5 -0
  17. data/features/configuration/uri_parser.feature +2 -4
  18. data/features/http_libraries/net_http.feature +1 -1
  19. data/features/request_matching/headers.feature +0 -1
  20. data/features/step_definitions/cli_steps.rb +1 -4
  21. data/features/test_frameworks/cucumber.feature +59 -0
  22. data/features/test_frameworks/rspec_metadata.feature +59 -1
  23. data/gemfiles/typhoeus_old.gemfile +19 -0
  24. data/gemfiles/typhoeus_old.gemfile.lock +84 -86
  25. data/lib/vcr.rb +12 -3
  26. data/lib/vcr/cassette.rb +32 -11
  27. data/lib/vcr/cassette/http_interaction_list.rb +3 -2
  28. data/lib/vcr/cassette/migrator.rb +1 -0
  29. data/lib/vcr/cassette/serializers/json.rb +1 -1
  30. data/lib/vcr/configuration.rb +17 -9
  31. data/lib/vcr/library_hooks/typhoeus.rb +3 -2
  32. data/lib/vcr/library_hooks/webmock.rb +1 -1
  33. data/lib/vcr/middleware/excon.rb +13 -1
  34. data/lib/vcr/middleware/faraday.rb +1 -0
  35. data/lib/vcr/request_handler.rb +1 -1
  36. data/lib/vcr/structs.rb +19 -4
  37. data/lib/vcr/test_frameworks/cucumber.rb +2 -2
  38. data/lib/vcr/test_frameworks/rspec.rb +10 -2
  39. data/lib/vcr/util/logger.rb +41 -7
  40. data/lib/vcr/version.rb +1 -1
  41. data/script/ci.sh +8 -1
  42. data/spec/acceptance/threading_spec.rb +6 -0
  43. data/spec/capture_warnings.rb +9 -1
  44. data/spec/spec_helper.rb +6 -2
  45. data/spec/support/configuration_stubbing.rb +8 -0
  46. data/spec/support/http_library_adapters.rb +1 -1
  47. data/spec/support/limited_uri.rb +1 -0
  48. data/spec/support/shared_example_groups/excon.rb +23 -1
  49. data/spec/support/shared_example_groups/hook_into_http_library.rb +12 -12
  50. data/spec/support/shared_example_groups/request_hooks.rb +1 -1
  51. data/spec/support/sinatra_app.rb +9 -0
  52. data/spec/support/vcr_localhost_server.rb +4 -25
  53. data/spec/support/vcr_stub_helpers.rb +1 -1
  54. data/spec/vcr/cassette/http_interaction_list_spec.rb +41 -14
  55. data/spec/vcr/cassette/migrator_spec.rb +1 -1
  56. data/spec/vcr/cassette/persisters_spec.rb +2 -2
  57. data/spec/vcr/cassette/serializers_spec.rb +13 -4
  58. data/spec/vcr/cassette_spec.rb +107 -58
  59. data/spec/vcr/configuration_spec.rb +23 -23
  60. data/spec/vcr/deprecations_spec.rb +9 -9
  61. data/spec/vcr/errors_spec.rb +6 -6
  62. data/spec/vcr/library_hooks/excon_spec.rb +15 -10
  63. data/spec/vcr/library_hooks/fakeweb_spec.rb +8 -8
  64. data/spec/vcr/library_hooks/faraday_spec.rb +1 -1
  65. data/spec/vcr/library_hooks/typhoeus_0.4_spec.rb +2 -2
  66. data/spec/vcr/library_hooks/typhoeus_spec.rb +68 -9
  67. data/spec/vcr/library_hooks/webmock_spec.rb +6 -10
  68. data/spec/vcr/middleware/faraday_spec.rb +33 -5
  69. data/spec/vcr/middleware/rack_spec.rb +2 -2
  70. data/spec/vcr/request_matcher_registry_spec.rb +11 -6
  71. data/spec/vcr/structs_spec.rb +114 -47
  72. data/spec/vcr/test_frameworks/cucumber_spec.rb +4 -4
  73. data/spec/vcr/util/hooks_spec.rb +2 -2
  74. data/spec/vcr/util/internet_connection_spec.rb +3 -3
  75. data/spec/vcr/util/version_checker_spec.rb +4 -4
  76. data/spec/vcr_spec.rb +22 -16
  77. data/vcr.gemspec +2 -31
  78. metadata +9 -328
  79. data/features/test_frameworks/shoulda.feature +0 -64
@@ -40,10 +40,10 @@ describe "WebMock hook", :with_monkey_patches => :webmock do
40
40
 
41
41
  context "when there'ss a bug and the request does not have the @__typed_vcr_request in the after_request callbacks" do
42
42
  let(:warner) { VCR::LibraryHooks::WebMock }
43
- before { warner.stub(:warn) }
43
+ before { allow(warner).to receive(:warn) }
44
44
 
45
45
  it 'records the HTTP interaction properly' do
46
- VCR.should_receive(:record_http_interaction) do |i|
46
+ expect(VCR).to receive(:record_http_interaction) do |i|
47
47
  expect(i.request.uri).to eq("http://foo.com/")
48
48
  expect(i.response.body).to eq("OK")
49
49
  end
@@ -63,7 +63,7 @@ describe "WebMock hook", :with_monkey_patches => :webmock do
63
63
  end
64
64
 
65
65
  it 'prints a warning' do
66
- warner.should_receive(:warn).at_least(:once).with(/bug.*after_request/)
66
+ expect(warner).to receive(:warn).at_least(:once).with(/bug.*after_request/)
67
67
 
68
68
  run_after_request_callback
69
69
  end
@@ -98,7 +98,7 @@ describe "WebMock hook", :with_monkey_patches => :webmock do
98
98
 
99
99
  expect {
100
100
  make_http_request(:get, request_url)
101
- }.to_not raise_error(unexpected_error)
101
+ }.to_not raise_error
102
102
  end
103
103
 
104
104
  it 'can allow connections to matching urls' do
@@ -107,16 +107,12 @@ describe "WebMock hook", :with_monkey_patches => :webmock do
107
107
 
108
108
  expect {
109
109
  make_http_request(:get, request_url)
110
- }.to_not raise_error(unexpected_error)
110
+ }.to_not raise_error
111
111
  end
112
112
  end
113
113
  end
114
114
  end
115
115
 
116
- it_behaves_like "Excon streaming" do
117
- before(:each) do
118
- pending "waiting on bblimke/webmock#246 for a fix"
119
- end
120
- end
116
+ it_behaves_like "Excon streaming"
121
117
  end
122
118
 
@@ -7,8 +7,7 @@ describe VCR::Middleware::Faraday do
7
7
  http_libs.each do |lib|
8
8
  it_behaves_like 'a hook into an HTTP library', :faraday, "faraday (w/ #{lib})",
9
9
  :status_message_not_exposed,
10
- :does_not_support_rotating_responses,
11
- :not_disableable
10
+ :does_not_support_rotating_responses
12
11
  end
13
12
 
14
13
  context 'when performing a multipart upload' do
@@ -22,7 +21,7 @@ describe VCR::Middleware::Faraday do
22
21
  it 'records the request body correctly' do
23
22
  payload = { :file => Faraday::UploadIO.new(__FILE__, 'text/plain') }
24
23
 
25
- VCR.should_receive(:record_http_interaction) do |i|
24
+ expect(VCR).to receive(:record_http_interaction) do |i|
26
25
  expect(i.request.headers['Content-Type'].first).to include("multipart")
27
26
  expect(i.request.body).to include(File.read(__FILE__))
28
27
  end
@@ -43,6 +42,35 @@ describe VCR::Middleware::Faraday do
43
42
  end
44
43
  end
45
44
 
45
+ context 'when extending the response body with an extension module' do
46
+ let(:connection) { ::Faraday.new("http://localhost:#{VCR::SinatraApp.port}/") }
47
+
48
+ def process_response(response)
49
+ response.body.extend Module.new { attr_accessor :_response }
50
+ response.body._response = response
51
+ end
52
+
53
+ it 'does not record the body extensions to the cassette' do
54
+ 3.times do |i|
55
+ VCR.use_cassette("hack", :record => :new_episodes) do
56
+ response = connection.get("/foo")
57
+ process_response(response)
58
+
59
+ # Do something different after the first time to
60
+ # ensure new interactions are added to an existing
61
+ # cassette.
62
+ if i > 1
63
+ response = connection.get("/")
64
+ process_response(response)
65
+ end
66
+ end
67
+ end
68
+
69
+ contents = VCR::Cassette.new("hack").send(:raw_cassette_bytes)
70
+ expect(contents).not_to include("ruby/object:Faraday::Response")
71
+ end
72
+ end
73
+
46
74
  context 'when making parallel requests' do
47
75
  include VCRStubHelpers
48
76
  let(:connection) { ::Faraday.new { |b| b.adapter :typhoeus } }
@@ -102,7 +130,7 @@ describe VCR::Middleware::Faraday do
102
130
 
103
131
  context 'for a recorded request' do
104
132
  let!(:inserted_cassette) { VCR.insert_cassette('new_cassette') }
105
- before(:each) { VCR.should_receive(:record_http_interaction) }
133
+ before(:each) { expect(VCR).to receive(:record_http_interaction) }
106
134
  it_behaves_like "exclusive library hook"
107
135
  end
108
136
 
@@ -132,7 +160,7 @@ describe VCR::Middleware::Faraday do
132
160
  it 'can be used to eject a cassette after the request is recorded' do
133
161
  VCR.configuration.after_http_request { |request| VCR.eject_cassette }
134
162
 
135
- VCR.should_receive(:record_http_interaction) do |interaction|
163
+ expect(VCR).to receive(:record_http_interaction) do |interaction|
136
164
  expect(VCR.current_cassette).to be(inserted_cassette)
137
165
  end
138
166
 
@@ -45,8 +45,8 @@ module VCR
45
45
  describe '#call' do
46
46
  let(:env_hash) { { :env => :hash } }
47
47
  it 'calls the provided rack app and returns its response' do
48
- rack_app = mock
49
- rack_app.should_receive(:call).with(env_hash).and_return(:response)
48
+ rack_app = double
49
+ expect(rack_app).to receive(:call).with(env_hash).and_return(:response)
50
50
  instance = described_class.new(rack_app) { |c| c.name 'cassette_name' }
51
51
  expect(instance.call(env_hash)).to eq(:response)
52
52
  end
@@ -2,11 +2,16 @@ require 'vcr/request_matcher_registry'
2
2
  require 'vcr/structs'
3
3
  require 'support/limited_uri'
4
4
  require 'cgi'
5
+ require 'support/configuration_stubbing'
5
6
 
6
7
  module VCR
7
8
  describe RequestMatcherRegistry do
8
- before { VCR.stub_chain(:configuration, :uri_parser) { LimitedURI } }
9
- before { VCR.stub_chain(:configuration, :query_parser) { CGI.method(:parse) } }
9
+ include_context "configuration stubbing"
10
+
11
+ before do
12
+ allow(config).to receive(:uri_parser) { LimitedURI }
13
+ allow(config).to receive(:query_parser) { CGI.method(:parse) }
14
+ end
10
15
 
11
16
  def request_with(values)
12
17
  VCR::Request.new.tap do |request|
@@ -20,23 +25,23 @@ module VCR
20
25
  it 'registers a request matcher block that can be used later' do
21
26
  matcher_called = false
22
27
  subject.register(:my_matcher) { |*a| matcher_called = true }
23
- subject[:my_matcher].matches?(stub, stub)
28
+ subject[:my_matcher].matches?(double, double)
24
29
  expect(matcher_called).to be_true
25
30
  end
26
31
 
27
32
  context 'when there is already a matcher for the given name' do
28
33
  before(:each) do
29
34
  subject.register(:foo) { |*a| false }
30
- subject.stub :warn
35
+ allow(subject).to receive :warn
31
36
  end
32
37
 
33
38
  it 'overrides the existing matcher' do
34
39
  subject.register(:foo) { |*a| true }
35
- expect(subject[:foo].matches?(stub, stub)).to be_true
40
+ expect(subject[:foo].matches?(double, double)).to be_true
36
41
  end
37
42
 
38
43
  it 'warns that there is a name collision' do
39
- subject.should_receive(:warn).with(
44
+ expect(subject).to receive(:warn).with(
40
45
  /WARNING: There is already a VCR request matcher registered for :foo\. Overriding it/
41
46
  )
42
47
 
@@ -8,6 +8,7 @@ require 'vcr/errors'
8
8
  require 'zlib'
9
9
  require 'stringio'
10
10
  require 'support/limited_uri'
11
+ require 'support/configuration_stubbing'
11
12
 
12
13
  shared_examples_for "a header normalizer" do
13
14
  let(:instance) do
@@ -61,7 +62,8 @@ end
61
62
 
62
63
  module VCR
63
64
  describe HTTPInteraction do
64
- before { VCR.stub_chain(:configuration, :uri_parser) { LimitedURI } }
65
+ include_context "configuration stubbing"
66
+ before { allow(config).to receive(:uri_parser) { LimitedURI } }
65
67
 
66
68
  if ''.respond_to?(:encoding)
67
69
  def body_hash(key, value)
@@ -77,7 +79,7 @@ module VCR
77
79
  let(:now) { Time.now }
78
80
 
79
81
  it 'is initialized to the current time' do
80
- Time.stub(:now => now)
82
+ allow(Time).to receive(:now).and_return(now)
81
83
  expect(VCR::HTTPInteraction.new.recorded_at).to eq(now)
82
84
  end
83
85
  end
@@ -118,6 +120,18 @@ module VCR
118
120
  expect(HTTPInteraction.from_hash(hash).recorded_at).to eq(recorded_at)
119
121
  end
120
122
 
123
+ it 'initializes the response adapter_metadata from the hash if it is included' do
124
+ hash['response']['adapter_metadata'] = { 'foo' => 12 }
125
+ interaction = HTTPInteraction.from_hash(hash)
126
+ expect(interaction.response.adapter_metadata).to eq("foo" => 12)
127
+ end
128
+
129
+ it 'works when the response adapter_metadata is missing' do
130
+ expect(hash['response'].keys).not_to include('adapter_metadata')
131
+ interaction = HTTPInteraction.from_hash(hash)
132
+ expect(interaction.response.adapter_metadata).to eq({})
133
+ end
134
+
121
135
  it 'uses a blank request when the hash lacks one' do
122
136
  hash.delete('request')
123
137
  i = HTTPInteraction.from_hash(hash)
@@ -192,7 +206,7 @@ module VCR
192
206
  expect(string).to be_valid_encoding
193
207
  hash['request']['body'] = { 'string' => string, 'encoding' => 'ASCII-8BIT' }
194
208
 
195
- Request.should_not_receive(:warn)
209
+ expect(Request).not_to receive(:warn)
196
210
  i = HTTPInteraction.from_hash(hash)
197
211
  expect(i.request.body).to eq(string)
198
212
  expect(i.request.body.bytes.to_a).to eq(string.bytes.to_a)
@@ -201,14 +215,12 @@ module VCR
201
215
 
202
216
  context 'when the string cannot be encoded as the original encoding' do
203
217
  def verify_encoding_error
204
- pending "rubinius 1.9 mode does not raise an encoding error", :if => (RUBY_INTERPRETER == :rubinius && RUBY_VERSION =~ /^1.9/) do
205
- expect { "\xFAbc".encode("ISO-8859-1") }.to raise_error(EncodingError)
206
- end
218
+ expect { "\xFAbc".encode("ISO-8859-1") }.to raise_error(EncodingError)
207
219
  end
208
220
 
209
221
  before do
210
- Request.stub(:warn)
211
- Response.stub(:warn)
222
+ allow(Request).to receive(:warn)
223
+ allow(Response).to receive(:warn)
212
224
 
213
225
  hash['request']['body'] = { 'string' => "\xFAbc", 'encoding' => 'ISO-8859-1' }
214
226
  hash['response']['body'] = { 'string' => "\xFAbc", 'encoding' => 'ISO-8859-1' }
@@ -225,8 +237,8 @@ module VCR
225
237
  end
226
238
 
227
239
  it 'prints a warning and informs users of the :preserve_exact_body_bytes option' do
228
- Request.should_receive(:warn).with(/ISO-8859-1.*preserve_exact_body_bytes/)
229
- Response.should_receive(:warn).with(/ISO-8859-1.*preserve_exact_body_bytes/)
240
+ expect(Request).to receive(:warn).with(/ISO-8859-1.*preserve_exact_body_bytes/)
241
+ expect(Response).to receive(:warn).with(/ISO-8859-1.*preserve_exact_body_bytes/)
230
242
 
231
243
  HTTPInteraction.from_hash(hash)
232
244
  end
@@ -235,9 +247,11 @@ module VCR
235
247
  end
236
248
 
237
249
  describe "#to_hash" do
250
+ include_context "configuration stubbing"
251
+
238
252
  before(:each) do
239
- VCR.stub_chain(:configuration, :preserve_exact_body_bytes_for?).and_return(false)
240
- VCR.stub_chain(:configuration, :uri_parser).and_return(URI)
253
+ allow(config).to receive(:preserve_exact_body_bytes_for?).and_return(false)
254
+ allow(config).to receive(:uri_parser).and_return(URI)
241
255
  end
242
256
 
243
257
  let(:hash) { interaction.to_hash }
@@ -265,8 +279,29 @@ module VCR
265
279
  })
266
280
  end
267
281
 
282
+ it 'includes the response adapter metadata when it is not empty' do
283
+ interaction.response.adapter_metadata['foo'] = 17
284
+ expect(hash['response']['adapter_metadata']).to eq('foo' => 17)
285
+ end
286
+
287
+ it 'does not include the response adapter metadata when it is empty' do
288
+ expect(interaction.response.adapter_metadata).to eq({})
289
+ expect(hash['response'].keys).not_to include('adapter_metadata')
290
+ end
291
+
292
+ context "when the body is extended with a module and some state" do
293
+ it 'serializes to YAML w/o the extra state' do
294
+ interaction.request.body.extend Module.new { attr_accessor :foo }
295
+ interaction.response.body.extend Module.new { attr_accessor :foo }
296
+ interaction.request.body.foo = 98765
297
+ interaction.response.body.foo = 98765
298
+
299
+ expect(YAML.dump(interaction.to_hash)).not_to include("98765")
300
+ end
301
+ end
302
+
268
303
  it 'encodes the body as base64 when the configuration is so set' do
269
- VCR.stub_chain(:configuration, :preserve_exact_body_bytes_for?).and_return(true)
304
+ allow(config).to receive(:preserve_exact_body_bytes_for?).and_return(true)
270
305
  expect(hash['request']['body']).to eq(body_hash('base64_string', Base64.encode64('req body')))
271
306
  expect(hash['response']['body']).to eq(body_hash('base64_string', Base64.encode64('res body')))
272
307
  end
@@ -291,19 +326,24 @@ module VCR
291
326
  assert_yielded_keys hash['response'], 'status', 'headers', 'body', 'http_version'
292
327
  assert_yielded_keys hash['response']['status'], 'code', 'message'
293
328
  end
329
+
330
+ it 'yields `adapter_metadata` if it has any data' do
331
+ interaction.response.adapter_metadata['foo'] = 17
332
+ assert_yielded_keys hash['response'], 'status', 'headers', 'body', 'http_version', 'adapter_metadata'
333
+ end
294
334
  end
295
335
 
296
336
  describe "#parsed_uri" do
297
337
  before :each do
298
- uri_parser.stub(:parse).and_return(uri)
299
- VCR.stub_chain(:configuration, :uri_parser).and_return(uri_parser)
338
+ allow(uri_parser).to receive(:parse).and_return(uri)
339
+ allow(config).to receive(:uri_parser).and_return(uri_parser)
300
340
  end
301
341
 
302
- let(:uri_parser){ mock('parser') }
303
- let(:uri){ mock('uri').as_null_object }
342
+ let(:uri_parser){ double('parser') }
343
+ let(:uri){ double('uri').as_null_object }
304
344
 
305
345
  it "parses the uri using the current uri_parser" do
306
- uri_parser.should_receive(:parse).with(request.uri)
346
+ expect(uri_parser).to receive(:parse).with(request.uri)
307
347
  request.parsed_uri
308
348
  end
309
349
 
@@ -314,7 +354,11 @@ module VCR
314
354
  end
315
355
 
316
356
  describe HTTPInteraction::HookAware do
317
- before { VCR.stub_chain(:configuration, :uri_parser) { LimitedURI } }
357
+ include_context "configuration stubbing"
358
+
359
+ before do
360
+ allow(config).to receive(:uri_parser) { LimitedURI }
361
+ end
318
362
 
319
363
  let(:response_status) { VCR::ResponseStatus.new(200, "OK foo") }
320
364
  let(:body) { "The body foo this is (foo-Foo)" }
@@ -399,14 +443,14 @@ module VCR
399
443
  describe Request::Typed do
400
444
  [:uri, :method, :headers, :body].each do |method|
401
445
  it "delegates ##{method} to the request" do
402
- request = stub(method => "delegated value")
446
+ request = double(method => "delegated value")
403
447
  expect(Request::Typed.new(request, :type).send(method)).to eq("delegated value")
404
448
  end
405
449
  end
406
450
 
407
451
  describe "#type" do
408
452
  it 'returns the initialized type' do
409
- expect(Request::Typed.new(stub, :ignored).type).to be(:ignored)
453
+ expect(Request::Typed.new(double, :ignored).type).to be(:ignored)
410
454
  end
411
455
  end
412
456
 
@@ -414,11 +458,11 @@ module VCR
414
458
  valid_types.each do |type|
415
459
  describe "##{type}?" do
416
460
  it "returns true if the type is set to :#{type}" do
417
- expect(Request::Typed.new(stub, type).send("#{type}?")).to be_true
461
+ expect(Request::Typed.new(double, type).send("#{type}?")).to be_true
418
462
  end
419
463
 
420
464
  it "returns false if the type is set to :other" do
421
- expect(Request::Typed.new(stub, :other).send("#{type}?")).to be_false
465
+ expect(Request::Typed.new(double, :other).send("#{type}?")).to be_false
422
466
  end
423
467
  end
424
468
  end
@@ -427,13 +471,13 @@ module VCR
427
471
  real_types = [:ignored, :recordable]
428
472
  real_types.each do |type|
429
473
  it "returns true if the type is set to :#{type}" do
430
- expect(Request::Typed.new(stub, type)).to be_real
474
+ expect(Request::Typed.new(double, type)).to be_real
431
475
  end
432
476
  end
433
477
 
434
478
  (valid_types - real_types).each do |type|
435
479
  it "returns false if the type is set to :#{type}" do
436
- expect(Request::Typed.new(stub, type)).not_to be_real
480
+ expect(Request::Typed.new(double, type)).not_to be_real
437
481
  end
438
482
  end
439
483
  end
@@ -442,20 +486,24 @@ module VCR
442
486
  stubbed_types = [:externally_stubbed, :stubbed_by_vcr]
443
487
  stubbed_types.each do |type|
444
488
  it "returns true if the type is set to :#{type}" do
445
- expect(Request::Typed.new(stub, type)).to be_stubbed
489
+ expect(Request::Typed.new(double, type)).to be_stubbed
446
490
  end
447
491
  end
448
492
 
449
493
  (valid_types - stubbed_types).each do |type|
450
494
  it "returns false if the type is set to :#{type}" do
451
- expect(Request::Typed.new(stub, type)).not_to be_stubbed
495
+ expect(Request::Typed.new(double, type)).not_to be_stubbed
452
496
  end
453
497
  end
454
498
  end
455
499
  end
456
500
 
457
501
  describe Request do
458
- before { VCR.stub_chain(:configuration, :uri_parser) { LimitedURI } }
502
+ include_context "configuration stubbing"
503
+
504
+ before do
505
+ allow(config).to receive(:uri_parser) { LimitedURI }
506
+ end
459
507
 
460
508
  describe '#method' do
461
509
  subject { VCR::Request.new(:get) }
@@ -518,7 +566,7 @@ module VCR
518
566
  end
519
567
 
520
568
  it 'can be cast to a proc' do
521
- Fiber.should_receive(:yield)
569
+ expect(Fiber).to receive(:yield)
522
570
  lambda(&subject).call
523
571
  end
524
572
  end if RUBY_VERSION > '1.9'
@@ -549,6 +597,27 @@ module VCR
549
597
  end
550
598
  end
551
599
 
600
+ describe "#adapter_metadata" do
601
+ it 'returns the hash given as the last #initialize argument' do
602
+ response = Response.new(
603
+ ResponseStatus.new(200, "OK"),
604
+ {}, "the body", "1.1",
605
+ { "meta" => "value" }
606
+ )
607
+
608
+ expect(response.adapter_metadata).to eq("meta" => "value")
609
+ end
610
+
611
+ it 'returns a blank hash when nil is passed to #initialize' do
612
+ response = Response.new(
613
+ ResponseStatus.new(200, "OK"),
614
+ {}, "the body", "1.1", nil
615
+ )
616
+
617
+ expect(response.adapter_metadata).to eq({})
618
+ end
619
+ end
620
+
552
621
  describe '#update_content_length_header' do
553
622
  %w[ content-length Content-Length ].each do |header|
554
623
  context "for the #{header} header" do
@@ -625,24 +694,22 @@ module VCR
625
694
  end
626
695
 
627
696
  it "unzips gzipped response" do
628
- pending "rubinius 1.9 mode has a Gzip issue", :if => (RUBY_INTERPRETER == :rubinius && RUBY_VERSION =~ /^1.9/) do
629
- io = StringIO.new
630
-
631
- writer = Zlib::GzipWriter.new(io)
632
- writer << content
633
- writer.close
634
-
635
- gzipped = io.string
636
- resp = instance(gzipped, 'gzip')
637
- expect(resp).to be_compressed
638
- expect {
639
- expect(resp.decompress).to equal(resp)
640
- expect(resp).not_to be_compressed
641
- expect(resp.body).to eq(content)
642
- }.to change { resp.headers['content-length'] }.
643
- from([gzipped.bytesize.to_s]).
644
- to([content.bytesize.to_s])
645
- end
697
+ io = StringIO.new
698
+
699
+ writer = Zlib::GzipWriter.new(io)
700
+ writer << content
701
+ writer.close
702
+
703
+ gzipped = io.string
704
+ resp = instance(gzipped, 'gzip')
705
+ expect(resp).to be_compressed
706
+ expect {
707
+ expect(resp.decompress).to equal(resp)
708
+ expect(resp).not_to be_compressed
709
+ expect(resp.body).to eq(content)
710
+ }.to change { resp.headers['content-length'] }.
711
+ from([gzipped.bytesize.to_s]).
712
+ to([content.bytesize.to_s])
646
713
  end
647
714
 
648
715
  it "inflates deflated response" do