vcr 6.4.0 → 6.4.1
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 +4 -4
- data/lib/vcr/cassette/erb_renderer.rb +1 -1
- data/lib/vcr/cassette/migrator.rb +1 -1
- data/lib/vcr/cassette.rb +20 -2
- data/lib/vcr/configuration.rb +13 -11
- data/lib/vcr/errors.rb +12 -12
- data/lib/vcr/library_hooks/typhoeus.rb +7 -7
- data/lib/vcr/library_hooks/webmock.rb +4 -4
- data/lib/vcr/middleware/excon.rb +3 -3
- data/lib/vcr/middleware/faraday.rb +1 -1
- data/lib/vcr/middleware/rack.rb +1 -1
- data/lib/vcr/request_matcher_registry.rb +2 -2
- data/lib/vcr/structs.rb +19 -3
- data/lib/vcr/test_frameworks/cucumber.rb +2 -2
- data/lib/vcr/test_frameworks/rspec.rb +2 -2
- data/lib/vcr/version.rb +1 -1
- data/lib/vcr.rb +13 -13
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8d9f32f07f523abec1ff78ce1c27771cbc7dd0568c80952075c4f28757b6261f
|
|
4
|
+
data.tar.gz: f4cb9ab001e861be14abee247c834aa5364b4858576bbb4e7dd11ce590f23692
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4069dfa5b9bf2f682fcff97d9c81fbd4364466a75b1126e3360af71668771d4d1fe0bfd6d6c13f5fa7d0335c4c7ad6eacf655a3ed818a7a5d0851d6aff25270d
|
|
7
|
+
data.tar.gz: 992c507dcde216017705d4c9550ba9343a8171fe6cc5f633c4c1faca20f0c4bc177906eed9d3831235bdc051141de6dbe225d9fc9dcec85b36afed695fcabe7d
|
|
@@ -23,7 +23,7 @@ module VCR
|
|
|
23
23
|
|
|
24
24
|
raise Errors::MissingERBVariableError.new(
|
|
25
25
|
"The ERB in the #{@cassette_name} cassette file references undefined variable #{e.name}. " +
|
|
26
|
-
"Pass it to the cassette using :
|
|
26
|
+
"Pass it to the cassette using erb: #{ example_hash.inspect }."
|
|
27
27
|
)
|
|
28
28
|
end
|
|
29
29
|
|
data/lib/vcr/cassette.rb
CHANGED
|
@@ -64,7 +64,7 @@ module VCR
|
|
|
64
64
|
extract_options
|
|
65
65
|
raise_error_unless_valid_record_mode
|
|
66
66
|
|
|
67
|
-
log "Initialized with options: #{@options
|
|
67
|
+
log "Initialized with options: #{format_options_for_log(@options)}"
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
# Ejects the current cassette. The cassette will no longer be used.
|
|
@@ -147,10 +147,17 @@ module VCR
|
|
|
147
147
|
|
|
148
148
|
# @return [Hash] The hash that will be serialized when the cassette is written to disk.
|
|
149
149
|
def serializable_hash
|
|
150
|
-
{
|
|
150
|
+
hash = {
|
|
151
151
|
"http_interactions" => interactions_to_record.map(&:to_hash),
|
|
152
152
|
"recorded_with" => "VCR #{VCR.version}"
|
|
153
153
|
}
|
|
154
|
+
hash["metadata"] = metadata unless metadata.empty?
|
|
155
|
+
hash
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# @return [Hash] Custom metadata associated with the cassette.
|
|
159
|
+
def metadata
|
|
160
|
+
@metadata ||= recording? ? {} : (deserialized_hash['metadata'] || {})
|
|
154
161
|
end
|
|
155
162
|
|
|
156
163
|
# @return [Time, nil] The `recorded_at` time of the first HTTP interaction
|
|
@@ -214,6 +221,7 @@ module VCR
|
|
|
214
221
|
@previously_recorded_interactions ||= if !raw_cassette_bytes.to_s.empty?
|
|
215
222
|
deserialized_hash['http_interactions'].map { |h| HTTPInteraction.from_hash(h) }.tap do |interactions|
|
|
216
223
|
invoke_hook(:before_playback, interactions)
|
|
224
|
+
invoke_hook(:recompress_response, interactions)
|
|
217
225
|
|
|
218
226
|
interactions.reject! do |i|
|
|
219
227
|
i.request.uri.is_a?(String) && VCR.request_ignorer.ignore?(i.request)
|
|
@@ -338,6 +346,16 @@ module VCR
|
|
|
338
346
|
@log_prefix ||= "[Cassette: '#{name}'] "
|
|
339
347
|
end
|
|
340
348
|
|
|
349
|
+
# Use the legacy `{:key=>val}` format (Ruby 3.4 changed Hash#inspect for symbol keys).
|
|
350
|
+
def format_options_for_log(value)
|
|
351
|
+
case value
|
|
352
|
+
when Hash
|
|
353
|
+
"{#{value.map { |k, v| "#{k.inspect}=>#{format_options_for_log(v)}" }.join(', ')}}"
|
|
354
|
+
else
|
|
355
|
+
value.inspect
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
|
|
341
359
|
def request_summary(request)
|
|
342
360
|
super(request, match_requests_on)
|
|
343
361
|
end
|
data/lib/vcr/configuration.rb
CHANGED
|
@@ -39,7 +39,7 @@ module VCR
|
|
|
39
39
|
# @return [void]
|
|
40
40
|
# @example
|
|
41
41
|
# VCR.configure do |c|
|
|
42
|
-
# c.default_cassette_options = { :
|
|
42
|
+
# c.default_cassette_options = { record: :new_episodes }
|
|
43
43
|
# end
|
|
44
44
|
# @note {VCR#insert_cassette} for the list of valid options.
|
|
45
45
|
attr_reader :default_cassette_options
|
|
@@ -184,7 +184,7 @@ module VCR
|
|
|
184
184
|
# end
|
|
185
185
|
# end
|
|
186
186
|
#
|
|
187
|
-
# VCR.use_cassette("my_cassette", :
|
|
187
|
+
# VCR.use_cassette("my_cassette", match_requests_on: [:method, :host, :port]) do
|
|
188
188
|
# # ...
|
|
189
189
|
# end
|
|
190
190
|
#
|
|
@@ -490,14 +490,14 @@ module VCR
|
|
|
490
490
|
@allow_http_connections_when_no_cassette = nil
|
|
491
491
|
@rspec_metadata_configured = false
|
|
492
492
|
@default_cassette_options = {
|
|
493
|
-
:
|
|
494
|
-
:
|
|
495
|
-
:
|
|
496
|
-
:
|
|
497
|
-
:
|
|
498
|
-
:
|
|
499
|
-
:
|
|
500
|
-
:
|
|
493
|
+
record: :once,
|
|
494
|
+
record_on_error: true,
|
|
495
|
+
match_requests_on: RequestMatcherRegistry::DEFAULT_MATCHERS,
|
|
496
|
+
allow_unused_http_interactions: true,
|
|
497
|
+
drop_unused_requests: false,
|
|
498
|
+
serialize_with: :yaml,
|
|
499
|
+
persist_with: :file_system,
|
|
500
|
+
persister_options: {}
|
|
501
501
|
}
|
|
502
502
|
|
|
503
503
|
self.uri_parser = URI
|
|
@@ -566,8 +566,10 @@ module VCR
|
|
|
566
566
|
lambda { |arg| arg.send(object) }
|
|
567
567
|
end
|
|
568
568
|
|
|
569
|
+
define_hook :recompress_response
|
|
570
|
+
|
|
569
571
|
def register_built_in_hooks
|
|
570
|
-
|
|
572
|
+
recompress_response(tag_filter_from(:recompress_response)) do |interaction|
|
|
571
573
|
interaction.response.recompress if interaction.response.vcr_decompressed?
|
|
572
574
|
end
|
|
573
575
|
|
data/lib/vcr/errors.rb
CHANGED
|
@@ -157,8 +157,8 @@ module VCR
|
|
|
157
157
|
lines = current_cassettes.inject(lines) do |memo, cassette|
|
|
158
158
|
memo.concat([
|
|
159
159
|
" - #{cassette.file}",
|
|
160
|
-
" - :
|
|
161
|
-
" - :
|
|
160
|
+
" - record: #{cassette.record_mode.inspect}",
|
|
161
|
+
" - match_requests_on: #{cassette.match_requests_on.inspect}"
|
|
162
162
|
])
|
|
163
163
|
end
|
|
164
164
|
|
|
@@ -192,27 +192,27 @@ module VCR
|
|
|
192
192
|
|
|
193
193
|
# List of suggestions for how to configure VCR to handle the request.
|
|
194
194
|
ALL_SUGGESTIONS = {
|
|
195
|
-
:
|
|
195
|
+
use_new_episodes: [
|
|
196
196
|
["You can use the :new_episodes record mode to allow VCR to",
|
|
197
197
|
"record this new request to the existing cassette"],
|
|
198
198
|
"https://benoittgt.github.io/vcr/?v=%s#/record_modes/new_episodes"
|
|
199
199
|
],
|
|
200
200
|
|
|
201
|
-
:
|
|
201
|
+
delete_cassette_for_once: [
|
|
202
202
|
["The current record mode (:once) does not allow new requests to be recorded",
|
|
203
203
|
"to a previously recorded cassette. You can delete the cassette file and re-run",
|
|
204
204
|
"your tests to allow the cassette to be recorded with this request"],
|
|
205
205
|
"https://benoittgt.github.io/vcr/?v=%s#/record_modes/once"
|
|
206
206
|
],
|
|
207
207
|
|
|
208
|
-
:
|
|
208
|
+
deal_with_none: [
|
|
209
209
|
["The current record mode (:none) does not allow requests to be recorded. You",
|
|
210
210
|
"can temporarily change the record mode to :once, delete the cassette file ",
|
|
211
211
|
"and re-run your tests to allow the cassette to be recorded with this request"],
|
|
212
212
|
"https://benoittgt.github.io/vcr/?v=%s#/record_modes/none"
|
|
213
213
|
],
|
|
214
214
|
|
|
215
|
-
:
|
|
215
|
+
none_without_file: [
|
|
216
216
|
["The current record mode (:none) does not allow requests to be recorded.",
|
|
217
217
|
"One or more cassette names registered was not found. Use ",
|
|
218
218
|
":new_episodes or :once record modes to record a new cassette"],
|
|
@@ -220,27 +220,27 @@ module VCR
|
|
|
220
220
|
],
|
|
221
221
|
|
|
222
222
|
|
|
223
|
-
:
|
|
223
|
+
use_a_cassette: [
|
|
224
224
|
["If you want VCR to record this request and play it back during future test",
|
|
225
225
|
"runs, you should wrap your test (or this portion of your test) in a",
|
|
226
226
|
"`VCR.use_cassette` block"],
|
|
227
227
|
"https://benoittgt.github.io/vcr/?v=%s#/getting_started"
|
|
228
228
|
],
|
|
229
229
|
|
|
230
|
-
:
|
|
230
|
+
allow_http_connections_when_no_cassette: [
|
|
231
231
|
["If you only want VCR to handle requests made while a cassette is in use,",
|
|
232
232
|
"configure `allow_http_connections_when_no_cassette = true`. VCR will",
|
|
233
233
|
"ignore this request since it is made when there is no cassette"],
|
|
234
234
|
"https://benoittgt.github.io/vcr/?v=%s#/configuration/allow_http_connections_when_no_cassette"
|
|
235
235
|
],
|
|
236
236
|
|
|
237
|
-
:
|
|
237
|
+
ignore_request: [
|
|
238
238
|
["If you want VCR to ignore this request (and others like it), you can",
|
|
239
239
|
"set an `ignore_request` callback"],
|
|
240
240
|
"https://benoittgt.github.io/vcr/?v=%s#/configuration/ignore_request"
|
|
241
241
|
],
|
|
242
242
|
|
|
243
|
-
:
|
|
243
|
+
allow_playback_repeats: [
|
|
244
244
|
["The cassette contains an HTTP interaction that matches this request,",
|
|
245
245
|
"but it has already been played back. If you wish to allow a single HTTP",
|
|
246
246
|
"interaction to be played back multiple times, set the `:allow_playback_repeats`",
|
|
@@ -248,7 +248,7 @@ module VCR
|
|
|
248
248
|
"https://benoittgt.github.io/vcr/?v=%s#/request_matching/playback_repeats"
|
|
249
249
|
],
|
|
250
250
|
|
|
251
|
-
:
|
|
251
|
+
match_requests_on: [
|
|
252
252
|
["The cassette contains %s not been",
|
|
253
253
|
"played back. If your request is non-deterministic, you may need to",
|
|
254
254
|
"change your :match_requests_on cassette option to be more lenient",
|
|
@@ -256,7 +256,7 @@ module VCR
|
|
|
256
256
|
"https://benoittgt.github.io/vcr/?v=%s#/request_matching"
|
|
257
257
|
],
|
|
258
258
|
|
|
259
|
-
:
|
|
259
|
+
try_debug_logger: [
|
|
260
260
|
["If you're surprised VCR is raising this error",
|
|
261
261
|
"and want insight about how VCR attempted to handle the request,",
|
|
262
262
|
"you can use the debug_logger configuration option to log more details"],
|
|
@@ -40,13 +40,13 @@ module VCR
|
|
|
40
40
|
|
|
41
41
|
def on_stubbed_by_vcr_request
|
|
42
42
|
response = ::Typhoeus::Response.new \
|
|
43
|
-
:
|
|
44
|
-
:
|
|
45
|
-
:
|
|
46
|
-
:
|
|
47
|
-
:
|
|
48
|
-
:
|
|
49
|
-
:
|
|
43
|
+
http_version: stubbed_response.http_version,
|
|
44
|
+
code: stubbed_response.status.code,
|
|
45
|
+
status_message: stubbed_response.status.message,
|
|
46
|
+
headers: stubbed_response_headers,
|
|
47
|
+
body: stubbed_response.body,
|
|
48
|
+
effective_url: stubbed_response.adapter_metadata.fetch('effective_url', request.url),
|
|
49
|
+
mock: true
|
|
50
50
|
|
|
51
51
|
first_header_line = "HTTP/#{stubbed_response.http_version} #{response.code} #{response.status_message}\r\n"
|
|
52
52
|
response.instance_variable_set(:@first_header_line, first_header_line)
|
|
@@ -122,9 +122,9 @@ module VCR
|
|
|
122
122
|
|
|
123
123
|
def on_stubbed_by_vcr_request
|
|
124
124
|
{
|
|
125
|
-
:
|
|
126
|
-
:
|
|
127
|
-
:
|
|
125
|
+
body: stubbed_response.body.dup, # Excon mutates the body, so we must dup it :-(
|
|
126
|
+
status: [stubbed_response.status.code.to_i, stubbed_response.status.message],
|
|
127
|
+
headers: stubbed_response.headers
|
|
128
128
|
}
|
|
129
129
|
end
|
|
130
130
|
end
|
|
@@ -135,7 +135,7 @@ module VCR
|
|
|
135
135
|
global_hook_disabled?(req) ? nil : RequestHandler.new(req).handle
|
|
136
136
|
end
|
|
137
137
|
|
|
138
|
-
::WebMock.after_request(:
|
|
138
|
+
::WebMock.after_request(real_requests_only: true) do |request, response|
|
|
139
139
|
unless VCR.library_hooks.disabled?(:webmock)
|
|
140
140
|
http_interaction = VCR::HTTPInteraction.new \
|
|
141
141
|
typed_request_for(request), vcr_response_for(response)
|
data/lib/vcr/middleware/excon.rb
CHANGED
|
@@ -102,9 +102,9 @@ module VCR
|
|
|
102
102
|
|
|
103
103
|
def on_stubbed_by_vcr_request
|
|
104
104
|
request_params[:response] = {
|
|
105
|
-
:
|
|
106
|
-
:
|
|
107
|
-
:
|
|
105
|
+
body: stubbed_response.body.dup, # Excon mutates the body, so we must dup it :-(
|
|
106
|
+
headers: normalized_headers(stubbed_response.headers || {}),
|
|
107
|
+
status: stubbed_response.status.code
|
|
108
108
|
}
|
|
109
109
|
end
|
|
110
110
|
|
|
@@ -100,7 +100,7 @@ module VCR
|
|
|
100
100
|
def on_stubbed_by_vcr_request
|
|
101
101
|
headers = env[:response_headers] ||= ::Faraday::Utils::Headers.new
|
|
102
102
|
headers.update stubbed_response.headers if stubbed_response.headers
|
|
103
|
-
env.update :
|
|
103
|
+
env.update status: stubbed_response.status.code, body: stubbed_response.body
|
|
104
104
|
|
|
105
105
|
@vcr_response = stubbed_response
|
|
106
106
|
|
data/lib/vcr/middleware/rack.rb
CHANGED
|
@@ -33,7 +33,7 @@ module VCR
|
|
|
33
33
|
# app = Rack::Builder.new do
|
|
34
34
|
# use VCR::Middleware::Rack do |cassette, env|
|
|
35
35
|
# cassette.name "rack/#{env['SERVER_NAME']}"
|
|
36
|
-
# cassette.options :
|
|
36
|
+
# cassette.options record: :new_episodes
|
|
37
37
|
# end
|
|
38
38
|
#
|
|
39
39
|
# run MyRackApp
|
|
@@ -77,14 +77,14 @@ module VCR
|
|
|
77
77
|
# without_timestamp = VCR.request_matchers.uri_without_param(:timestamp)
|
|
78
78
|
#
|
|
79
79
|
# # use it directly...
|
|
80
|
-
# VCR.use_cassette('example', :
|
|
80
|
+
# VCR.use_cassette('example', match_requests_on: [:method, without_timestamp]) { }
|
|
81
81
|
#
|
|
82
82
|
# # ...or register it as a named matcher
|
|
83
83
|
# VCR.configure do |c|
|
|
84
84
|
# c.register_request_matcher(:uri_without_timestamp, &without_timestamp)
|
|
85
85
|
# end
|
|
86
86
|
#
|
|
87
|
-
# VCR.use_cassette('example', :
|
|
87
|
+
# VCR.use_cassette('example', match_requests_on: [:method, :uri_without_timestamp]) { }
|
|
88
88
|
#
|
|
89
89
|
# @param ignores [Array<#to_s>] The names of the query parameters to ignore
|
|
90
90
|
# @return [#call] the request matcher
|
data/lib/vcr/structs.rb
CHANGED
|
@@ -38,7 +38,7 @@ module VCR
|
|
|
38
38
|
# ASCII-8BIT just means binary, so encoding to it is nonsensical
|
|
39
39
|
# and yet "\u00f6".encode("ASCII-8BIT") raises an error.
|
|
40
40
|
# Instead, we'll force encode it (essentially just tagging it as binary)
|
|
41
|
-
return string.force_encoding(encoding) if encoding == Encoding::BINARY
|
|
41
|
+
return string.dup.force_encoding(encoding) if encoding == Encoding::BINARY
|
|
42
42
|
|
|
43
43
|
string.encode(encoding)
|
|
44
44
|
rescue EncodingError => e
|
|
@@ -366,8 +366,10 @@ module VCR
|
|
|
366
366
|
end
|
|
367
367
|
|
|
368
368
|
# Checks if the type of encoding is one of "gzip" or "deflate".
|
|
369
|
+
# An empty body is never compressed, whatever the header says: a HEAD
|
|
370
|
+
# response carries the Content-Encoding of the GET it describes.
|
|
369
371
|
def compressed?
|
|
370
|
-
%w[ gzip deflate ].include?
|
|
372
|
+
!body.to_s.empty? && %w[ gzip deflate ].include?(content_encoding)
|
|
371
373
|
end
|
|
372
374
|
|
|
373
375
|
# Checks if VCR decompressed the response body
|
|
@@ -381,6 +383,8 @@ module VCR
|
|
|
381
383
|
# @raise [VCR::Errors::UnknownContentEncodingError] if the content encoding
|
|
382
384
|
# is not a known encoding.
|
|
383
385
|
def decompress
|
|
386
|
+
return self if body.to_s.empty?
|
|
387
|
+
|
|
384
388
|
self.class.decompress(body, content_encoding) { |new_body|
|
|
385
389
|
self.body = new_body
|
|
386
390
|
update_content_length_header
|
|
@@ -399,7 +403,7 @@ module VCR
|
|
|
399
403
|
new_body = begin
|
|
400
404
|
case type
|
|
401
405
|
when 'gzip'
|
|
402
|
-
body_str =
|
|
406
|
+
body_str = String.new
|
|
403
407
|
writer = Zlib::GzipWriter.new(StringIO.new(body_str), encoding: 'ASCII-8BIT')
|
|
404
408
|
writer.write(body)
|
|
405
409
|
writer.close
|
|
@@ -545,11 +549,23 @@ module VCR
|
|
|
545
549
|
def filter!(text, replacement_text)
|
|
546
550
|
text, replacement_text = text.to_s, replacement_text.to_s
|
|
547
551
|
return self if [text, replacement_text].any? { |t| t.empty? }
|
|
552
|
+
ensure_mutable_strings!(self)
|
|
548
553
|
filter_object!(self, text, replacement_text)
|
|
549
554
|
end
|
|
550
555
|
|
|
551
556
|
private
|
|
552
557
|
|
|
558
|
+
# Walk the interaction and replace any String values with a dup'd copy
|
|
559
|
+
# so that subsequent in-place mutations (e.g. gsub!) don't trigger
|
|
560
|
+
# "literal string will be frozen" warnings on Ruby 3.4+.
|
|
561
|
+
def ensure_mutable_strings!(object)
|
|
562
|
+
if object.respond_to?(:each_pair) && object.respond_to?(:[]=)
|
|
563
|
+
object.each_pair { |name, v| v.is_a?(String) ? object[name] = v.dup : ensure_mutable_strings!(v) }
|
|
564
|
+
elsif object.is_a?(Array)
|
|
565
|
+
object.each_with_index { |o, i| o.is_a?(String) ? object[i] = o.dup : ensure_mutable_strings!(o) }
|
|
566
|
+
end
|
|
567
|
+
end
|
|
568
|
+
|
|
553
569
|
def filter_object!(object, text, replacement_text)
|
|
554
570
|
if object.respond_to?(:gsub)
|
|
555
571
|
object.gsub!(text, replacement_text) if object.include?(text)
|
|
@@ -25,7 +25,7 @@ module VCR
|
|
|
25
25
|
#
|
|
26
26
|
# @param tag_names [Array<String,Hash>] the cucumber scenario tags. If
|
|
27
27
|
# the last argument is a hash it is treated as cassette options.
|
|
28
|
-
# -
|
|
28
|
+
# - `use_scenario_name: true` to automatically name the
|
|
29
29
|
# cassette according to the scenario name.
|
|
30
30
|
def tags(*tag_names)
|
|
31
31
|
original_options = tag_names.last.is_a?(::Hash) ? tag_names.pop : {}
|
|
@@ -71,7 +71,7 @@ module VCR
|
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
@main_object.After(tag_name) do |scenario|
|
|
74
|
-
VCR.eject_cassette(:
|
|
74
|
+
VCR.eject_cassette(skip_no_unused_interactions_assertion: scenario.failed?)
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
self.class.add_tag(tag_name)
|
|
@@ -30,7 +30,7 @@ module VCR
|
|
|
30
30
|
def configure!
|
|
31
31
|
::RSpec.configure do |config|
|
|
32
32
|
|
|
33
|
-
when_tagged_with_vcr = { :
|
|
33
|
+
when_tagged_with_vcr = { vcr: lambda { |v| !!v } }
|
|
34
34
|
|
|
35
35
|
config.before(:each, when_tagged_with_vcr) do |ex|
|
|
36
36
|
example = ex.respond_to?(:metadata) ? ex : ex.example
|
|
@@ -54,7 +54,7 @@ module VCR
|
|
|
54
54
|
|
|
55
55
|
config.after(:each, when_tagged_with_vcr) do |ex|
|
|
56
56
|
example = ex.respond_to?(:metadata) ? ex : ex.example
|
|
57
|
-
VCR.eject_cassette(:
|
|
57
|
+
VCR.eject_cassette(skip_no_unused_interactions_assertion: !!example.exception)
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
end
|
data/lib/vcr/version.rb
CHANGED
data/lib/vcr.rb
CHANGED
|
@@ -56,7 +56,7 @@ module VCR
|
|
|
56
56
|
# `:record` option.
|
|
57
57
|
#
|
|
58
58
|
# @example
|
|
59
|
-
# VCR.insert_cassette('twitter', :
|
|
59
|
+
# VCR.insert_cassette('twitter', record: :new_episodes)
|
|
60
60
|
#
|
|
61
61
|
# # ...later, after making an HTTP request:
|
|
62
62
|
#
|
|
@@ -140,7 +140,7 @@ module VCR
|
|
|
140
140
|
cassette
|
|
141
141
|
elsif !ignore_cassettes?
|
|
142
142
|
message = "VCR is turned off. You must turn it on before you can insert a cassette. " +
|
|
143
|
-
"Or you can use the
|
|
143
|
+
"Or you can use the `ignore_cassettes: true` option to completely ignore cassette insertions."
|
|
144
144
|
raise TurnedOffError.new(message)
|
|
145
145
|
end
|
|
146
146
|
end
|
|
@@ -152,7 +152,7 @@ module VCR
|
|
|
152
152
|
# @param options [Hash] Eject options.
|
|
153
153
|
# @option options :skip_no_unused_interactions_assertion [Boolean]
|
|
154
154
|
# If `true` is given, this will skip the "no unused HTTP interactions"
|
|
155
|
-
# assertion enabled by the
|
|
155
|
+
# assertion enabled by the `allow_unused_http_interactions: false`
|
|
156
156
|
# cassette option. This is intended for use when your test has had
|
|
157
157
|
# an error, but your test framework has already handled it.
|
|
158
158
|
# @return [VCR::Cassette, nil] the ejected cassette if there was one
|
|
@@ -168,7 +168,7 @@ module VCR
|
|
|
168
168
|
# block, and ejects the cassette.
|
|
169
169
|
#
|
|
170
170
|
# @example
|
|
171
|
-
# VCR.use_cassette('twitter', :
|
|
171
|
+
# VCR.use_cassette('twitter', record: :new_episodes) do
|
|
172
172
|
# # make an HTTP request
|
|
173
173
|
# end
|
|
174
174
|
#
|
|
@@ -246,7 +246,7 @@ module VCR
|
|
|
246
246
|
# @example
|
|
247
247
|
# VCR.cucumber_tags do |t|
|
|
248
248
|
# t.tags "tag1", "tag2"
|
|
249
|
-
# t.tag "@some_other_tag", :
|
|
249
|
+
# t.tag "@some_other_tag", record: :new_episodes
|
|
250
250
|
# end
|
|
251
251
|
#
|
|
252
252
|
# @yield the cucumber tags configuration block
|
|
@@ -434,10 +434,10 @@ private
|
|
|
434
434
|
|
|
435
435
|
def dup_context(context)
|
|
436
436
|
{
|
|
437
|
-
:
|
|
438
|
-
:
|
|
439
|
-
:
|
|
440
|
-
:
|
|
437
|
+
turned_off: context[:turned_off],
|
|
438
|
+
ignore_cassettes: context[:ignore_cassettes],
|
|
439
|
+
cassettes: [],
|
|
440
|
+
linked_context: context
|
|
441
441
|
}
|
|
442
442
|
end
|
|
443
443
|
|
|
@@ -462,10 +462,10 @@ private
|
|
|
462
462
|
initialize_fibers
|
|
463
463
|
@context = {
|
|
464
464
|
MainThread => {
|
|
465
|
-
:
|
|
466
|
-
:
|
|
467
|
-
:
|
|
468
|
-
:
|
|
465
|
+
turned_off: false,
|
|
466
|
+
ignore_cassettes: false,
|
|
467
|
+
cassettes: [],
|
|
468
|
+
linked_context: nil
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
471
|
@configuration = Configuration.new
|
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.
|
|
4
|
+
version: 6.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Myron Marston
|
|
@@ -63,7 +63,7 @@ licenses:
|
|
|
63
63
|
- Hippocratic-2.1
|
|
64
64
|
- MIT
|
|
65
65
|
metadata:
|
|
66
|
-
changelog_uri: https://github.com/vcr/vcr/blob/v6.4.
|
|
66
|
+
changelog_uri: https://github.com/vcr/vcr/blob/v6.4.1/CHANGELOG.md
|
|
67
67
|
funding_uri: https://opencollective.com/vcr
|
|
68
68
|
rdoc_options: []
|
|
69
69
|
require_paths:
|
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
79
79
|
- !ruby/object:Gem::Version
|
|
80
80
|
version: '0'
|
|
81
81
|
requirements: []
|
|
82
|
-
rubygems_version: 4.0.
|
|
82
|
+
rubygems_version: 4.0.14
|
|
83
83
|
specification_version: 4
|
|
84
84
|
summary: Record your test suite's HTTP interactions and replay them during future
|
|
85
85
|
test runs for fast, deterministic, accurate tests.
|