vcr 6.1.0 → 6.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vcr/cassette.rb +15 -3
- data/lib/vcr/configuration.rb +1 -0
- data/lib/vcr/middleware/faraday.rb +19 -1
- data/lib/vcr/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 902881c25780fa44253365c8f5fd0bb260510d7f754287d74a70275abc2dabce
|
4
|
+
data.tar.gz: fe52ddaa831a711b7415c350205a2662e833de2c4a6d58b8b6539170645bd218
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f79ffb02f15e691a1266c3421043a5ee95f3bd35715687137f139b291c490ee87a93351e0526faa0f29c73deba80ba41740f87d0fc9d50793a6b6d4101c7b116
|
7
|
+
data.tar.gz: 3e9276ffc9e2a2ae07f4a11054dcb484a324dc18e28a4badaa06df7454db36cfdbfbf38b95aec40c01a15a40cde56fb6cd9868780e50994fc2f554caf86e209a
|
data/lib/vcr/cassette.rb
CHANGED
@@ -46,6 +46,9 @@ module VCR
|
|
46
46
|
# @return [Boolean, nil] Should outdated interactions be recorded back to file
|
47
47
|
attr_reader :clean_outdated_http_interactions
|
48
48
|
|
49
|
+
# @return [Boolean] Should unused requests be dropped from the cassette?
|
50
|
+
attr_reader :drop_unused_requests
|
51
|
+
|
49
52
|
# @return [Array<Symbol>] If set, {VCR::Configuration#before_record} and
|
50
53
|
# {VCR::Configuration#before_playback} hooks with a corresponding tag will apply.
|
51
54
|
attr_reader :tags
|
@@ -176,7 +179,8 @@ module VCR
|
|
176
179
|
:record, :record_on_error, :erb, :match_requests_on, :re_record_interval, :tag, :tags,
|
177
180
|
:update_content_length_header, :allow_playback_repeats, :allow_unused_http_interactions,
|
178
181
|
:exclusive, :serialize_with, :preserve_exact_body_bytes, :decode_compressed_response,
|
179
|
-
:recompress_response, :persist_with, :persister_options, :clean_outdated_http_interactions
|
182
|
+
:recompress_response, :persist_with, :persister_options, :clean_outdated_http_interactions,
|
183
|
+
:drop_unused_requests
|
180
184
|
]
|
181
185
|
|
182
186
|
if invalid_options.size > 0
|
@@ -186,7 +190,7 @@ module VCR
|
|
186
190
|
|
187
191
|
def extract_options
|
188
192
|
[:record_on_error, :erb, :match_requests_on, :re_record_interval, :clean_outdated_http_interactions,
|
189
|
-
:allow_playback_repeats, :allow_unused_http_interactions, :exclusive].each do |name|
|
193
|
+
:allow_playback_repeats, :allow_unused_http_interactions, :exclusive, :drop_unused_requests].each do |name|
|
190
194
|
instance_variable_set("@#{name}", @options[name])
|
191
195
|
end
|
192
196
|
|
@@ -259,6 +263,10 @@ module VCR
|
|
259
263
|
record_mode == :all
|
260
264
|
end
|
261
265
|
|
266
|
+
def should_remove_unused_interactions?
|
267
|
+
@drop_unused_requests
|
268
|
+
end
|
269
|
+
|
262
270
|
def should_assert_no_unused_interactions?
|
263
271
|
!(@allow_unused_http_interactions || $!)
|
264
272
|
end
|
@@ -277,7 +285,11 @@ module VCR
|
|
277
285
|
end
|
278
286
|
end
|
279
287
|
|
280
|
-
|
288
|
+
if should_remove_unused_interactions?
|
289
|
+
new_recorded_interactions
|
290
|
+
else
|
291
|
+
up_to_date_interactions(old_interactions) + new_recorded_interactions
|
292
|
+
end
|
281
293
|
end
|
282
294
|
|
283
295
|
def up_to_date_interactions(interactions)
|
data/lib/vcr/configuration.rb
CHANGED
@@ -495,6 +495,7 @@ module VCR
|
|
495
495
|
:record_on_error => true,
|
496
496
|
:match_requests_on => RequestMatcherRegistry::DEFAULT_MATCHERS,
|
497
497
|
:allow_unused_http_interactions => true,
|
498
|
+
:drop_unused_requests => false,
|
498
499
|
:serialize_with => :yaml,
|
499
500
|
:persist_with => :file_system,
|
500
501
|
:persister_options => {}
|
@@ -45,9 +45,11 @@ module VCR
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def handle
|
48
|
-
# Faraday must be
|
48
|
+
# Faraday must be exclusive here in case another library hook is being used.
|
49
49
|
# We don't want double recording/double playback.
|
50
50
|
VCR.library_hooks.exclusive_hook = :faraday
|
51
|
+
collect_chunks if env.request.stream_response?
|
52
|
+
|
51
53
|
super
|
52
54
|
ensure
|
53
55
|
response = defined?(@vcr_response) ? @vcr_response : nil
|
@@ -103,6 +105,7 @@ module VCR
|
|
103
105
|
@vcr_response = stubbed_response
|
104
106
|
|
105
107
|
faraday_response = ::Faraday::Response.new
|
108
|
+
env.request.on_data.call(stubbed_response.body, stubbed_response.body.length) if env.request.stream_response?
|
106
109
|
faraday_response.finish(env)
|
107
110
|
env[:response] = faraday_response
|
108
111
|
end
|
@@ -111,6 +114,7 @@ module VCR
|
|
111
114
|
@has_on_complete_hook = true
|
112
115
|
response = app.call(env)
|
113
116
|
response.on_complete do
|
117
|
+
restore_body_from_chunks(env.request) if env.request.stream_response?
|
114
118
|
@vcr_response = response_for(response)
|
115
119
|
VCR.record_http_interaction(VCR::HTTPInteraction.new(vcr_request, @vcr_response))
|
116
120
|
invoke_after_request_hook(@vcr_response) if delay_finishing?
|
@@ -121,6 +125,20 @@ module VCR
|
|
121
125
|
super
|
122
126
|
VCR.library_hooks.exclusive_hook = nil
|
123
127
|
end
|
128
|
+
|
129
|
+
def collect_chunks
|
130
|
+
caller_on_data = env.request.on_data
|
131
|
+
chunks = ''
|
132
|
+
env.request.on_data = Proc.new do |chunk, overall_received_bytes|
|
133
|
+
chunks += chunk
|
134
|
+
env.request.instance_variable_set(:@chunked_body, chunks)
|
135
|
+
caller_on_data.call(chunk, overall_received_bytes)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def restore_body_from_chunks(request)
|
140
|
+
env[:body] = request.instance_variable_get(:@chunked_body)
|
141
|
+
end
|
124
142
|
end
|
125
143
|
end
|
126
144
|
end
|
data/lib/vcr/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Myron Marston
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-06-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -365,7 +365,7 @@ files:
|
|
365
365
|
- lib/vcr/util/variable_args_block_caller.rb
|
366
366
|
- lib/vcr/util/version_checker.rb
|
367
367
|
- lib/vcr/version.rb
|
368
|
-
homepage: https://
|
368
|
+
homepage: https://benoittgt.github.io/vcr
|
369
369
|
licenses:
|
370
370
|
- Hippocratic-2.1
|
371
371
|
- MIT
|
@@ -378,14 +378,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
378
378
|
requirements:
|
379
379
|
- - ">="
|
380
380
|
- !ruby/object:Gem::Version
|
381
|
-
version: '2.
|
381
|
+
version: '2.7'
|
382
382
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
383
383
|
requirements:
|
384
384
|
- - ">="
|
385
385
|
- !ruby/object:Gem::Version
|
386
386
|
version: '0'
|
387
387
|
requirements: []
|
388
|
-
rubygems_version: 3.
|
388
|
+
rubygems_version: 3.4.14
|
389
389
|
signing_key:
|
390
390
|
specification_version: 4
|
391
391
|
summary: Record your test suite's HTTP interactions and replay them during future
|